From 497d0466af7d2d97f178f93a9aebb87cdf129952 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Thu, 4 Sep 2025 14:06:19 +0200 Subject: [PATCH] feat: kmd rust api client; txtype string enum generation with macros Adds kmd rust client generation. Introduces Jinja2 macros for generating Rust enums, including support for "Unknown" variants for enhanced deserialization. This change streamlines the enum generation process and provides better handling of unknown enum values, particularly in the KMD client. It also ensures TxType in KMD spec can handle unknown values, which is required. --- .github/workflows/api_openapi_sync.yml | 9 +- Cargo.lock | 19 + Cargo.toml | 1 + api/oas_generator/ARCHITECTURE.md | 18 + .../rust_oas_generator/generator/filters.py | 7 +- .../rust_oas_generator/parser/oas_parser.py | 5 + .../templates/apis/client.rs.j2 | 6 +- .../templates/apis/endpoint.rs.j2 | 14 + .../templates/macros/enum_macros.j2 | 72 +- .../templates/models/model.rs.j2 | 23 +- api/package.json | 4 + api/scripts/convert-openapi.ts | 213 +- api/scripts/data/README.md | 33 + api/scripts/data/transaction_types.json | 47 + api/scripts/validate-transaction-types.ts | 135 ++ api/specs/kmd.oas2.json | 1705 +++++++++++++++ api/specs/kmd.oas3.json | 1892 +++++++++++++++++ .../apis/account_application_information.rs | 13 +- .../src/apis/account_asset_information.rs | 13 +- .../src/apis/account_assets_information.rs | 1 - .../src/apis/account_information.rs | 13 +- .../src/apis/experimental_check.rs | 1 - .../src/apis/generate_participation_keys.rs | 28 +- .../src/apis/get_application_box_by_name.rs | 1 - .../src/apis/get_application_boxes.rs | 1 - .../src/apis/get_application_by_id.rs | 1 - .../algod_client/src/apis/get_asset_by_id.rs | 1 - crates/algod_client/src/apis/get_block.rs | 13 +- .../algod_client/src/apis/get_block_hash.rs | 1 - .../algod_client/src/apis/get_block_logs.rs | 1 - .../src/apis/get_block_time_stamp_offset.rs | 1 - .../algod_client/src/apis/get_block_txids.rs | 1 - crates/algod_client/src/apis/get_config.rs | 29 +- .../src/apis/get_debug_settings_prof.rs | 1 - crates/algod_client/src/apis/get_genesis.rs | 1 - .../src/apis/get_ledger_state_delta.rs | 13 +- ...edger_state_delta_for_transaction_group.rs | 13 +- .../src/apis/get_light_block_header_proof.rs | 1 - .../src/apis/get_participation_key_by_id.rs | 1 - .../src/apis/get_participation_keys.rs | 1 - .../src/apis/get_pending_transactions.rs | 13 +- .../get_pending_transactions_by_address.rs | 13 +- crates/algod_client/src/apis/get_ready.rs | 1 - .../algod_client/src/apis/get_state_proof.rs | 1 - crates/algod_client/src/apis/get_status.rs | 1 - crates/algod_client/src/apis/get_supply.rs | 1 - .../algod_client/src/apis/get_sync_round.rs | 1 - ...ion_group_ledger_state_deltas_for_round.rs | 13 +- .../src/apis/get_transaction_proof.rs | 1 - crates/algod_client/src/apis/get_version.rs | 1 - crates/algod_client/src/apis/health_check.rs | 1 - crates/algod_client/src/apis/metrics.rs | 1 - .../apis/pending_transaction_information.rs | 13 +- crates/algod_client/src/apis/swagger_json.rs | 29 +- .../src/apis/transaction_params.rs | 1 - .../algod_client/src/apis/wait_for_block.rs | 1 - crates/algokit_utils/Cargo.toml | 4 +- .../algokit_utils/tests/kmd/key_management.rs | 109 + crates/algokit_utils/tests/kmd/mod.rs | 2 + .../tests/kmd/wallet_lifecycle.rs | 56 + crates/algokit_utils/tests/kmd_tests.rs | 1 + .../apis/lookup_account_app_local_states.rs | 1 - .../src/apis/lookup_account_assets.rs | 1 - .../src/apis/lookup_account_by_id.rs | 1 - .../lookup_account_created_applications.rs | 1 - .../src/apis/lookup_account_created_assets.rs | 1 - .../src/apis/lookup_account_transactions.rs | 1 - .../lookup_application_box_by_id_and_name.rs | 1 - .../src/apis/lookup_application_by_id.rs | 1 - .../src/apis/lookup_application_logs_by_id.rs | 1 - .../src/apis/lookup_asset_balances.rs | 1 - .../src/apis/lookup_asset_by_id.rs | 1 - .../src/apis/lookup_asset_transactions.rs | 1 - .../indexer_client/src/apis/lookup_block.rs | 1 - .../src/apis/lookup_transaction.rs | 1 - .../src/apis/make_health_check.rs | 1 - .../src/apis/search_for_accounts.rs | 1 - .../src/apis/search_for_application_boxes.rs | 1 - .../src/apis/search_for_applications.rs | 1 - .../src/apis/search_for_assets.rs | 1 - .../src/apis/search_for_block_headers.rs | 1 - .../src/apis/search_for_transactions.rs | 1 - crates/kmd_client/Cargo.toml | 39 + crates/kmd_client/README.md | 280 +++ crates/kmd_client/src/apis/client.rs | 251 +++ crates/kmd_client/src/apis/create_wallet.rs | 86 + crates/kmd_client/src/apis/delete_key.rs | 86 + crates/kmd_client/src/apis/delete_multisig.rs | 86 + crates/kmd_client/src/apis/export_key.rs | 86 + .../kmd_client/src/apis/export_master_key.rs | 86 + crates/kmd_client/src/apis/export_multisig.rs | 86 + crates/kmd_client/src/apis/generate_key.rs | 86 + crates/kmd_client/src/apis/get_version.rs | 77 + crates/kmd_client/src/apis/get_wallet_info.rs | 86 + crates/kmd_client/src/apis/import_key.rs | 86 + crates/kmd_client/src/apis/import_multisig.rs | 86 + .../src/apis/init_wallet_handle_token.rs | 86 + .../src/apis/list_keys_in_wallet.rs | 86 + crates/kmd_client/src/apis/list_multisig.rs | 86 + crates/kmd_client/src/apis/list_wallets.rs | 77 + crates/kmd_client/src/apis/mod.rs | 335 +++ .../src/apis/release_wallet_handle_token.rs | 86 + crates/kmd_client/src/apis/rename_wallet.rs | 86 + .../src/apis/renew_wallet_handle_token.rs | 86 + .../src/apis/sign_multisig_program.rs | 86 + .../src/apis/sign_multisig_transaction.rs | 86 + crates/kmd_client/src/apis/sign_program.rs | 86 + .../kmd_client/src/apis/sign_transaction.rs | 86 + crates/kmd_client/src/apis/swagger_handler.rs | 55 + crates/kmd_client/src/lib.rs | 8 + .../src/models/apiv1_delete_key_response.rs | 29 + .../models/apiv1_delete_multisig_response.rs | 29 + .../src/models/apiv1_get_wallets_response.rs | 33 + .../models/apiv1_post_key_export_response.rs | 33 + .../models/apiv1_post_key_import_response.rs | 31 + .../models/apiv1_post_key_list_response.rs | 31 + .../src/models/apiv1_post_key_response.rs | 31 + .../apiv1_post_master_key_export_response.rs | 36 + .../apiv1_post_multisig_export_response.rs | 37 + .../apiv1_post_multisig_import_response.rs | 31 + .../apiv1_post_multisig_list_response.rs | 31 + ...iv1_post_multisig_program_sign_response.rs | 34 + ...post_multisig_transaction_sign_response.rs | 34 + .../apiv1_post_program_sign_response.rs | 34 + .../apiv1_post_transaction_sign_response.rs | 34 + .../models/apiv1_post_wallet_info_response.rs | 33 + .../models/apiv1_post_wallet_init_response.rs | 34 + .../apiv1_post_wallet_release_response.rs | 29 + .../apiv1_post_wallet_rename_response.rs | 33 + .../apiv1_post_wallet_renew_response.rs | 33 + .../src/models/apiv1_post_wallet_response.rs | 33 + crates/kmd_client/src/models/apiv1_wallet.rs | 38 + .../src/models/apiv1_wallet_handle.rs | 31 + .../src/models/create_wallet_request.rs | 37 + .../src/models/delete_key_request.rs | 33 + .../src/models/delete_multisig_request.rs | 33 + crates/kmd_client/src/models/digest.rs | 14 + .../src/models/ed25519_private_key.rs | 14 + .../src/models/ed25519_public_key.rs | 14 + .../src/models/ed25519_signature.rs | 14 + .../src/models/export_key_request.rs | 33 + .../src/models/export_master_key_request.rs | 31 + .../src/models/export_multisig_request.rs | 31 + .../src/models/generate_key_request.rs | 31 + .../src/models/import_key_request.rs | 33 + .../src/models/import_multisig_request.rs | 37 + .../init_wallet_handle_token_request.rs | 28 + .../src/models/list_keys_request.rs | 29 + .../src/models/list_multisig_request.rs | 29 + .../src/models/list_wallets_request.rs | 23 + .../src/models/master_derivation_key.rs | 15 + crates/kmd_client/src/models/mod.rs | 124 ++ crates/kmd_client/src/models/multisig_sig.rs | 32 + .../kmd_client/src/models/multisig_subsig.rs | 32 + crates/kmd_client/src/models/private_key.rs | 22 + crates/kmd_client/src/models/public_key.rs | 22 + .../release_wallet_handle_token_request.rs | 29 + .../src/models/rename_wallet_request.rs | 30 + .../renew_wallet_handle_token_request.rs | 29 + .../src/models/sign_multisig_request.rs | 46 + .../models/sign_program_multisig_request.rs | 45 + .../src/models/sign_program_request.rs | 38 + .../src/models/sign_transaction_request.rs | 44 + crates/kmd_client/src/models/signature.rs | 22 + crates/kmd_client/src/models/tx_type.rs | 85 + .../kmd_client/src/models/versions_request.rs | 23 + .../src/models/versions_response.rs | 27 + .../src/models/wallet_info_request.rs | 29 + tools/api_tools/src/main.rs | 54 +- 169 files changed, 9157 insertions(+), 287 deletions(-) create mode 100644 api/scripts/data/README.md create mode 100644 api/scripts/data/transaction_types.json create mode 100644 api/scripts/validate-transaction-types.ts create mode 100644 api/specs/kmd.oas2.json create mode 100644 api/specs/kmd.oas3.json create mode 100644 crates/algokit_utils/tests/kmd/key_management.rs create mode 100644 crates/algokit_utils/tests/kmd/mod.rs create mode 100644 crates/algokit_utils/tests/kmd/wallet_lifecycle.rs create mode 100644 crates/algokit_utils/tests/kmd_tests.rs create mode 100644 crates/kmd_client/Cargo.toml create mode 100644 crates/kmd_client/README.md create mode 100644 crates/kmd_client/src/apis/client.rs create mode 100644 crates/kmd_client/src/apis/create_wallet.rs create mode 100644 crates/kmd_client/src/apis/delete_key.rs create mode 100644 crates/kmd_client/src/apis/delete_multisig.rs create mode 100644 crates/kmd_client/src/apis/export_key.rs create mode 100644 crates/kmd_client/src/apis/export_master_key.rs create mode 100644 crates/kmd_client/src/apis/export_multisig.rs create mode 100644 crates/kmd_client/src/apis/generate_key.rs create mode 100644 crates/kmd_client/src/apis/get_version.rs create mode 100644 crates/kmd_client/src/apis/get_wallet_info.rs create mode 100644 crates/kmd_client/src/apis/import_key.rs create mode 100644 crates/kmd_client/src/apis/import_multisig.rs create mode 100644 crates/kmd_client/src/apis/init_wallet_handle_token.rs create mode 100644 crates/kmd_client/src/apis/list_keys_in_wallet.rs create mode 100644 crates/kmd_client/src/apis/list_multisig.rs create mode 100644 crates/kmd_client/src/apis/list_wallets.rs create mode 100644 crates/kmd_client/src/apis/mod.rs create mode 100644 crates/kmd_client/src/apis/release_wallet_handle_token.rs create mode 100644 crates/kmd_client/src/apis/rename_wallet.rs create mode 100644 crates/kmd_client/src/apis/renew_wallet_handle_token.rs create mode 100644 crates/kmd_client/src/apis/sign_multisig_program.rs create mode 100644 crates/kmd_client/src/apis/sign_multisig_transaction.rs create mode 100644 crates/kmd_client/src/apis/sign_program.rs create mode 100644 crates/kmd_client/src/apis/sign_transaction.rs create mode 100644 crates/kmd_client/src/apis/swagger_handler.rs create mode 100644 crates/kmd_client/src/lib.rs create mode 100644 crates/kmd_client/src/models/apiv1_delete_key_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_delete_multisig_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_get_wallets_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_key_export_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_key_import_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_key_list_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_key_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_master_key_export_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_multisig_export_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_multisig_import_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_multisig_list_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_multisig_program_sign_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_multisig_transaction_sign_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_program_sign_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_transaction_sign_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_wallet_info_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_wallet_init_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_wallet_release_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_wallet_rename_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_wallet_renew_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_post_wallet_response.rs create mode 100644 crates/kmd_client/src/models/apiv1_wallet.rs create mode 100644 crates/kmd_client/src/models/apiv1_wallet_handle.rs create mode 100644 crates/kmd_client/src/models/create_wallet_request.rs create mode 100644 crates/kmd_client/src/models/delete_key_request.rs create mode 100644 crates/kmd_client/src/models/delete_multisig_request.rs create mode 100644 crates/kmd_client/src/models/digest.rs create mode 100644 crates/kmd_client/src/models/ed25519_private_key.rs create mode 100644 crates/kmd_client/src/models/ed25519_public_key.rs create mode 100644 crates/kmd_client/src/models/ed25519_signature.rs create mode 100644 crates/kmd_client/src/models/export_key_request.rs create mode 100644 crates/kmd_client/src/models/export_master_key_request.rs create mode 100644 crates/kmd_client/src/models/export_multisig_request.rs create mode 100644 crates/kmd_client/src/models/generate_key_request.rs create mode 100644 crates/kmd_client/src/models/import_key_request.rs create mode 100644 crates/kmd_client/src/models/import_multisig_request.rs create mode 100644 crates/kmd_client/src/models/init_wallet_handle_token_request.rs create mode 100644 crates/kmd_client/src/models/list_keys_request.rs create mode 100644 crates/kmd_client/src/models/list_multisig_request.rs create mode 100644 crates/kmd_client/src/models/list_wallets_request.rs create mode 100644 crates/kmd_client/src/models/master_derivation_key.rs create mode 100644 crates/kmd_client/src/models/mod.rs create mode 100644 crates/kmd_client/src/models/multisig_sig.rs create mode 100644 crates/kmd_client/src/models/multisig_subsig.rs create mode 100644 crates/kmd_client/src/models/private_key.rs create mode 100644 crates/kmd_client/src/models/public_key.rs create mode 100644 crates/kmd_client/src/models/release_wallet_handle_token_request.rs create mode 100644 crates/kmd_client/src/models/rename_wallet_request.rs create mode 100644 crates/kmd_client/src/models/renew_wallet_handle_token_request.rs create mode 100644 crates/kmd_client/src/models/sign_multisig_request.rs create mode 100644 crates/kmd_client/src/models/sign_program_multisig_request.rs create mode 100644 crates/kmd_client/src/models/sign_program_request.rs create mode 100644 crates/kmd_client/src/models/sign_transaction_request.rs create mode 100644 crates/kmd_client/src/models/signature.rs create mode 100644 crates/kmd_client/src/models/tx_type.rs create mode 100644 crates/kmd_client/src/models/versions_request.rs create mode 100644 crates/kmd_client/src/models/versions_response.rs create mode 100644 crates/kmd_client/src/models/wallet_info_request.rs diff --git a/.github/workflows/api_openapi_sync.yml b/.github/workflows/api_openapi_sync.yml index 964f96880..c495ce29d 100644 --- a/.github/workflows/api_openapi_sync.yml +++ b/.github/workflows/api_openapi_sync.yml @@ -1,6 +1,6 @@ name: API OpenAPI Sync # This workflow runs weekly to check if the OpenAPI specifications need to be converted -# and ensures the generated code is up to date. It processes algod and indexer in parallel. +# and ensures the generated code is up to date. It processes algod, indexer, and kmd in parallel. on: schedule: @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - spec: [algod, indexer] + spec: [algod, indexer, kmd] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-api-tools @@ -27,6 +27,11 @@ jobs: - name: Convert ${{ matrix.spec }} OpenAPI specification run: cargo api convert-${{ matrix.spec }} + - name: Validate Transaction Types + run: | + cd api + bun run validate-tx-types + - name: Check for ${{ matrix.spec }} changes run: | git status --porcelain > /tmp/post_${{ matrix.spec }}_status.txt diff --git a/Cargo.lock b/Cargo.lock index 460fa822e..0f4a7b9d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,6 +136,7 @@ dependencies = [ "futures", "hex", "indexer_client", + "kmd_client", "lazy_static", "log", "num-bigint", @@ -1912,6 +1913,24 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "kmd_client" +version = "0.0.1" +dependencies = [ + "algokit_http_client", + "base64 0.22.1", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "serde_with", + "snafu", + "tokio", + "tokio-test", + "url", + "uuid", +] + [[package]] name = "kqueue" version = "1.1.1" diff --git a/Cargo.toml b/Cargo.toml index 42502c371..6d6a435c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ members = [ "crates/ffi_macros", "crates/algod_client", "crates/indexer_client", + "crates/kmd_client", "tools/build_pkgs", "crates/uniffi-bindgen", "docs", diff --git a/api/oas_generator/ARCHITECTURE.md b/api/oas_generator/ARCHITECTURE.md index b9e6f30ce..791060ebb 100644 --- a/api/oas_generator/ARCHITECTURE.md +++ b/api/oas_generator/ARCHITECTURE.md @@ -4,6 +4,24 @@ The Rust OAS Generator is a Jinja2-based code generator that converts OpenAPI 3.x specifications into Rust API clients. The architecture emphasizes separation of concerns between parsing, analysis, and generation phases. +### Primitive Response Handling Pattern (String Early Return) + +For endpoints whose success response body is a raw `String` (i.e., no structured JSON/model deserialization required), the generator emits an early return immediately after UTF-8 validation of the response body. The generic content negotiation / deserialization block is conditionally omitted for these endpoints. This avoids generating unreachable code (previously the template placed the early `return` above a still-rendered negotiation block) and yields simpler, smaller endpoint functions. + +Guidelines: +- Condition: `success_type == "String"` triggers early-return pattern. +- Behavior: `String::from_utf8(response.body)` is performed, mapping any UTF-8 error to an internal `Error::Serde` variant, then `Ok(decoded_string)` is returned. +- No side-effects: Logging, metrics, or header-driven negotiation logic are skipped because they would have been no-ops for raw string passthrough semantics. +- Other primitive/raw types (e.g., potential future `Vec`) currently still flow through the standard content negotiation path; they may be optimized similarly if patterns of unreachable code emerge. + +Rationale: +- Eliminates unreachable code warnings surfaced by Clippy (`unreachable_code`). +- Ensures generated code remains warning-free under `-D warnings` policy. +- Maintains behavioral parity: Non-`String` endpoints continue through negotiation logic untouched. + +Future Extension: +- Introduce analogous conditional blocks for other opaque passthrough response types (e.g., raw bytes) when specifications require them, ensuring consistent early-return semantics without redundant negotiation scaffolding. + ## Core Components ### 1. CLI Interface (`cli.py`) diff --git a/api/oas_generator/rust_oas_generator/generator/filters.py b/api/oas_generator/rust_oas_generator/generator/filters.py index 0eb232934..33bb80e22 100644 --- a/api/oas_generator/rust_oas_generator/generator/filters.py +++ b/api/oas_generator/rust_oas_generator/generator/filters.py @@ -264,13 +264,15 @@ def detect_client_type(spec_title: str) -> str: spec_title: The title field from the OpenAPI spec info section. Returns: - The appropriate client type string (e.g., "Algod", "Indexer"). + The appropriate client type string (e.g., "Algod", "Indexer", "Kmd"). Examples: >>> detect_client_type("Algod REST API.") 'Algod' >>> detect_client_type("Indexer") 'Indexer' + >>> detect_client_type("for KMD HTTP API") + 'Kmd' >>> detect_client_type("Unknown API") 'Api' """ @@ -284,6 +286,9 @@ def detect_client_type(spec_title: str) -> str: return "Algod" if "indexer" in title_lower: return "Indexer" + # KMD titles often contain 'kmd' or phrases like 'for KMD HTTP API' + if "kmd" in title_lower or re.search(r"\bfor\s+kmd\b", title_lower): + return "Kmd" # Fallback: extract first word and capitalize first_word = spec_title.split()[0] if spec_title.split() else "Api" diff --git a/api/oas_generator/rust_oas_generator/parser/oas_parser.py b/api/oas_generator/rust_oas_generator/parser/oas_parser.py index 7477a796e..6520d1534 100644 --- a/api/oas_generator/rust_oas_generator/parser/oas_parser.py +++ b/api/oas_generator/rust_oas_generator/parser/oas_parser.py @@ -29,6 +29,7 @@ "integer": { None: "u64", "int32": "u32", + "uint32": "u32", "int64": "u64", "uint64": "u64", }, @@ -444,6 +445,7 @@ class Schema: # For string enum schemas enum_values: list[str] = field(default_factory=list) is_string_enum: bool = field(init=False) + is_primitive_string_schema: bool = field(init=False, default=False) def __post_init__(self) -> None: # Keep the original struct name without renaming @@ -456,6 +458,9 @@ def __post_init__(self) -> None: self.has_required_fields = len(self.required_fields) > 0 self.has_signed_transaction_fields = any(prop.is_signed_transaction for prop in self.properties) self.is_string_enum = self.schema_type == "string" and len(self.enum_values) > 0 + # Mark primitive string schemas (referenced string without enum) for alias generation later + if self.schema_type == "string" and len(self.enum_values) == 0 and len(self.properties) == 0: + self.is_primitive_string_schema = True @dataclass diff --git a/api/oas_generator/rust_oas_generator/templates/apis/client.rs.j2 b/api/oas_generator/rust_oas_generator/templates/apis/client.rs.j2 index 76025cb0d..7b7d8a84e 100644 --- a/api/oas_generator/rust_oas_generator/templates/apis/client.rs.j2 +++ b/api/oas_generator/rust_oas_generator/templates/apis/client.rs.j2 @@ -57,6 +57,7 @@ impl {{ client_type }}Client { Self { http_client } } + {% if client_type != "Kmd" %} /// Create a new {{ client_type }}Client for Algorand TestNet. #[cfg(feature = "default_client")] pub fn testnet() -> Self { @@ -74,13 +75,14 @@ impl {{ client_type }}Client { )); Self::new(http_client) } + {% endif %} /// Create a new {{ client_type }}Client for a local localnet environment. #[cfg(feature = "default_client")] pub fn localnet() -> Self { let http_client = Arc::new(DefaultHttpClient::with_header( - {% if client_type == "Indexer" %}"http://localhost:8980"{% else %}"http://localhost:4001"{% endif %}, - {% if client_type == "Indexer" %}"X-Indexer-API-Token"{% else %}"X-Algo-API-Token"{% endif %}, + {% if client_type == "Indexer" %}"http://localhost:8980"{% elif client_type == "Kmd" %}"http://localhost:4002"{% else %}"http://localhost:4001"{% endif %}, + {% if client_type == "Indexer" %}"X-Indexer-API-Token"{% elif client_type == "Kmd" %}"X-KMD-API-Token"{% else %}"X-Algo-API-Token"{% endif %}, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", ).expect("Failed to create HTTP client with API token header")); Self::new(http_client) diff --git a/api/oas_generator/rust_oas_generator/templates/apis/endpoint.rs.j2 b/api/oas_generator/rust_oas_generator/templates/apis/endpoint.rs.j2 index 8645016c9..20e55149c 100644 --- a/api/oas_generator/rust_oas_generator/templates/apis/endpoint.rs.j2 +++ b/api/oas_generator/rust_oas_generator/templates/apis/endpoint.rs.j2 @@ -111,6 +111,14 @@ pub async fn {{ operation.rust_function_name }}( {% endif %} {% endfor %} + {# General rule: only set Content-Type when body exists; always set Accept #} + {% if operation.method == "GET" and not has_request_body(operation) %} + let mut headers: HashMap = HashMap::new(); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = None; + + {% else %} {% if operation.request_body_supports_text_plain %} let mut headers: HashMap = HashMap::new(); headers.insert("Content-Type".to_string(), "text/plain".to_string()); @@ -175,6 +183,7 @@ pub async fn {{ operation.rust_function_name }}( None {% endif %}; {% endif %} + {% endif %} let response = http_client .request( @@ -188,6 +197,10 @@ pub async fn {{ operation.rust_function_name }}( .map_err(|e| Error::Http { source: e })?; {% if get_success_response_type(operation) %} + {% set success_type = get_success_response_type(operation) %} + {% if success_type == "String" %} + String::from_utf8(response.body).map_err(|e| Error::Serde { message: e.to_string() }) + {% else %} let content_type = response .headers .get("content-type") @@ -207,6 +220,7 @@ pub async fn {{ operation.rust_function_name }}( }, ContentType::Unsupported(ct) => Err(Error::Serde { message: format!("Unsupported content type: {}", ct) }), } + {% endif %} {% else %} let _ = response; Ok(()) diff --git a/api/oas_generator/rust_oas_generator/templates/macros/enum_macros.j2 b/api/oas_generator/rust_oas_generator/templates/macros/enum_macros.j2 index d270aed8a..e645d668f 100644 --- a/api/oas_generator/rust_oas_generator/templates/macros/enum_macros.j2 +++ b/api/oas_generator/rust_oas_generator/templates/macros/enum_macros.j2 @@ -43,4 +43,74 @@ impl {{ enum_name }} { {{ enum_name }}::default() } } -{% endmacro %} \ No newline at end of file +{% endmacro %} + +{# Macro to generate a Rust enum for string enum values with Unknown(String) fallback #} +{% macro generate_string_enum_with_unknown(enum_name, enum_values, description=None) %} +{% if description %} +{{ description | rust_doc_comment }} +{% endif %} +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub enum {{ enum_name }} { +{% for value in enum_values %} + {{ value | pascal_case }}, +{% endfor %} + /// Fallback for any future/unknown value encountered during deserialization. + Unknown(String), +} + +impl {{ enum_name }} { + pub fn as_str(&self) -> &str { + match self { +{% for value in enum_values %} + {{ enum_name }}::{{ value | pascal_case }} => "{{ value }}", +{% endfor %} + {{ enum_name }}::Unknown(s) => s.as_str(), + } + } +} + +impl std::fmt::Display for {{ enum_name }} { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.as_str()) } +} + +impl Default for {{ enum_name }} { fn default() -> Self { {{ enum_name }}::Unknown(String::new()) } } + +impl AsRef for {{ enum_name }} { fn as_ref(&self) -> &str { self.as_str() } } + +impl From<&str> for {{ enum_name }} { fn from(s: &str) -> Self { {{ enum_name }}::from(s.to_string()) } } +impl From for {{ enum_name }} { + fn from(s: String) -> Self { + match s.as_str() { +{% for value in enum_values %} + "{{ value }}" => {{ enum_name }}::{{ value | pascal_case }}, +{% endfor %} + _ => {{ enum_name }}::Unknown(s), + } + } +} + +impl std::str::FromStr for {{ enum_name }} { + type Err = std::convert::Infallible; + fn from_str(s: &str) -> Result { Ok({{ enum_name }}::from(s)) } +} + +impl serde::Serialize for {{ enum_name }} { + fn serialize(&self, serializer: S) -> Result where S: serde::ser::Serializer { + serializer.serialize_str(self.as_str()) + } +} + +struct {{ enum_name }}Visitor; +impl<'de> serde::de::Visitor<'de> for {{ enum_name }}Visitor { + type Value = {{ enum_name }}; + fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "a string enum value") } + fn visit_str(self, v: &str) -> Result where E: serde::de::Error { Ok({{ enum_name }}::from(v)) } +} + +impl<'de> serde::Deserialize<'de> for {{ enum_name }} { + fn deserialize(deserializer: D) -> Result where D: serde::de::Deserializer<'de> { + deserializer.deserialize_str({{ enum_name }}Visitor) + } +} +{% endmacro %} diff --git a/api/oas_generator/rust_oas_generator/templates/models/model.rs.j2 b/api/oas_generator/rust_oas_generator/templates/models/model.rs.j2 index d62b23858..c72bb7700 100644 --- a/api/oas_generator/rust_oas_generator/templates/models/model.rs.j2 +++ b/api/oas_generator/rust_oas_generator/templates/models/model.rs.j2 @@ -55,7 +55,7 @@ use crate::models::{{ custom_type }}; {% if schema.schema_type == 'array' and schema.underlying_rust_type %} {% if schema.underlying_rust_type.startswith('Vec<') %} {% set alias_inner = schema.underlying_rust_type[4:-1] %} - {% if alias_inner and alias_inner[0].isupper() and '::' not in alias_inner %} + {% if alias_inner and alias_inner[0].isupper() and '::' not in alias_inner and alias_inner not in ['String', 'Vec', 'Option', 'serde_json::Value'] and not alias_inner.startswith('i') and not alias_inner.startswith('u') and alias_inner != 'bool' and alias_inner != 'Vec' %} use crate::models::{{ alias_inner }}; {% endif %} {% endif %} @@ -69,7 +69,26 @@ use crate::models::{{ alias_inner }}; pub type {{ schema.rust_struct_name }} = {{ schema.underlying_rust_type }}; {# Handle string enum schemas as Rust enums #} {% elif schema.is_string_enum %} + {# If the schema declares unknown-fallback support via vendor extension, generate with Unknown #} + {% if schema.vendor_extensions.get('x-algokit-unknown-fallback') %} + {% from 'macros/enum_macros.j2' import generate_string_enum_with_unknown %} +{{ generate_string_enum_with_unknown(schema.rust_struct_name, schema.enum_values, schema.description) }} + {% else %} {{ generate_string_enum(schema.rust_struct_name, schema.enum_values, schema.description) }} + {% endif %} +{# Handle primitive string schemas (referenced string without enum) as transparent newtypes #} +{% elif schema.is_primitive_string_schema %} +{% if schema.description %} +{{ schema.description | rust_doc_comment }} +{% endif %} +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct {{ schema.rust_struct_name }}(pub String); +impl std::fmt::Display for {{ schema.rust_struct_name }} { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) } +} +impl From for {{ schema.rust_struct_name }} { fn from(s: String) -> Self { Self(s) } } +impl From<&str> for {{ schema.rust_struct_name }} { fn from(s: &str) -> Self { Self(s.to_string()) } } +impl AsRef for {{ schema.rust_struct_name }} { fn as_ref(&self) -> &str { &self.0 } } {% else %} {% if schema.description %} {{ schema.description | rust_doc_comment }} @@ -208,7 +227,7 @@ impl AlgorandMsgpack for {{ schema.rust_struct_name }} { } {% endif %} -{% if not (schema.schema_type == 'array' and schema.underlying_rust_type) and not schema.is_string_enum %} +{% if not (schema.schema_type == 'array' and schema.underlying_rust_type) and not schema.is_string_enum and schema.rust_struct_name != 'TxType' %} impl {{ schema.rust_struct_name }} { {% if schema.has_required_fields %} /// Constructor for {{ schema.rust_struct_name }} diff --git a/api/package.json b/api/package.json index 49821e969..b43628be7 100644 --- a/api/package.json +++ b/api/package.json @@ -11,5 +11,9 @@ }, "peerDependencies": { "typescript": "^5" + }, + "scripts": { + "validate-tx-types": "bun scripts/validate-transaction-types.ts", + "convert": "bun scripts/convert-openapi.ts && bun scripts/validate-transaction-types.ts" } } diff --git a/api/scripts/convert-openapi.ts b/api/scripts/convert-openapi.ts index 5a5c79740..925de560b 100644 --- a/api/scripts/convert-openapi.ts +++ b/api/scripts/convert-openapi.ts @@ -1,6 +1,7 @@ #!/usr/bin/env bun import { writeFileSync, mkdirSync } from "fs"; +import transactionTypesData from "./data/transaction_types.json"; import { join, dirname } from "path"; import SwaggerParser from "@apidevtools/swagger-parser"; @@ -600,12 +601,12 @@ class OpenAPIProcessor { console.log(`ℹ️ Transformed ${transformedFieldsCount} required field states`); } - // 7. Transform properties if configured - let transformedPropertiesCount = 0; - if (this.config.fieldTransforms && this.config.fieldTransforms.length > 0) { - transformedPropertiesCount = transformProperties(spec, this.config.fieldTransforms); - console.log(`ℹ️ Applied ${transformedPropertiesCount} property transformations (additions/removals)`); - } + // 7. Transform properties if configured + let transformedPropertiesCount = 0; + if (this.config.fieldTransforms && this.config.fieldTransforms.length > 0) { + transformedPropertiesCount = transformProperties(spec, this.config.fieldTransforms); + console.log(`ℹ️ Applied ${transformedPropertiesCount} property transformations (additions/removals)`); + } // 8. Transform vendor extensions if configured if (this.config.vendorExtensionTransforms && this.config.vendorExtensionTransforms.length > 0) { @@ -694,10 +695,10 @@ async function getLatestIndexerTag(): Promise { } /** - * Process specifications for both algod and indexer + * Process specifications for algod, indexer, and kmd */ async function processAlgorandSpecs() { - await Promise.all([processAlgodSpec(), processIndexerSpec()]); + await Promise.all([processAlgodSpec(), processIndexerSpec(), processKmdSpec()]); } async function processAlgodSpec() { @@ -711,32 +712,32 @@ async function processAlgodSpec() { fieldTransforms: [ { fieldName: "action", - removeItems: ["format"] + removeItems: ["format"], }, { fieldName: "num-uint", removeItems: ["format"], addItems: { - "minimum": 0, - "maximum": 64, - } + minimum: 0, + maximum: 64, + }, }, { fieldName: "num-byte-slice", removeItems: ["format"], addItems: { - "minimum": 0, - "maximum": 64, - } + minimum: 0, + maximum: 64, + }, }, { fieldName: "extra-program-pages", removeItems: ["format"], addItems: { - "minimum": 0, - "maximum": 3, - } - } + minimum: 0, + maximum: 3, + }, + }, ], vendorExtensionTransforms: [ { @@ -790,25 +791,25 @@ async function processIndexerSpec() { fieldName: "num-uint", removeItems: ["x-algorand-format"], addItems: { - "minimum": 0, - "maximum": 64, - } + minimum: 0, + maximum: 64, + }, }, { fieldName: "num-byte-slice", removeItems: ["x-algorand-format"], addItems: { - "minimum": 0, - "maximum": 64, - } + minimum: 0, + maximum: 64, + }, }, { fieldName: "extra-program-pages", addItems: { - "minimum": 0, - "maximum": 3, - } - } + minimum: 0, + maximum: 3, + }, + }, ], vendorExtensionTransforms: [ { @@ -845,6 +846,154 @@ async function processIndexerSpec() { await processAlgorandSpec(config); } +async function processKmdSpec() { + console.log("\n🔄 Processing KMD specification..."); + + const stableTag = await getLatestStableTag(); + + const config: ProcessingConfig = { + sourceUrl: `https://raw.githubusercontent.com/algorand/go-algorand/${stableTag}/daemon/kmd/api/swagger.json`, + outputPath: join(process.cwd(), "specs", "kmd.oas3.json"), + vendorExtensionTransforms: [ + { + sourceProperty: "x-algorand-format", + sourceValue: "uint64", + targetProperty: "x-algokit-bigint", + targetValue: true, + removeSource: true, + }, + { + sourceProperty: "format", + sourceValue: "uint64", + targetProperty: "x-algokit-bigint", + targetValue: true, + removeSource: false, + }, + { + sourceProperty: "x-go-type", + sourceValue: "uint64", + targetProperty: "x-algokit-bigint", + targetValue: true, + removeSource: true, + }, + ], + }; + + // Run KMD-specific processing before validation/save + const processor = new OpenAPIProcessor(config); + try { + // Fetch and convert to OAS3 via processor internals + let spec = await (processor as any).fetchSpec(); + spec = await (processor as any).convertToOpenAPI3(spec); + + // KMD-specific post-processing: + // 1) Remove requestBody from all GET operations + // 2) Inject enum values for TxType if missing (Algorand transaction type codes) + // This resolves generation of an empty struct for referenced primitive schema + // and provides strong typing & serde(renamed) variants in Rust. + // Source: canonical list at scripts/data/transaction_types.json. + const TX_TYPE_ENUM_VALUES = Object.keys((transactionTypesData as any).transaction_types); + if (spec.components?.schemas?.TxType && spec.components.schemas.TxType.type === "string") { + const txTypeSchema = spec.components.schemas.TxType; + if (!Array.isArray(txTypeSchema.enum) || txTypeSchema.enum.length === 0) { + txTypeSchema.enum = TX_TYPE_ENUM_VALUES; + txTypeSchema["x-algokit-source"] = "injected-enum"; + txTypeSchema["x-algokit-unknown-fallback"] = true; + console.log(`ℹ️ Injected enum values into TxType from canonical list: ${TX_TYPE_ENUM_VALUES.join(", ")}`); + } else { + // Validate existing enum matches canonical list + const existing = [...txTypeSchema.enum].sort(); + const canonical = [...TX_TYPE_ENUM_VALUES].sort(); + const mismatch = existing.length !== canonical.length || existing.some((v: string, i: number) => v !== canonical[i]); + if (mismatch) { + console.warn( + `⚠️ TxType enum in spec does not match canonical list. Spec=[${existing.join(", ")}] Canonical=[${canonical.join(", ")}]`, + ); + } else { + console.log("ℹ️ TxType enum matches canonical list"); + } + // Ensure Unknown fallback is enabled even when enum exists + txTypeSchema["x-algokit-unknown-fallback"] = true; + } + } + if (spec.paths && typeof spec.paths === "object") { + for (const [pathName, pathObj] of Object.entries(spec.paths)) { + if (!pathObj || typeof pathObj !== "object") continue; + for (const [method, op] of Object.entries(pathObj as Record)) { + if (method.toLowerCase() === "get" && op && typeof op === "object" && op.requestBody) { + delete (op as any).requestBody; + } + } + } + } + + // 2) Fix operationId typo: ListMultisg -> ListMultisig + if (spec.paths && typeof spec.paths === "object") { + for (const pathObj of Object.values(spec.paths)) { + if (!pathObj || typeof pathObj !== "object") continue; + for (const op of Object.values(pathObj as Record)) { + if (op && typeof op === "object" && typeof op.operationId === "string") { + if (op.operationId.includes("ListMultisg")) { + op.operationId = op.operationId.replaceAll("ListMultisg", "ListMultisig"); + } + } + } + } + } + + // Apply the standard transformations on the adjusted spec using existing helpers + // We mimic the steps in OpenAPIProcessor.process() but on our mutated spec. + const descriptionCount = fixMissingDescriptions(spec); + console.log(`ℹ️ Fixed ${descriptionCount} missing descriptions`); + const pydanticCount = fixPydanticRecursionError(spec); + console.log(`ℹ️ Fixed ${pydanticCount} pydantic recursion errors`); + const fieldNamingCount = fixFieldNaming(spec); + console.log(`ℹ️ Added field rename extensions to ${fieldNamingCount} properties`); + const tealValueCount = fixTealValueBytes(spec); + console.log(`ℹ️ Added bytes base64 extensions to ${tealValueCount} TealValue.bytes properties`); + const bigIntCount = fixBigInt(spec); + console.log(`ℹ️ Added x-algokit-bigint to ${bigIntCount} properties`); + + if (config.requiredFieldTransforms?.length) { + const transformedFieldsCount = transformRequiredFields(spec, config.requiredFieldTransforms); + console.log(`ℹ️ Transformed ${transformedFieldsCount} required field states`); + } + if (config.fieldTransforms?.length) { + const transformedPropertiesCount = transformProperties(spec, config.fieldTransforms); + console.log(`ℹ️ Applied ${transformedPropertiesCount} property transformations (additions/removals)`); + } + if (config.vendorExtensionTransforms?.length) { + const transformCounts = transformVendorExtensions(spec, config.vendorExtensionTransforms); + for (const [countKey, count] of Object.entries(transformCounts)) { + const [sourceProperty, sourceValue] = countKey.split(":"); + const transform = config.vendorExtensionTransforms.find( + (t) => t.sourceProperty === sourceProperty && t.sourceValue === sourceValue, + ); + if (transform) { + console.log(`ℹ️ Transformed ${count} ${sourceProperty}: ${sourceValue} to ${transform.targetProperty}`); + } + } + } + + await SwaggerParser.validate(JSON.parse(JSON.stringify(spec))); + console.log("✅ Specification is valid"); + + // Save + const outputDir = dirname(config.outputPath); + mkdirSync(outputDir, { recursive: true }); + const indent = config.indent || 2; + const content = JSON.stringify(spec, null, indent); + writeFileSync(config.outputPath, content, "utf8"); + console.log(`✅ Specification saved to ${config.outputPath}`); + console.log("✅ OpenAPI processing completed successfully!"); + console.log(`📄 Source: ${config.sourceUrl}`); + console.log(`📄 Output: ${config.outputPath}`); + } catch (error) { + console.error(`❌ Processing failed: ${error instanceof Error ? error.message : error}`); + throw error; + } +} + async function processAlgorandSpec(config: ProcessingConfig) { const processor = new OpenAPIProcessor(config); await processor.process(); @@ -855,13 +1004,15 @@ async function main() { try { const args = process.argv.slice(2); - // Support for individual spec processing or both + // Support for individual spec processing or all if (args.includes("--algod-only")) { await processAlgodSpec(); } else if (args.includes("--indexer-only")) { await processIndexerSpec(); + } else if (args.includes("--kmd-only")) { + await processKmdSpec(); } else { - // Process both by default + // Process all by default await processAlgorandSpecs(); } } catch (error) { diff --git a/api/scripts/data/README.md b/api/scripts/data/README.md new file mode 100644 index 000000000..2168fe244 --- /dev/null +++ b/api/scripts/data/README.md @@ -0,0 +1,33 @@ +# Canonical Data Sources + +## Transaction Types + +The canonical list of Algorand transaction types is maintained in `transaction_types.json`. + +Path: `scripts/data/transaction_types.json` + +### Adding New Transaction Types + +1. Update `transaction_types.json` with the new type definition (name, description, enum_variant). +2. Update the `version` or add a note in `notes` as appropriate and refresh `last_updated`. +3. Run conversion to inject/validate: `cd api && bun run convert` (or `cargo api convert-openapi`). +4. Regenerate affected clients (e.g. `cargo api generate-kmd` if KMD uses TxType, or `cargo api generate-all`). +5. Run validation explicitly: `cd api && bun run validate-tx-types`. +6. Add/update tests if needed and commit changes. + +### Validation + +Transaction types are validated automatically: + +- During OpenAPI conversion via `bun run convert` (which chains validation) +- In CI via GitHub Actions workflow (`api_openapi_sync.yml`) +- Manually using `bun run validate-tx-types` inside the `api` directory + +### Purpose + +This canonical source prevents drift among algod, indexer, and KMD specifications and ensures generated clients share a single authoritative definition for transaction types. + +### Notes + +- KMD spec injection: If the upstream spec omits TxType enum values they are injected from this canonical list. +- Validation Heuristics: Indexer and Algod specifications are scanned for enums referencing transaction types; warnings become errors only for canonical mismatches where an explicit TxType-like enum is discovered. diff --git a/api/scripts/data/transaction_types.json b/api/scripts/data/transaction_types.json new file mode 100644 index 000000000..e03fd03b3 --- /dev/null +++ b/api/scripts/data/transaction_types.json @@ -0,0 +1,47 @@ +{ + "transaction_types": { + "pay": { + "name": "pay", + "description": "Payment transaction", + "enum_variant": "Pay" + }, + "keyreg": { + "name": "keyreg", + "description": "Key registration transaction", + "enum_variant": "Keyreg" + }, + "acfg": { + "name": "acfg", + "description": "Asset configuration transaction", + "enum_variant": "Acfg" + }, + "axfer": { + "name": "axfer", + "description": "Asset transfer transaction", + "enum_variant": "Axfer" + }, + "afrz": { + "name": "afrz", + "description": "Asset freeze transaction", + "enum_variant": "Afrz" + }, + "appl": { + "name": "appl", + "description": "Application call transaction", + "enum_variant": "Appl" + }, + "stpf": { + "name": "stpf", + "description": "State proof transaction", + "enum_variant": "Stpf" + }, + "hb": { + "name": "hb", + "description": "Heartbeat transaction", + "enum_variant": "Hb" + } + }, + "version": "1.0.0", + "last_updated": "2025-09-04T00:00:00.000Z", + "notes": "Canonical list of Algorand transaction types. Used for OpenAPI spec generation and validation." +} diff --git a/api/scripts/validate-transaction-types.ts b/api/scripts/validate-transaction-types.ts new file mode 100644 index 000000000..a072b9733 --- /dev/null +++ b/api/scripts/validate-transaction-types.ts @@ -0,0 +1,135 @@ +#!/usr/bin/env bun +import fs from "fs"; +import path from "path"; + +interface CanonicalData { + transaction_types: Record; +} + +function findRepoRoot(): string { + // Look upwards for scripts/data/transaction_types.json + let current = process.cwd(); + const targetRel = path.join("scripts", "data", "transaction_types.json"); + while (true) { + if (fs.existsSync(path.join(current, targetRel))) return current; + const parent = path.dirname(current); + if (parent === current) break; + current = parent; + } + return process.cwd(); +} +const root = findRepoRoot(); +function loadJSON(rel: string) { + return JSON.parse(fs.readFileSync(path.join(root, rel), "utf-8")); +} + +const canonical: CanonicalData = loadJSON("scripts/data/transaction_types.json"); +const canonicalTypes = Object.keys(canonical.transaction_types).sort(); + +function compareArrays(a: string[], b: string[]) { + const as = [...a].sort(); + const bs = [...b].sort(); + if (as.length !== bs.length) return false; + return as.every((v, i) => v === bs[i]); +} + +function validateKmdSpec(): string[] { + const errors: string[] = []; + const spec = loadJSON("api/specs/kmd.oas3.json"); + const txType = spec.components?.schemas?.TxType; + if (!txType) { + errors.push("KMD spec missing components.schemas.TxType"); + return errors; + } + if (!Array.isArray(txType.enum)) { + errors.push("KMD spec TxType has no enum array"); + return errors; + } + if (!compareArrays(txType.enum, canonicalTypes)) { + errors.push(`KMD spec TxType enum mismatch. Spec=[${txType.enum.join(", ")}] Canonical=[${canonicalTypes.join(", ")}]`); + } + return errors; +} + +function validateIndexerSpec(): string[] { + const errors: string[] = []; + const spec = loadJSON("api/specs/indexer.oas3.json"); + // Find parameters that are explicit tx-type enumerations (all values subset of canonical) + const candidateEnums: Set = new Set(); + const collect = (p: any) => { + if (p && typeof p === "object" && p.name && /tx[-_]type/i.test(p.name) && p.schema && Array.isArray(p.schema.enum)) { + const values: string[] = p.schema.enum.filter((v: any) => typeof v === "string"); + if (values.length > 0 && values.every((v) => canonicalTypes.includes(v))) { + values.forEach((v) => candidateEnums.add(v)); + } else if (values.some((v) => canonicalTypes.includes(v))) { + errors.push(`Indexer parameter ${p.name} mixes canonical and non-canonical values: ${values.join(", ")}`); + } + } + }; + if (spec.components?.parameters) { + Object.values(spec.components.parameters).forEach(collect); + } + if (spec.paths) { + for (const pathObj of Object.values(spec.paths)) { + if (!pathObj) continue; + for (const op of Object.values(pathObj)) { + if (!op || typeof op !== "object") continue; + if (Array.isArray(op.parameters)) op.parameters.forEach(collect); + } + } + } + if (candidateEnums.size > 0) { + const missing = canonicalTypes.filter((v) => !candidateEnums.has(v)); + if (missing.length > 0) { + errors.push(`Indexer tx-type parameter missing canonical values: ${missing.join(", ")}`); + } + } else { + // Not an error: indexer may not expose tx-type param as enum; only warn + // (We do not push to errors to avoid failing validation.) + } + return errors; +} + +function validateAlgodSpec(): string[] { + const errors: string[] = []; + const spec = loadJSON("api/specs/algod.oas3.json"); + // Algod may not define TxType directly; scan schemas for likely tx type enums + if (spec.components?.schemas) { + for (const [name, schema] of Object.entries(spec.components.schemas)) { + if (schema && Array.isArray(schema.enum) && schema.type === "string" && schema.enum.every((v: any) => typeof v === "string")) { + const allInCanonical = schema.enum.every((v: string) => canonicalTypes.includes(v)); + const share = schema.enum.filter((v: string) => canonicalTypes.includes(v)); + if (share.length >= canonicalTypes.length / 2) { + // heuristic candidate + if (!compareArrays(schema.enum, canonicalTypes)) { + errors.push( + `Algod schema ${name} has near-transaction enum mismatch. Spec=[${schema.enum.join(", ")}] Canonical=[${canonicalTypes.join(", ")}]`, + ); + } + } + if (allInCanonical && !compareArrays(schema.enum, canonicalTypes)) { + errors.push( + `Algod schema ${name} missing some canonical transaction types: Spec=[${schema.enum.join(", ")}] Canonical=[${canonicalTypes.join(", ")}]`, + ); + } + } + } + } + return errors; +} + +function main() { + const errors: string[] = []; + errors.push(...validateKmdSpec()); + errors.push(...validateIndexerSpec()); + errors.push(...validateAlgodSpec()); + + if (errors.length > 0) { + console.error("Transaction type validation failed:"); + errors.forEach((err) => console.error(` - ${err}`)); + process.exit(1); + } + console.log("✅ All transaction types validated successfully"); +} + +main(); diff --git a/api/specs/kmd.oas2.json b/api/specs/kmd.oas2.json new file mode 100644 index 000000000..b5894f38f --- /dev/null +++ b/api/specs/kmd.oas2.json @@ -0,0 +1,1705 @@ +{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "http" + ], + "swagger": "2.0", + "info": { + "description": "API for KMD (Key Management Daemon)", + "title": "for KMD HTTP API", + "contact": { + "email": "contact@algorand.com" + }, + "version": "0.0.1" + }, + "host": "localhost", + "basePath": "/", + "paths": { + "/swagger.json": { + "get": { + "description": "Returns the entire swagger spec in json.", + "produces": [ + "application/json" + ], + "schemes": [ + "http" + ], + "summary": "Gets the current swagger spec.", + "operationId": "SwaggerHandler", + "responses": { + "200": { + "description": "The current swagger spec", + "schema": { + "type": "string" + } + }, + "default": { + "description": "Unknown Error" + } + } + } + }, + "/v1/key": { + "post": { + "description": "Generates the next key in the deterministic key sequence (as determined by the master derivation key) and adds it to the wallet, returning the public key.\n", + "produces": [ + "application/json" + ], + "summary": "Generate a key", + "operationId": "GenerateKey", + "parameters": [ + { + "name": "Generate Key Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/GenerateKeyRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/GenerateKeyResponse" + } + } + }, + "delete": { + "description": "Deletes the key with the passed public key from the wallet.", + "produces": [ + "application/json" + ], + "summary": "Delete a key", + "operationId": "DeleteKey", + "parameters": [ + { + "name": "Delete Key Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/DeleteKeyRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/DeleteKeyResponse" + } + } + } + }, + "/v1/key/export": { + "post": { + "description": "Export the secret key associated with the passed public key.", + "produces": [ + "application/json" + ], + "summary": "Export a key", + "operationId": "ExportKey", + "parameters": [ + { + "name": "Export Key Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ExportKeyRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ExportKeyResponse" + } + } + } + }, + "/v1/key/import": { + "post": { + "description": "Import an externally generated key into the wallet. Note that if you wish to back up the imported key, you must do so by backing up the entire wallet database, because imported keys were not derived from the wallet's master derivation key.\n", + "produces": [ + "application/json" + ], + "summary": "Import a key", + "operationId": "ImportKey", + "parameters": [ + { + "name": "Import Key Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ImportKeyRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ImportKeyResponse" + } + } + } + }, + "/v1/key/list": { + "post": { + "description": "Lists all of the public keys in this wallet. All of them have a stored private key.", + "produces": [ + "application/json" + ], + "summary": "List keys in wallet", + "operationId": "ListKeysInWallet", + "parameters": [ + { + "name": "List Keys Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ListKeysRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ListKeysResponse" + } + } + } + }, + "/v1/master-key/export": { + "post": { + "description": "Export the master derivation key from the wallet. This key is a master \"backup\" key for the underlying wallet. With it, you can regenerate all of the wallets that have been generated with this wallet's `POST /v1/key` endpoint. This key will not allow you to recover keys imported from other wallets, however.\n", + "produces": [ + "application/json" + ], + "summary": "Export the master derivation key from a wallet", + "operationId": "ExportMasterKey", + "parameters": [ + { + "name": "Export Master Key Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ExportMasterKeyRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ExportMasterKeyResponse" + } + } + } + }, + "/v1/multisig": { + "delete": { + "description": "Deletes multisig preimage information for the passed address from the wallet.\n", + "produces": [ + "application/json" + ], + "summary": "Delete a multisig", + "operationId": "DeleteMultisig", + "parameters": [ + { + "name": "Delete Multisig Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/DeleteMultisigRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/DeleteMultisigResponse" + } + } + } + }, + "/v1/multisig/export": { + "post": { + "description": "Given a multisig address whose preimage this wallet stores, returns the information used to generate the address, including public keys, threshold, and multisig version.\n", + "produces": [ + "application/json" + ], + "summary": "Export multisig address metadata", + "operationId": "ExportMultisig", + "parameters": [ + { + "name": "Export Multisig Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ExportMultisigRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ExportMultisigResponse" + } + } + } + }, + "/v1/multisig/import": { + "post": { + "description": "Generates a multisig account from the passed public keys array and multisig metadata, and stores all of this in the wallet.\n", + "produces": [ + "application/json" + ], + "summary": "Import a multisig account", + "operationId": "ImportMultisig", + "parameters": [ + { + "name": "Import Multisig Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ImportMultisigRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ImportMultisigResponse" + } + } + } + }, + "/v1/multisig/list": { + "post": { + "description": "Lists all of the multisig accounts whose preimages this wallet stores", + "produces": [ + "application/json" + ], + "summary": "List multisig accounts", + "operationId": "ListMultisg", + "parameters": [ + { + "name": "List Multisig Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ListMultisigRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ListMultisigResponse" + } + } + } + }, + "/v1/multisig/sign": { + "post": { + "description": "Start a multisig signature, or add a signature to a partially completed multisig signature object.\n", + "produces": [ + "application/json" + ], + "summary": "Sign a multisig transaction", + "operationId": "SignMultisigTransaction", + "parameters": [ + { + "name": "Sign Multisig Transaction Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/SignMultisigRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/SignMultisigResponse" + } + } + } + }, + "/v1/multisig/signprogram": { + "post": { + "description": "Start a multisig signature, or add a signature to a partially completed multisig signature object.\n", + "produces": [ + "application/json" + ], + "summary": "Sign a program for a multisig account", + "operationId": "SignMultisigProgram", + "parameters": [ + { + "name": "Sign Multisig Program Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/SignProgramMultisigRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/SignProgramMultisigResponse" + } + } + } + }, + "/v1/program/sign": { + "post": { + "description": "Signs the passed program with a key from the wallet, determined by the account named in the request.\n", + "produces": [ + "application/json" + ], + "summary": "Sign program", + "operationId": "SignProgram", + "parameters": [ + { + "name": "Sign Program Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/SignProgramRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/SignProgramResponse" + } + } + } + }, + "/v1/transaction/sign": { + "post": { + "description": "Signs the passed transaction with a key from the wallet, determined by the sender encoded in the transaction.\n", + "produces": [ + "application/json" + ], + "summary": "Sign a transaction", + "operationId": "SignTransaction", + "parameters": [ + { + "name": "Sign Transaction Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/SignTransactionRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/SignTransactionResponse" + } + } + } + }, + "/v1/wallet": { + "post": { + "description": "Create a new wallet (collection of keys) with the given parameters.", + "produces": [ + "application/json" + ], + "summary": "Create a wallet", + "operationId": "CreateWallet", + "parameters": [ + { + "name": "Create Wallet Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateWalletRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/CreateWalletResponse" + } + } + } + }, + "/v1/wallet/info": { + "post": { + "description": "Returns information about the wallet associated with the passed wallet handle token. Additionally returns expiration information about the token itself.\n", + "produces": [ + "application/json" + ], + "summary": "Get wallet info", + "operationId": "GetWalletInfo", + "parameters": [ + { + "name": "Get Wallet Info Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/WalletInfoRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/WalletInfoResponse" + } + } + } + }, + "/v1/wallet/init": { + "post": { + "description": "Unlock the wallet and return a wallet handle token that can be used for subsequent operations. These tokens expire periodically and must be renewed. You can `POST` the token to `/v1/wallet/info` to see how much time remains until expiration, and renew it with `/v1/wallet/renew`. When you're done, you can invalidate the token with `/v1/wallet/release`.\n", + "produces": [ + "application/json" + ], + "summary": "Initialize a wallet handle token", + "operationId": "InitWalletHandleToken", + "parameters": [ + { + "name": "Initialize Wallet Handle Token Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/InitWalletHandleTokenRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/InitWalletHandleTokenResponse" + } + } + } + }, + "/v1/wallet/release": { + "post": { + "description": "Invalidate the passed wallet handle token, making it invalid for use in subsequent requests.", + "produces": [ + "application/json" + ], + "summary": "Release a wallet handle token", + "operationId": "ReleaseWalletHandleToken", + "parameters": [ + { + "name": "Release Wallet Handle Token Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReleaseWalletHandleTokenRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ReleaseWalletHandleTokenResponse" + } + } + } + }, + "/v1/wallet/rename": { + "post": { + "description": "Rename the underlying wallet to something else", + "produces": [ + "application/json" + ], + "summary": "Rename a wallet", + "operationId": "RenameWallet", + "parameters": [ + { + "name": "Rename Wallet Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RenameWalletRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/RenameWalletResponse" + } + } + } + }, + "/v1/wallet/renew": { + "post": { + "description": "Renew a wallet handle token, increasing its expiration duration to its initial value", + "produces": [ + "application/json" + ], + "summary": "Renew a wallet handle token", + "operationId": "RenewWalletHandleToken", + "parameters": [ + { + "name": "Renew Wallet Handle Token Request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RenewWalletHandleTokenRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/RenewWalletHandleTokenResponse" + } + } + } + }, + "/v1/wallets": { + "get": { + "description": "Lists all of the wallets that kmd is aware of.", + "produces": [ + "application/json" + ], + "summary": "List wallets", + "operationId": "ListWallets", + "parameters": [ + { + "name": "List Wallet Request", + "in": "body", + "schema": { + "$ref": "#/definitions/ListWalletsRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/ListWalletsResponse" + } + } + } + }, + "/versions": { + "get": { + "produces": [ + "application/json" + ], + "summary": "Retrieves the current version", + "operationId": "GetVersion", + "parameters": [ + { + "name": "Versions Request", + "in": "body", + "schema": { + "$ref": "#/definitions/VersionsRequest" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/VersionsResponse" + } + } + } + } + }, + "definitions": { + "APIV1DELETEKeyResponse": { + "description": "APIV1DELETEKeyResponse is the response to `DELETE /v1/key`\nfriendly:DeleteKeyResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1DELETEMultisigResponse": { + "description": "APIV1DELETEMultisigResponse is the response to POST /v1/multisig/delete`\nfriendly:DeleteMultisigResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1GETWalletsResponse": { + "description": "APIV1GETWalletsResponse is the response to `GET /v1/wallets`\nfriendly:ListWalletsResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallets": { + "type": "array", + "items": { + "$ref": "#/definitions/APIV1Wallet" + }, + "x-go-name": "Wallets" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTKeyExportResponse": { + "description": "APIV1POSTKeyExportResponse is the response to `POST /v1/key/export`\nfriendly:ExportKeyResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "private_key": { + "$ref": "#/definitions/PrivateKey" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTKeyImportResponse": { + "description": "APIV1POSTKeyImportResponse is the response to `POST /v1/key/import`\nfriendly:ImportKeyResponse", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTKeyListResponse": { + "description": "APIV1POSTKeyListResponse is the response to `POST /v1/key/list`\nfriendly:ListKeysResponse", + "type": "object", + "properties": { + "addresses": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Addresses" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTKeyResponse": { + "description": "APIV1POSTKeyResponse is the response to `POST /v1/key`\nfriendly:GenerateKeyResponse", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMasterKeyExportResponse": { + "description": "APIV1POSTMasterKeyExportResponse is the response to `POST /v1/master-key/export`\nfriendly:ExportMasterKeyResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "master_derivation_key": { + "$ref": "#/definitions/MasterDerivationKey" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigExportResponse": { + "description": "APIV1POSTMultisigExportResponse is the response to `POST /v1/multisig/export`\nfriendly:ExportMultisigResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "multisig_version": { + "type": "integer", + "format": "uint8", + "x-go-name": "Version" + }, + "pks": { + "type": "array", + "items": { + "$ref": "#/definitions/PublicKey" + }, + "x-go-name": "PKs" + }, + "threshold": { + "type": "integer", + "format": "uint8", + "x-go-name": "Threshold" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigImportResponse": { + "description": "APIV1POSTMultisigImportResponse is the response to `POST /v1/multisig/import`\nfriendly:ImportMultisigResponse", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigListResponse": { + "description": "APIV1POSTMultisigListResponse is the response to `POST /v1/multisig/list`\nfriendly:ListMultisigResponse", + "type": "object", + "properties": { + "addresses": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Addresses" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigProgramSignResponse": { + "description": "APIV1POSTMultisigProgramSignResponse is the response to `POST /v1/multisig/signdata`\nfriendly:SignProgramMultisigResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "multisig": { + "type": "string", + "format": "byte", + "x-go-name": "Multisig" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigTransactionSignResponse": { + "description": "APIV1POSTMultisigTransactionSignResponse is the response to `POST /v1/multisig/sign`\nfriendly:SignMultisigResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "multisig": { + "type": "string", + "format": "byte", + "x-go-name": "Multisig" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTProgramSignResponse": { + "description": "APIV1POSTProgramSignResponse is the response to `POST /v1/data/sign`\nfriendly:SignProgramResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "sig": { + "type": "string", + "format": "byte", + "x-go-name": "Signature" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTTransactionSignResponse": { + "description": "APIV1POSTTransactionSignResponse is the response to `POST /v1/transaction/sign`\nfriendly:SignTransactionResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "signed_transaction": { + "type": "string", + "format": "byte", + "x-go-name": "SignedTransaction" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletInfoResponse": { + "description": "APIV1POSTWalletInfoResponse is the response to `POST /v1/wallet/info`\nfriendly:WalletInfoResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet_handle": { + "$ref": "#/definitions/APIV1WalletHandle" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletInitResponse": { + "description": "APIV1POSTWalletInitResponse is the response to `POST /v1/wallet/init`\nfriendly:InitWalletHandleTokenResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletReleaseResponse": { + "description": "APIV1POSTWalletReleaseResponse is the response to `POST /v1/wallet/release`\nfriendly:ReleaseWalletHandleTokenResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletRenameResponse": { + "description": "APIV1POSTWalletRenameResponse is the response to `POST /v1/wallet/rename`\nfriendly:RenameWalletResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet": { + "$ref": "#/definitions/APIV1Wallet" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletRenewResponse": { + "description": "APIV1POSTWalletRenewResponse is the response to `POST /v1/wallet/renew`\nfriendly:RenewWalletHandleTokenResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet_handle": { + "$ref": "#/definitions/APIV1WalletHandle" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletResponse": { + "description": "APIV1POSTWalletResponse is the response to `POST /v1/wallet`\nfriendly:CreateWalletResponse", + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet": { + "$ref": "#/definitions/APIV1Wallet" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1Wallet": { + "description": "APIV1Wallet is the API's representation of a wallet", + "type": "object", + "properties": { + "driver_name": { + "type": "string", + "x-go-name": "DriverName" + }, + "driver_version": { + "type": "integer", + "format": "uint32", + "x-go-name": "DriverVersion" + }, + "id": { + "type": "string", + "x-go-name": "ID" + }, + "mnemonic_ux": { + "type": "boolean", + "x-go-name": "SupportsMnemonicUX" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "supported_txs": { + "type": "array", + "items": { + "$ref": "#/definitions/TxType" + }, + "x-go-name": "SupportedTransactions" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1WalletHandle": { + "description": "APIV1WalletHandle includes the wallet the handle corresponds to\nand the number of number of seconds to expiration", + "type": "object", + "properties": { + "expires_seconds": { + "type": "integer", + "format": "int64", + "x-go-name": "ExpiresSeconds" + }, + "wallet": { + "$ref": "#/definitions/APIV1Wallet" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "CreateWalletRequest": { + "description": "APIV1POSTWalletRequest is the request for `POST /v1/wallet`", + "type": "object", + "properties": { + "master_derivation_key": { + "$ref": "#/definitions/MasterDerivationKey" + }, + "wallet_driver_name": { + "type": "string", + "x-go-name": "WalletDriverName" + }, + "wallet_name": { + "type": "string", + "x-go-name": "WalletName" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTWalletRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "DeleteKeyRequest": { + "description": "APIV1DELETEKeyRequest is the request for `DELETE /v1/key`", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1DELETEKeyRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "DeleteMultisigRequest": { + "description": "APIV1DELETEMultisigRequest is the request for `DELETE /v1/multisig`", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1DELETEMultisigRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "Digest": { + "type": "array", + "title": "Digest represents a 32-byte value holding the 256-bit Hash digest.", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "ExportKeyRequest": { + "description": "APIV1POSTKeyExportRequest is the request for `POST /v1/key/export`", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTKeyExportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ExportMasterKeyRequest": { + "description": "APIV1POSTMasterKeyExportRequest is the request for `POST /v1/master-key/export`", + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTMasterKeyExportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ExportMultisigRequest": { + "description": "APIV1POSTMultisigExportRequest is the request for `POST /v1/multisig/export`", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTMultisigExportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "GenerateKeyRequest": { + "description": "APIV1POSTKeyRequest is the request for `POST /v1/key`", + "type": "object", + "properties": { + "display_mnemonic": { + "type": "boolean", + "x-go-name": "DisplayMnemonic" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTKeyRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ImportKeyRequest": { + "description": "APIV1POSTKeyImportRequest is the request for `POST /v1/key/import`", + "type": "object", + "properties": { + "private_key": { + "$ref": "#/definitions/PrivateKey" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTKeyImportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ImportMultisigRequest": { + "description": "APIV1POSTMultisigImportRequest is the request for `POST /v1/multisig/import`", + "type": "object", + "properties": { + "multisig_version": { + "type": "integer", + "format": "uint8", + "x-go-name": "Version" + }, + "pks": { + "type": "array", + "items": { + "$ref": "#/definitions/PublicKey" + }, + "x-go-name": "PKs" + }, + "threshold": { + "type": "integer", + "format": "uint8", + "x-go-name": "Threshold" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTMultisigImportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "InitWalletHandleTokenRequest": { + "description": "APIV1POSTWalletInitRequest is the request for `POST /v1/wallet/init`", + "type": "object", + "properties": { + "wallet_id": { + "type": "string", + "x-go-name": "WalletID" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTWalletInitRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ListKeysRequest": { + "description": "APIV1POSTKeyListRequest is the request for `POST /v1/key/list`", + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTKeyListRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ListMultisigRequest": { + "description": "APIV1POSTMultisigListRequest is the request for `POST /v1/multisig/list`", + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTMultisigListRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ListWalletsRequest": { + "description": "APIV1GETWalletsRequest is the request for `GET /v1/wallets`", + "type": "object", + "x-go-name": "APIV1GETWalletsRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "MasterDerivationKey": { + "description": "MasterDerivationKey is used to derive ed25519 keys for use in wallets", + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "MultisigSig": { + "description": "MultisigSig is the structure that holds multiple Subsigs", + "type": "object", + "properties": { + "Subsigs": { + "type": "array", + "items": { + "$ref": "#/definitions/MultisigSubsig" + } + }, + "Threshold": { + "type": "integer", + "format": "uint8" + }, + "Version": { + "type": "integer", + "format": "uint8" + } + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "MultisigSubsig": { + "description": "MultisigSubsig is a struct that holds a pair of public key and signatures\nsignatures may be empty", + "type": "object", + "properties": { + "Key": { + "$ref": "#/definitions/PublicKey" + }, + "Sig": { + "$ref": "#/definitions/Signature" + } + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "PrivateKey": { + "description": "PrivateKey is an exported ed25519PrivateKey", + "$ref": "#/definitions/ed25519PrivateKey" + }, + "PublicKey": { + "description": "PublicKey is an exported ed25519PublicKey", + "$ref": "#/definitions/ed25519PublicKey" + }, + "ReleaseWalletHandleTokenRequest": { + "description": "APIV1POSTWalletReleaseRequest is the request for `POST /v1/wallet/release`", + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTWalletReleaseRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "RenameWalletRequest": { + "description": "APIV1POSTWalletRenameRequest is the request for `POST /v1/wallet/rename`", + "type": "object", + "properties": { + "wallet_id": { + "type": "string", + "x-go-name": "WalletID" + }, + "wallet_name": { + "type": "string", + "x-go-name": "NewWalletName" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTWalletRenameRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "RenewWalletHandleTokenRequest": { + "description": "APIV1POSTWalletRenewRequest is the request for `POST /v1/wallet/renew`", + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTWalletRenewRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "SignMultisigRequest": { + "description": "APIV1POSTMultisigTransactionSignRequest is the request for `POST /v1/multisig/sign`", + "type": "object", + "properties": { + "partial_multisig": { + "$ref": "#/definitions/MultisigSig" + }, + "public_key": { + "$ref": "#/definitions/PublicKey" + }, + "signer": { + "$ref": "#/definitions/Digest" + }, + "transaction": { + "type": "string", + "format": "byte", + "x-go-name": "Transaction" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTMultisigTransactionSignRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "SignProgramMultisigRequest": { + "description": "APIV1POSTMultisigProgramSignRequest is the request for `POST /v1/multisig/signprogram`", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "data": { + "type": "string", + "format": "byte", + "x-go-name": "Program" + }, + "partial_multisig": { + "$ref": "#/definitions/MultisigSig" + }, + "public_key": { + "$ref": "#/definitions/PublicKey" + }, + "use_legacy_msig": { + "type": "boolean", + "x-go-name": "UseLegacyMsig" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTMultisigProgramSignRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "SignProgramRequest": { + "description": "APIV1POSTProgramSignRequest is the request for `POST /v1/program/sign`", + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "data": { + "type": "string", + "format": "byte", + "x-go-name": "Program" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTProgramSignRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "SignTransactionRequest": { + "description": "APIV1POSTTransactionSignRequest is the request for `POST /v1/transaction/sign`", + "type": "object", + "properties": { + "public_key": { + "$ref": "#/definitions/PublicKey" + }, + "transaction": { + "description": "Base64 encoding of msgpack encoding of a `Transaction` object\nNote: SDK and goal usually generate `SignedTxn` objects\nin that case, the field `txn` / `Transaction` of the\ngenerated `SignedTxn` object needs to be used", + "type": "string", + "format": "byte", + "x-go-name": "Transaction" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "x-go-name": "APIV1POSTTransactionSignRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "Signature": { + "description": "A Signature is a cryptographic signature. It proves that a message was\nproduced by a holder of a cryptographic secret.", + "$ref": "#/definitions/ed25519Signature" + }, + "TxType": { + "description": "TxType is the type of the transaction written to the ledger", + "type": "string", + "x-go-package": "github.com/algorand/go-algorand/protocol" + }, + "VersionsRequest": { + "description": "VersionsRequest is the request for `GET /versions`", + "type": "object", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "VersionsResponse": { + "description": "VersionsResponse is the response to `GET /versions`\nfriendly:VersionsResponse", + "type": "object", + "properties": { + "versions": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Versions" + } + }, + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "WalletInfoRequest": { + "description": "APIV1POSTWalletInfoRequest is the request for `POST /v1/wallet/info`", + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "x-go-name": "APIV1POSTWalletInfoRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ed25519PrivateKey": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "ed25519PublicKey": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "ed25519Signature": { + "type": "array", + "title": "Classical signatures */", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + } + }, + "responses": { + "CreateWalletResponse": { + "description": "Response to `POST /v1/wallet`", + "schema": { + "$ref": "#/definitions/APIV1POSTWalletResponse" + } + }, + "DeleteKeyResponse": { + "description": "Response to `DELETE /v1/key`", + "schema": { + "$ref": "#/definitions/APIV1DELETEKeyResponse" + } + }, + "DeleteMultisigResponse": { + "description": "Response to POST /v1/multisig/delete", + "schema": { + "$ref": "#/definitions/APIV1DELETEMultisigResponse" + } + }, + "ExportKeyResponse": { + "description": "Response to `POST /v1/key/export`", + "schema": { + "$ref": "#/definitions/APIV1POSTKeyExportResponse" + } + }, + "ExportMasterKeyResponse": { + "description": "Response to `POST /v1/master-key/export`", + "schema": { + "$ref": "#/definitions/APIV1POSTMasterKeyExportResponse" + } + }, + "ExportMultisigResponse": { + "description": "Response to `POST /v1/multisig/export`", + "schema": { + "$ref": "#/definitions/APIV1POSTMultisigExportResponse" + } + }, + "GenerateKeyResponse": { + "description": "Response to `POST /v1/key`", + "schema": { + "$ref": "#/definitions/APIV1POSTKeyResponse" + } + }, + "ImportKeyResponse": { + "description": "Response to `POST /v1/key/import`", + "schema": { + "$ref": "#/definitions/APIV1POSTKeyImportResponse" + } + }, + "ImportMultisigResponse": { + "description": "Response to `POST /v1/multisig/import`", + "schema": { + "$ref": "#/definitions/APIV1POSTMultisigImportResponse" + } + }, + "InitWalletHandleTokenResponse": { + "description": "Response to `POST /v1/wallet/init`", + "schema": { + "$ref": "#/definitions/APIV1POSTWalletInitResponse" + } + }, + "ListKeysResponse": { + "description": "Response to `POST /v1/key/list`", + "schema": { + "$ref": "#/definitions/APIV1POSTKeyListResponse" + } + }, + "ListMultisigResponse": { + "description": "Response to `POST /v1/multisig/list`", + "schema": { + "$ref": "#/definitions/APIV1POSTMultisigListResponse" + } + }, + "ListWalletsResponse": { + "description": "Response to `GET /v1/wallets`", + "schema": { + "$ref": "#/definitions/APIV1GETWalletsResponse" + } + }, + "ReleaseWalletHandleTokenResponse": { + "description": "Response to `POST /v1/wallet/release`", + "schema": { + "$ref": "#/definitions/APIV1POSTWalletReleaseResponse" + } + }, + "RenameWalletResponse": { + "description": "Response to `POST /v1/wallet/rename`", + "schema": { + "$ref": "#/definitions/APIV1POSTWalletRenameResponse" + } + }, + "RenewWalletHandleTokenResponse": { + "description": "Response `POST /v1/wallet/renew`", + "schema": { + "$ref": "#/definitions/APIV1POSTWalletRenewResponse" + } + }, + "SignMultisigResponse": { + "description": "Response to `POST /v1/multisig/sign`", + "schema": { + "$ref": "#/definitions/APIV1POSTMultisigTransactionSignResponse" + } + }, + "SignProgramMultisigResponse": { + "description": "Response to `POST /v1/multisig/signdata`", + "schema": { + "$ref": "#/definitions/APIV1POSTMultisigProgramSignResponse" + } + }, + "SignProgramResponse": { + "description": "Response to `POST /v1/data/sign`", + "schema": { + "$ref": "#/definitions/APIV1POSTProgramSignResponse" + } + }, + "SignTransactionResponse": { + "description": "Response to `POST /v1/transaction/sign`", + "schema": { + "$ref": "#/definitions/APIV1POSTTransactionSignResponse" + } + }, + "VersionsResponse": { + "description": "Response to `GET /versions`", + "schema": { + "$ref": "#/definitions/VersionsResponse" + } + }, + "WalletInfoResponse": { + "description": "Response to `POST /v1/wallet/info`", + "schema": { + "$ref": "#/definitions/APIV1POSTWalletInfoResponse" + } + } + }, + "securityDefinitions": { + "api_key": { + "description": "Generated header parameter. This value can be found in `/kmd/data/dir/kmd.token`. Example value: '330b2e4fc9b20f4f89812cf87f1dabeb716d23e3f11aec97a61ff5f750563b78'", + "type": "apiKey", + "name": "X-KMD-API-Token", + "in": "header", + "x-example": "330b2e4fc9b20f4f89812cf87f1dabeb716d23e3f11aec97a61ff5f750563b78" + } + }, + "security": [ + { + "api_key": [] + } + ] +} \ No newline at end of file diff --git a/api/specs/kmd.oas3.json b/api/specs/kmd.oas3.json new file mode 100644 index 000000000..c56a49706 --- /dev/null +++ b/api/specs/kmd.oas3.json @@ -0,0 +1,1892 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "for KMD HTTP API", + "description": "API for KMD (Key Management Daemon)", + "contact": { + "email": "contact@algorand.com" + }, + "version": "0.0.1" + }, + "servers": [ + { + "url": "http://localhost/" + } + ], + "security": [ + { + "api_key": [] + } + ], + "paths": { + "/swagger.json": { + "get": { + "summary": "Gets the current swagger spec.", + "description": "Returns the entire swagger spec in json.", + "operationId": "SwaggerHandler", + "responses": { + "200": { + "description": "The current swagger spec", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "default": { + "description": "Unknown Error", + "content": {} + } + } + } + }, + "/v1/key": { + "post": { + "summary": "Generate a key", + "description": "Generates the next key in the deterministic key sequence (as determined by the master derivation key) and adds it to the wallet, returning the public key.\n", + "operationId": "GenerateKey", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GenerateKeyRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/key`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTKeyResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Generate Key Request" + }, + "delete": { + "summary": "Delete a key", + "description": "Deletes the key with the passed public key from the wallet.", + "operationId": "DeleteKey", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteKeyRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `DELETE /v1/key`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1DELETEKeyResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Delete Key Request" + } + }, + "/v1/key/export": { + "post": { + "summary": "Export a key", + "description": "Export the secret key associated with the passed public key.", + "operationId": "ExportKey", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExportKeyRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/key/export`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTKeyExportResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Export Key Request" + } + }, + "/v1/key/import": { + "post": { + "summary": "Import a key", + "description": "Import an externally generated key into the wallet. Note that if you wish to back up the imported key, you must do so by backing up the entire wallet database, because imported keys were not derived from the wallet's master derivation key.\n", + "operationId": "ImportKey", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ImportKeyRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/key/import`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTKeyImportResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Import Key Request" + } + }, + "/v1/key/list": { + "post": { + "summary": "List keys in wallet", + "description": "Lists all of the public keys in this wallet. All of them have a stored private key.", + "operationId": "ListKeysInWallet", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListKeysRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/key/list`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTKeyListResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "List Keys Request" + } + }, + "/v1/master-key/export": { + "post": { + "summary": "Export the master derivation key from a wallet", + "description": "Export the master derivation key from the wallet. This key is a master \"backup\" key for the underlying wallet. With it, you can regenerate all of the wallets that have been generated with this wallet's `POST /v1/key` endpoint. This key will not allow you to recover keys imported from other wallets, however.\n", + "operationId": "ExportMasterKey", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExportMasterKeyRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/master-key/export`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMasterKeyExportResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Export Master Key Request" + } + }, + "/v1/multisig": { + "delete": { + "summary": "Delete a multisig", + "description": "Deletes multisig preimage information for the passed address from the wallet.\n", + "operationId": "DeleteMultisig", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteMultisigRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to POST /v1/multisig/delete", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1DELETEMultisigResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Delete Multisig Request" + } + }, + "/v1/multisig/export": { + "post": { + "summary": "Export multisig address metadata", + "description": "Given a multisig address whose preimage this wallet stores, returns the information used to generate the address, including public keys, threshold, and multisig version.\n", + "operationId": "ExportMultisig", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExportMultisigRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/multisig/export`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigExportResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Export Multisig Request" + } + }, + "/v1/multisig/import": { + "post": { + "summary": "Import a multisig account", + "description": "Generates a multisig account from the passed public keys array and multisig metadata, and stores all of this in the wallet.\n", + "operationId": "ImportMultisig", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ImportMultisigRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/multisig/import`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigImportResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Import Multisig Request" + } + }, + "/v1/multisig/list": { + "post": { + "summary": "List multisig accounts", + "description": "Lists all of the multisig accounts whose preimages this wallet stores", + "operationId": "ListMultisig", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListMultisigRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/multisig/list`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigListResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "List Multisig Request" + } + }, + "/v1/multisig/sign": { + "post": { + "summary": "Sign a multisig transaction", + "description": "Start a multisig signature, or add a signature to a partially completed multisig signature object.\n", + "operationId": "SignMultisigTransaction", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SignMultisigRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/multisig/sign`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigTransactionSignResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Sign Multisig Transaction Request" + } + }, + "/v1/multisig/signprogram": { + "post": { + "summary": "Sign a program for a multisig account", + "description": "Start a multisig signature, or add a signature to a partially completed multisig signature object.\n", + "operationId": "SignMultisigProgram", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SignProgramMultisigRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/multisig/signdata`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigProgramSignResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Sign Multisig Program Request" + } + }, + "/v1/program/sign": { + "post": { + "summary": "Sign program", + "description": "Signs the passed program with a key from the wallet, determined by the account named in the request.\n", + "operationId": "SignProgram", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SignProgramRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/data/sign`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTProgramSignResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Sign Program Request" + } + }, + "/v1/transaction/sign": { + "post": { + "summary": "Sign a transaction", + "description": "Signs the passed transaction with a key from the wallet, determined by the sender encoded in the transaction.\n", + "operationId": "SignTransaction", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SignTransactionRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/transaction/sign`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTTransactionSignResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Sign Transaction Request" + } + }, + "/v1/wallet": { + "post": { + "summary": "Create a wallet", + "description": "Create a new wallet (collection of keys) with the given parameters.", + "operationId": "CreateWallet", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateWalletRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/wallet`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Create Wallet Request" + } + }, + "/v1/wallet/info": { + "post": { + "summary": "Get wallet info", + "description": "Returns information about the wallet associated with the passed wallet handle token. Additionally returns expiration information about the token itself.\n", + "operationId": "GetWalletInfo", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WalletInfoRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/wallet/info`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletInfoResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Get Wallet Info Request" + } + }, + "/v1/wallet/init": { + "post": { + "summary": "Initialize a wallet handle token", + "description": "Unlock the wallet and return a wallet handle token that can be used for subsequent operations. These tokens expire periodically and must be renewed. You can `POST` the token to `/v1/wallet/info` to see how much time remains until expiration, and renew it with `/v1/wallet/renew`. When you're done, you can invalidate the token with `/v1/wallet/release`.\n", + "operationId": "InitWalletHandleToken", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InitWalletHandleTokenRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/wallet/init`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletInitResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Initialize Wallet Handle Token Request" + } + }, + "/v1/wallet/release": { + "post": { + "summary": "Release a wallet handle token", + "description": "Invalidate the passed wallet handle token, making it invalid for use in subsequent requests.", + "operationId": "ReleaseWalletHandleToken", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReleaseWalletHandleTokenRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/wallet/release`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletReleaseResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Release Wallet Handle Token Request" + } + }, + "/v1/wallet/rename": { + "post": { + "summary": "Rename a wallet", + "description": "Rename the underlying wallet to something else", + "operationId": "RenameWallet", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RenameWalletRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response to `POST /v1/wallet/rename`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletRenameResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Rename Wallet Request" + } + }, + "/v1/wallet/renew": { + "post": { + "summary": "Renew a wallet handle token", + "description": "Renew a wallet handle token, increasing its expiration duration to its initial value", + "operationId": "RenewWalletHandleToken", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RenewWalletHandleTokenRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Response `POST /v1/wallet/renew`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletRenewResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Renew Wallet Handle Token Request" + } + }, + "/v1/wallets": { + "get": { + "summary": "List wallets", + "description": "Lists all of the wallets that kmd is aware of.", + "operationId": "ListWallets", + "responses": { + "200": { + "description": "Response to `GET /v1/wallets`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1GETWalletsResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "List Wallet Request" + } + }, + "/versions": { + "get": { + "summary": "Retrieves the current version", + "operationId": "GetVersion", + "responses": { + "200": { + "description": "Response to `GET /versions`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VersionsResponse" + } + } + } + } + }, + "x-codegen-request-body-name": "Versions Request" + } + } + }, + "components": { + "schemas": { + "APIV1DELETEKeyResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1DELETEKeyResponse is the response to `DELETE /v1/key`\nfriendly:DeleteKeyResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1DELETEMultisigResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1DELETEMultisigResponse is the response to POST /v1/multisig/delete`\nfriendly:DeleteMultisigResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1GETWalletsResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/APIV1Wallet" + }, + "x-go-name": "Wallets" + } + }, + "description": "APIV1GETWalletsResponse is the response to `GET /v1/wallets`\nfriendly:ListWalletsResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTKeyExportResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "private_key": { + "$ref": "#/components/schemas/PrivateKey" + } + }, + "description": "APIV1POSTKeyExportResponse is the response to `POST /v1/key/export`\nfriendly:ExportKeyResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTKeyImportResponse": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1POSTKeyImportResponse is the response to `POST /v1/key/import`\nfriendly:ImportKeyResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTKeyListResponse": { + "type": "object", + "properties": { + "addresses": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Addresses" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1POSTKeyListResponse is the response to `POST /v1/key/list`\nfriendly:ListKeysResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTKeyResponse": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1POSTKeyResponse is the response to `POST /v1/key`\nfriendly:GenerateKeyResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMasterKeyExportResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "master_derivation_key": { + "$ref": "#/components/schemas/MasterDerivationKey" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1POSTMasterKeyExportResponse is the response to `POST /v1/master-key/export`\nfriendly:ExportMasterKeyResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigExportResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "multisig_version": { + "type": "integer", + "format": "uint8", + "x-go-name": "Version" + }, + "pks": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PublicKey" + }, + "x-go-name": "PKs" + }, + "threshold": { + "type": "integer", + "format": "uint8", + "x-go-name": "Threshold" + } + }, + "description": "APIV1POSTMultisigExportResponse is the response to `POST /v1/multisig/export`\nfriendly:ExportMultisigResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigImportResponse": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1POSTMultisigImportResponse is the response to `POST /v1/multisig/import`\nfriendly:ImportMultisigResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigListResponse": { + "type": "object", + "properties": { + "addresses": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Addresses" + }, + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1POSTMultisigListResponse is the response to `POST /v1/multisig/list`\nfriendly:ListMultisigResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigProgramSignResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "multisig": { + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", + "type": "string", + "format": "byte", + "x-go-name": "Multisig" + } + }, + "description": "APIV1POSTMultisigProgramSignResponse is the response to `POST /v1/multisig/signdata`\nfriendly:SignProgramMultisigResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTMultisigTransactionSignResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "multisig": { + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", + "type": "string", + "format": "byte", + "x-go-name": "Multisig" + } + }, + "description": "APIV1POSTMultisigTransactionSignResponse is the response to `POST /v1/multisig/sign`\nfriendly:SignMultisigResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTProgramSignResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "sig": { + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", + "type": "string", + "format": "byte", + "x-go-name": "Signature" + } + }, + "description": "APIV1POSTProgramSignResponse is the response to `POST /v1/data/sign`\nfriendly:SignProgramResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTTransactionSignResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "signed_transaction": { + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", + "type": "string", + "format": "byte", + "x-go-name": "SignedTransaction" + } + }, + "description": "APIV1POSTTransactionSignResponse is the response to `POST /v1/transaction/sign`\nfriendly:SignTransactionResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletInfoResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet_handle": { + "$ref": "#/components/schemas/APIV1WalletHandle" + } + }, + "description": "APIV1POSTWalletInfoResponse is the response to `POST /v1/wallet/info`\nfriendly:WalletInfoResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletInitResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTWalletInitResponse is the response to `POST /v1/wallet/init`\nfriendly:InitWalletHandleTokenResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletReleaseResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + } + }, + "description": "APIV1POSTWalletReleaseResponse is the response to `POST /v1/wallet/release`\nfriendly:ReleaseWalletHandleTokenResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletRenameResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet": { + "$ref": "#/components/schemas/APIV1Wallet" + } + }, + "description": "APIV1POSTWalletRenameResponse is the response to `POST /v1/wallet/rename`\nfriendly:RenameWalletResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletRenewResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet_handle": { + "$ref": "#/components/schemas/APIV1WalletHandle" + } + }, + "description": "APIV1POSTWalletRenewResponse is the response to `POST /v1/wallet/renew`\nfriendly:RenewWalletHandleTokenResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1POSTWalletResponse": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "x-go-name": "Error" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "wallet": { + "$ref": "#/components/schemas/APIV1Wallet" + } + }, + "description": "APIV1POSTWalletResponse is the response to `POST /v1/wallet`\nfriendly:CreateWalletResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1Wallet": { + "type": "object", + "properties": { + "driver_name": { + "type": "string", + "x-go-name": "DriverName" + }, + "driver_version": { + "type": "integer", + "format": "uint32", + "x-go-name": "DriverVersion" + }, + "id": { + "type": "string", + "x-go-name": "ID" + }, + "mnemonic_ux": { + "type": "boolean", + "x-go-name": "SupportsMnemonicUX" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "supported_txs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TxType" + }, + "x-go-name": "SupportedTransactions" + } + }, + "description": "APIV1Wallet is the API's representation of a wallet", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "APIV1WalletHandle": { + "type": "object", + "properties": { + "expires_seconds": { + "type": "integer", + "format": "int64", + "x-go-name": "ExpiresSeconds" + }, + "wallet": { + "$ref": "#/components/schemas/APIV1Wallet" + } + }, + "description": "APIV1WalletHandle includes the wallet the handle corresponds to\nand the number of number of seconds to expiration", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "CreateWalletRequest": { + "type": "object", + "properties": { + "master_derivation_key": { + "$ref": "#/components/schemas/MasterDerivationKey" + }, + "wallet_driver_name": { + "type": "string", + "x-go-name": "WalletDriverName" + }, + "wallet_name": { + "type": "string", + "x-go-name": "WalletName" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTWalletRequest is the request for `POST /v1/wallet`", + "x-go-name": "APIV1POSTWalletRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "DeleteKeyRequest": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1DELETEKeyRequest is the request for `DELETE /v1/key`", + "x-go-name": "APIV1DELETEKeyRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "DeleteMultisigRequest": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1DELETEMultisigRequest is the request for `DELETE /v1/multisig`", + "x-go-name": "APIV1DELETEMultisigRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "Digest": { + "title": "Digest represents a 32-byte value holding the 256-bit Hash digest.", + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "ExportKeyRequest": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTKeyExportRequest is the request for `POST /v1/key/export`", + "x-go-name": "APIV1POSTKeyExportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ExportMasterKeyRequest": { + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTMasterKeyExportRequest is the request for `POST /v1/master-key/export`", + "x-go-name": "APIV1POSTMasterKeyExportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ExportMultisigRequest": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTMultisigExportRequest is the request for `POST /v1/multisig/export`", + "x-go-name": "APIV1POSTMultisigExportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "GenerateKeyRequest": { + "type": "object", + "properties": { + "display_mnemonic": { + "type": "boolean", + "x-go-name": "DisplayMnemonic" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTKeyRequest is the request for `POST /v1/key`", + "x-go-name": "APIV1POSTKeyRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ImportKeyRequest": { + "type": "object", + "properties": { + "private_key": { + "$ref": "#/components/schemas/PrivateKey" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTKeyImportRequest is the request for `POST /v1/key/import`", + "x-go-name": "APIV1POSTKeyImportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ImportMultisigRequest": { + "type": "object", + "properties": { + "multisig_version": { + "type": "integer", + "format": "uint8", + "x-go-name": "Version" + }, + "pks": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PublicKey" + }, + "x-go-name": "PKs" + }, + "threshold": { + "type": "integer", + "format": "uint8", + "x-go-name": "Threshold" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTMultisigImportRequest is the request for `POST /v1/multisig/import`", + "x-go-name": "APIV1POSTMultisigImportRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "InitWalletHandleTokenRequest": { + "type": "object", + "properties": { + "wallet_id": { + "type": "string", + "x-go-name": "WalletID" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTWalletInitRequest is the request for `POST /v1/wallet/init`", + "x-go-name": "APIV1POSTWalletInitRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ListKeysRequest": { + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTKeyListRequest is the request for `POST /v1/key/list`", + "x-go-name": "APIV1POSTKeyListRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ListMultisigRequest": { + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTMultisigListRequest is the request for `POST /v1/multisig/list`", + "x-go-name": "APIV1POSTMultisigListRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ListWalletsRequest": { + "type": "object", + "description": "APIV1GETWalletsRequest is the request for `GET /v1/wallets`", + "x-go-name": "APIV1GETWalletsRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "MasterDerivationKey": { + "type": "array", + "description": "MasterDerivationKey is used to derive ed25519 keys for use in wallets", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "MultisigSig": { + "type": "object", + "properties": { + "Subsigs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MultisigSubsig" + } + }, + "Threshold": { + "type": "integer", + "format": "uint8" + }, + "Version": { + "type": "integer", + "format": "uint8" + } + }, + "description": "MultisigSig is the structure that holds multiple Subsigs", + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "MultisigSubsig": { + "type": "object", + "properties": { + "Key": { + "$ref": "#/components/schemas/PublicKey" + }, + "Sig": { + "$ref": "#/components/schemas/Signature" + } + }, + "description": "MultisigSubsig is a struct that holds a pair of public key and signatures\nsignatures may be empty", + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "PrivateKey": { + "$ref": "#/components/schemas/ed25519PrivateKey" + }, + "PublicKey": { + "$ref": "#/components/schemas/ed25519PublicKey" + }, + "ReleaseWalletHandleTokenRequest": { + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTWalletReleaseRequest is the request for `POST /v1/wallet/release`", + "x-go-name": "APIV1POSTWalletReleaseRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "RenameWalletRequest": { + "type": "object", + "properties": { + "wallet_id": { + "type": "string", + "x-go-name": "WalletID" + }, + "wallet_name": { + "type": "string", + "x-go-name": "NewWalletName" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTWalletRenameRequest is the request for `POST /v1/wallet/rename`", + "x-go-name": "APIV1POSTWalletRenameRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "RenewWalletHandleTokenRequest": { + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTWalletRenewRequest is the request for `POST /v1/wallet/renew`", + "x-go-name": "APIV1POSTWalletRenewRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "SignMultisigRequest": { + "type": "object", + "properties": { + "partial_multisig": { + "$ref": "#/components/schemas/MultisigSig" + }, + "public_key": { + "$ref": "#/components/schemas/PublicKey" + }, + "signer": { + "$ref": "#/components/schemas/Digest" + }, + "transaction": { + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", + "type": "string", + "format": "byte", + "x-go-name": "Transaction" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTMultisigTransactionSignRequest is the request for `POST /v1/multisig/sign`", + "x-go-name": "APIV1POSTMultisigTransactionSignRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "SignProgramMultisigRequest": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "data": { + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", + "type": "string", + "format": "byte", + "x-go-name": "Program" + }, + "partial_multisig": { + "$ref": "#/components/schemas/MultisigSig" + }, + "public_key": { + "$ref": "#/components/schemas/PublicKey" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTMultisigProgramSignRequest is the request for `POST /v1/multisig/signprogram`", + "x-go-name": "APIV1POSTMultisigProgramSignRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "SignProgramRequest": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-go-name": "Address" + }, + "data": { + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", + "type": "string", + "format": "byte", + "x-go-name": "Program" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTProgramSignRequest is the request for `POST /v1/program/sign`", + "x-go-name": "APIV1POSTProgramSignRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "SignTransactionRequest": { + "type": "object", + "properties": { + "public_key": { + "$ref": "#/components/schemas/PublicKey" + }, + "transaction": { + "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", + "type": "string", + "description": "Base64 encoding of msgpack encoding of a `Transaction` object\nNote: SDK and goal usually generate `SignedTxn` objects\nin that case, the field `txn` / `Transaction` of the\ngenerated `SignedTxn` object needs to be used", + "format": "byte", + "x-go-name": "Transaction" + }, + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + }, + "wallet_password": { + "type": "string", + "x-go-name": "WalletPassword" + } + }, + "description": "APIV1POSTTransactionSignRequest is the request for `POST /v1/transaction/sign`", + "x-go-name": "APIV1POSTTransactionSignRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "Signature": { + "$ref": "#/components/schemas/ed25519Signature" + }, + "TxType": { + "type": "string", + "description": "TxType is the type of the transaction written to the ledger", + "x-go-package": "github.com/algorand/go-algorand/protocol", + "enum": [ + "pay", + "keyreg", + "acfg", + "axfer", + "afrz", + "appl", + "stpf", + "hb" + ], + "x-algokit-source": "injected-enum" + }, + "VersionsRequest": { + "type": "object", + "description": "VersionsRequest is the request for `GET /versions`", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "VersionsResponse": { + "type": "object", + "properties": { + "versions": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Versions" + } + }, + "description": "VersionsResponse is the response to `GET /versions`\nfriendly:VersionsResponse", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "WalletInfoRequest": { + "type": "object", + "properties": { + "wallet_handle_token": { + "type": "string", + "x-go-name": "WalletHandleToken" + } + }, + "description": "APIV1POSTWalletInfoRequest is the request for `POST /v1/wallet/info`", + "x-go-name": "APIV1POSTWalletInfoRequest", + "x-go-package": "github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi" + }, + "ed25519PrivateKey": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "ed25519PublicKey": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + }, + "ed25519Signature": { + "title": "Classical signatures */", + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + }, + "x-go-package": "github.com/algorand/go-algorand/crypto" + } + }, + "responses": { + "CreateWalletResponse": { + "description": "Response to `POST /v1/wallet`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletResponse" + } + } + } + }, + "DeleteKeyResponse": { + "description": "Response to `DELETE /v1/key`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1DELETEKeyResponse" + } + } + } + }, + "DeleteMultisigResponse": { + "description": "Response to POST /v1/multisig/delete", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1DELETEMultisigResponse" + } + } + } + }, + "ExportKeyResponse": { + "description": "Response to `POST /v1/key/export`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTKeyExportResponse" + } + } + } + }, + "ExportMasterKeyResponse": { + "description": "Response to `POST /v1/master-key/export`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMasterKeyExportResponse" + } + } + } + }, + "ExportMultisigResponse": { + "description": "Response to `POST /v1/multisig/export`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigExportResponse" + } + } + } + }, + "GenerateKeyResponse": { + "description": "Response to `POST /v1/key`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTKeyResponse" + } + } + } + }, + "ImportKeyResponse": { + "description": "Response to `POST /v1/key/import`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTKeyImportResponse" + } + } + } + }, + "ImportMultisigResponse": { + "description": "Response to `POST /v1/multisig/import`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigImportResponse" + } + } + } + }, + "InitWalletHandleTokenResponse": { + "description": "Response to `POST /v1/wallet/init`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletInitResponse" + } + } + } + }, + "ListKeysResponse": { + "description": "Response to `POST /v1/key/list`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTKeyListResponse" + } + } + } + }, + "ListMultisigResponse": { + "description": "Response to `POST /v1/multisig/list`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigListResponse" + } + } + } + }, + "ListWalletsResponse": { + "description": "Response to `GET /v1/wallets`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1GETWalletsResponse" + } + } + } + }, + "ReleaseWalletHandleTokenResponse": { + "description": "Response to `POST /v1/wallet/release`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletReleaseResponse" + } + } + } + }, + "RenameWalletResponse": { + "description": "Response to `POST /v1/wallet/rename`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletRenameResponse" + } + } + } + }, + "RenewWalletHandleTokenResponse": { + "description": "Response `POST /v1/wallet/renew`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletRenewResponse" + } + } + } + }, + "SignMultisigResponse": { + "description": "Response to `POST /v1/multisig/sign`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigTransactionSignResponse" + } + } + } + }, + "SignProgramMultisigResponse": { + "description": "Response to `POST /v1/multisig/signdata`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTMultisigProgramSignResponse" + } + } + } + }, + "SignProgramResponse": { + "description": "Response to `POST /v1/data/sign`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTProgramSignResponse" + } + } + } + }, + "SignTransactionResponse": { + "description": "Response to `POST /v1/transaction/sign`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTTransactionSignResponse" + } + } + } + }, + "VersionsResponse": { + "description": "Response to `GET /versions`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VersionsResponse" + } + } + } + }, + "WalletInfoResponse": { + "description": "Response to `POST /v1/wallet/info`", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIV1POSTWalletInfoResponse" + } + } + } + } + }, + "securitySchemes": { + "api_key": { + "type": "apiKey", + "description": "Generated header parameter. This value can be found in `/kmd/data/dir/kmd.token`. Example value: '330b2e4fc9b20f4f89812cf87f1dabeb716d23e3f11aec97a61ff5f750563b78'", + "name": "X-KMD-API-Token", + "in": "header" + } + } + }, + "x-original-swagger-version": "2.0" +} \ No newline at end of file diff --git a/crates/algod_client/src/apis/account_application_information.rs b/crates/algod_client/src/apis/account_application_information.rs index b8cb05e74..9b5e899d9 100644 --- a/crates/algod_client/src/apis/account_application_information.rs +++ b/crates/algod_client/src/apis/account_application_information.rs @@ -55,19 +55,8 @@ pub async fn account_application_information( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/account_asset_information.rs b/crates/algod_client/src/apis/account_asset_information.rs index 828470241..a88d48d19 100644 --- a/crates/algod_client/src/apis/account_asset_information.rs +++ b/crates/algod_client/src/apis/account_asset_information.rs @@ -55,19 +55,8 @@ pub async fn account_asset_information( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/account_assets_information.rs b/crates/algod_client/src/apis/account_assets_information.rs index 8649f3508..9c5d379c6 100644 --- a/crates/algod_client/src/apis/account_assets_information.rs +++ b/crates/algod_client/src/apis/account_assets_information.rs @@ -56,7 +56,6 @@ pub async fn account_assets_information( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/account_information.rs b/crates/algod_client/src/apis/account_information.rs index 8f1262559..f84772e1b 100644 --- a/crates/algod_client/src/apis/account_information.rs +++ b/crates/algod_client/src/apis/account_information.rs @@ -57,19 +57,8 @@ pub async fn account_information( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/experimental_check.rs b/crates/algod_client/src/apis/experimental_check.rs index 3e3065ae7..96931628e 100644 --- a/crates/algod_client/src/apis/experimental_check.rs +++ b/crates/algod_client/src/apis/experimental_check.rs @@ -35,7 +35,6 @@ pub async fn experimental_check(http_client: &dyn HttpClient) -> Result<(), Erro let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/generate_participation_keys.rs b/crates/algod_client/src/apis/generate_participation_keys.rs index 8bd1ed726..88338dee6 100644 --- a/crates/algod_client/src/apis/generate_participation_keys.rs +++ b/crates/algod_client/src/apis/generate_participation_keys.rs @@ -74,29 +74,7 @@ pub async fn generate_participation_keys( .await .map_err(|e| Error::Http { source: e })?; - let content_type = response - .headers - .get("content-type") - .map(|s| s.as_str()) - .unwrap_or("application/json"); - - match ContentType::from(content_type) { - ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { - message: e.to_string(), - }), - ContentType::MsgPack => Err(Error::Serde { - message: "MsgPack not supported".to_string(), - }), - ContentType::Text => { - let text = String::from_utf8(response.body).map_err(|e| Error::Serde { - message: e.to_string(), - })?; - Err(Error::Serde { - message: format!("Unexpected text response: {}", text), - }) - } - ContentType::Unsupported(ct) => Err(Error::Serde { - message: format!("Unsupported content type: {}", ct), - }), - } + String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }) } diff --git a/crates/algod_client/src/apis/get_application_box_by_name.rs b/crates/algod_client/src/apis/get_application_box_by_name.rs index 0e3cad199..bc0a08e60 100644 --- a/crates/algod_client/src/apis/get_application_box_by_name.rs +++ b/crates/algod_client/src/apis/get_application_box_by_name.rs @@ -50,7 +50,6 @@ pub async fn get_application_box_by_name( query_params.insert("name".to_string(), p_name.to_string()); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_application_boxes.rs b/crates/algod_client/src/apis/get_application_boxes.rs index 52640f462..b38aeb4e0 100644 --- a/crates/algod_client/src/apis/get_application_boxes.rs +++ b/crates/algod_client/src/apis/get_application_boxes.rs @@ -51,7 +51,6 @@ pub async fn get_application_boxes( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_application_by_id.rs b/crates/algod_client/src/apis/get_application_by_id.rs index 9697d846f..3cdfebac9 100644 --- a/crates/algod_client/src/apis/get_application_by_id.rs +++ b/crates/algod_client/src/apis/get_application_by_id.rs @@ -47,7 +47,6 @@ pub async fn get_application_by_id( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_asset_by_id.rs b/crates/algod_client/src/apis/get_asset_by_id.rs index bc55c1b49..d1387a1a4 100644 --- a/crates/algod_client/src/apis/get_asset_by_id.rs +++ b/crates/algod_client/src/apis/get_asset_by_id.rs @@ -41,7 +41,6 @@ pub async fn get_asset_by_id(http_client: &dyn HttpClient, asset_id: u64) -> Res let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_block.rs b/crates/algod_client/src/apis/get_block.rs index 3f5efe178..7addededd 100644 --- a/crates/algod_client/src/apis/get_block.rs +++ b/crates/algod_client/src/apis/get_block.rs @@ -55,19 +55,8 @@ pub async fn get_block( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_block_hash.rs b/crates/algod_client/src/apis/get_block_hash.rs index 89945d889..6c7b9bbff 100644 --- a/crates/algod_client/src/apis/get_block_hash.rs +++ b/crates/algod_client/src/apis/get_block_hash.rs @@ -44,7 +44,6 @@ pub async fn get_block_hash( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_block_logs.rs b/crates/algod_client/src/apis/get_block_logs.rs index f2b1d4e53..20fc9cdca 100644 --- a/crates/algod_client/src/apis/get_block_logs.rs +++ b/crates/algod_client/src/apis/get_block_logs.rs @@ -43,7 +43,6 @@ pub async fn get_block_logs( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_block_time_stamp_offset.rs b/crates/algod_client/src/apis/get_block_time_stamp_offset.rs index de956e7ec..effd22662 100644 --- a/crates/algod_client/src/apis/get_block_time_stamp_offset.rs +++ b/crates/algod_client/src/apis/get_block_time_stamp_offset.rs @@ -38,7 +38,6 @@ pub async fn get_block_time_stamp_offset( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_block_txids.rs b/crates/algod_client/src/apis/get_block_txids.rs index 768704f4a..d74a1c318 100644 --- a/crates/algod_client/src/apis/get_block_txids.rs +++ b/crates/algod_client/src/apis/get_block_txids.rs @@ -44,7 +44,6 @@ pub async fn get_block_txids( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_config.rs b/crates/algod_client/src/apis/get_config.rs index 88213c067..c0f0d5a75 100644 --- a/crates/algod_client/src/apis/get_config.rs +++ b/crates/algod_client/src/apis/get_config.rs @@ -34,7 +34,6 @@ pub async fn get_config(http_client: &dyn HttpClient) -> Result { let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; @@ -50,29 +49,7 @@ pub async fn get_config(http_client: &dyn HttpClient) -> Result { .await .map_err(|e| Error::Http { source: e })?; - let content_type = response - .headers - .get("content-type") - .map(|s| s.as_str()) - .unwrap_or("application/json"); - - match ContentType::from(content_type) { - ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { - message: e.to_string(), - }), - ContentType::MsgPack => Err(Error::Serde { - message: "MsgPack not supported".to_string(), - }), - ContentType::Text => { - let text = String::from_utf8(response.body).map_err(|e| Error::Serde { - message: e.to_string(), - })?; - Err(Error::Serde { - message: format!("Unexpected text response: {}", text), - }) - } - ContentType::Unsupported(ct) => Err(Error::Serde { - message: format!("Unsupported content type: {}", ct), - }), - } + String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }) } diff --git a/crates/algod_client/src/apis/get_debug_settings_prof.rs b/crates/algod_client/src/apis/get_debug_settings_prof.rs index 402232f5d..82e5ebe3f 100644 --- a/crates/algod_client/src/apis/get_debug_settings_prof.rs +++ b/crates/algod_client/src/apis/get_debug_settings_prof.rs @@ -36,7 +36,6 @@ pub async fn get_debug_settings_prof( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_genesis.rs b/crates/algod_client/src/apis/get_genesis.rs index 107e9612d..7decceee8 100644 --- a/crates/algod_client/src/apis/get_genesis.rs +++ b/crates/algod_client/src/apis/get_genesis.rs @@ -35,7 +35,6 @@ pub async fn get_genesis(http_client: &dyn HttpClient) -> Result let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_ledger_state_delta.rs b/crates/algod_client/src/apis/get_ledger_state_delta.rs index 1cdf332ab..490892e9e 100644 --- a/crates/algod_client/src/apis/get_ledger_state_delta.rs +++ b/crates/algod_client/src/apis/get_ledger_state_delta.rs @@ -51,19 +51,8 @@ pub async fn get_ledger_state_delta( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_ledger_state_delta_for_transaction_group.rs b/crates/algod_client/src/apis/get_ledger_state_delta_for_transaction_group.rs index d73795dfd..f61df407f 100644 --- a/crates/algod_client/src/apis/get_ledger_state_delta_for_transaction_group.rs +++ b/crates/algod_client/src/apis/get_ledger_state_delta_for_transaction_group.rs @@ -54,19 +54,8 @@ pub async fn get_ledger_state_delta_for_transaction_group( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_light_block_header_proof.rs b/crates/algod_client/src/apis/get_light_block_header_proof.rs index 058868f52..e16a8ebe0 100644 --- a/crates/algod_client/src/apis/get_light_block_header_proof.rs +++ b/crates/algod_client/src/apis/get_light_block_header_proof.rs @@ -45,7 +45,6 @@ pub async fn get_light_block_header_proof( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_participation_key_by_id.rs b/crates/algod_client/src/apis/get_participation_key_by_id.rs index a1c8f0780..1e630dbf7 100644 --- a/crates/algod_client/src/apis/get_participation_key_by_id.rs +++ b/crates/algod_client/src/apis/get_participation_key_by_id.rs @@ -47,7 +47,6 @@ pub async fn get_participation_key_by_id( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_participation_keys.rs b/crates/algod_client/src/apis/get_participation_keys.rs index f0b983d58..02c5ae2d4 100644 --- a/crates/algod_client/src/apis/get_participation_keys.rs +++ b/crates/algod_client/src/apis/get_participation_keys.rs @@ -41,7 +41,6 @@ pub async fn get_participation_keys( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_pending_transactions.rs b/crates/algod_client/src/apis/get_pending_transactions.rs index 5e6ccb9f8..0f238aebe 100644 --- a/crates/algod_client/src/apis/get_pending_transactions.rs +++ b/crates/algod_client/src/apis/get_pending_transactions.rs @@ -52,19 +52,8 @@ pub async fn get_pending_transactions( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_pending_transactions_by_address.rs b/crates/algod_client/src/apis/get_pending_transactions_by_address.rs index 0342cdbe1..6bf901840 100644 --- a/crates/algod_client/src/apis/get_pending_transactions_by_address.rs +++ b/crates/algod_client/src/apis/get_pending_transactions_by_address.rs @@ -58,19 +58,8 @@ pub async fn get_pending_transactions_by_address( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_ready.rs b/crates/algod_client/src/apis/get_ready.rs index 4c1f4f016..ba6832406 100644 --- a/crates/algod_client/src/apis/get_ready.rs +++ b/crates/algod_client/src/apis/get_ready.rs @@ -36,7 +36,6 @@ pub async fn get_ready(http_client: &dyn HttpClient) -> Result<(), Error> { let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_state_proof.rs b/crates/algod_client/src/apis/get_state_proof.rs index 8ee9276d0..c7d8e4490 100644 --- a/crates/algod_client/src/apis/get_state_proof.rs +++ b/crates/algod_client/src/apis/get_state_proof.rs @@ -45,7 +45,6 @@ pub async fn get_state_proof( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_status.rs b/crates/algod_client/src/apis/get_status.rs index 6f354e6ba..2a1c1001b 100644 --- a/crates/algod_client/src/apis/get_status.rs +++ b/crates/algod_client/src/apis/get_status.rs @@ -37,7 +37,6 @@ pub async fn get_status(http_client: &dyn HttpClient) -> Result = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_supply.rs b/crates/algod_client/src/apis/get_supply.rs index 8c6ad007d..f77ab49fe 100644 --- a/crates/algod_client/src/apis/get_supply.rs +++ b/crates/algod_client/src/apis/get_supply.rs @@ -36,7 +36,6 @@ pub async fn get_supply(http_client: &dyn HttpClient) -> Result = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_sync_round.rs b/crates/algod_client/src/apis/get_sync_round.rs index afecd2af2..dd5fcefb9 100644 --- a/crates/algod_client/src/apis/get_sync_round.rs +++ b/crates/algod_client/src/apis/get_sync_round.rs @@ -39,7 +39,6 @@ pub async fn get_sync_round(http_client: &dyn HttpClient) -> Result = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_transaction_group_ledger_state_deltas_for_round.rs b/crates/algod_client/src/apis/get_transaction_group_ledger_state_deltas_for_round.rs index 53f39d6d3..99acc8c01 100644 --- a/crates/algod_client/src/apis/get_transaction_group_ledger_state_deltas_for_round.rs +++ b/crates/algod_client/src/apis/get_transaction_group_ledger_state_deltas_for_round.rs @@ -51,19 +51,8 @@ pub async fn get_transaction_group_ledger_state_deltas_for_round( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_transaction_proof.rs b/crates/algod_client/src/apis/get_transaction_proof.rs index a29b638af..c14f783e4 100644 --- a/crates/algod_client/src/apis/get_transaction_proof.rs +++ b/crates/algod_client/src/apis/get_transaction_proof.rs @@ -61,7 +61,6 @@ pub async fn get_transaction_proof( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/get_version.rs b/crates/algod_client/src/apis/get_version.rs index 93c2aba6d..b1fc5805f 100644 --- a/crates/algod_client/src/apis/get_version.rs +++ b/crates/algod_client/src/apis/get_version.rs @@ -34,7 +34,6 @@ pub async fn get_version(http_client: &dyn HttpClient) -> Result let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/health_check.rs b/crates/algod_client/src/apis/health_check.rs index 25402601b..e5eec3aeb 100644 --- a/crates/algod_client/src/apis/health_check.rs +++ b/crates/algod_client/src/apis/health_check.rs @@ -34,7 +34,6 @@ pub async fn health_check(http_client: &dyn HttpClient) -> Result<(), Error> { let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/metrics.rs b/crates/algod_client/src/apis/metrics.rs index a9d031c46..a04d6e595 100644 --- a/crates/algod_client/src/apis/metrics.rs +++ b/crates/algod_client/src/apis/metrics.rs @@ -34,7 +34,6 @@ pub async fn metrics(http_client: &dyn HttpClient) -> Result<(), Error> { let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/pending_transaction_information.rs b/crates/algod_client/src/apis/pending_transaction_information.rs index ed19de0b3..5d2caf3eb 100644 --- a/crates/algod_client/src/apis/pending_transaction_information.rs +++ b/crates/algod_client/src/apis/pending_transaction_information.rs @@ -57,19 +57,8 @@ pub async fn pending_transaction_information( query_params.insert("format".to_string(), value.to_string()); } - let use_msgpack = p_format.map(|f| f != Format::Json).unwrap_or(true); - let mut headers: HashMap = HashMap::new(); - if use_msgpack { - headers.insert( - "Content-Type".to_string(), - "application/msgpack".to_string(), - ); - headers.insert("Accept".to_string(), "application/msgpack".to_string()); - } else { - headers.insert("Content-Type".to_string(), "application/json".to_string()); - headers.insert("Accept".to_string(), "application/json".to_string()); - } + headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/swagger_json.rs b/crates/algod_client/src/apis/swagger_json.rs index 726f9abf3..0e3f259dd 100644 --- a/crates/algod_client/src/apis/swagger_json.rs +++ b/crates/algod_client/src/apis/swagger_json.rs @@ -34,7 +34,6 @@ pub async fn swagger_json(http_client: &dyn HttpClient) -> Result let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; @@ -50,29 +49,7 @@ pub async fn swagger_json(http_client: &dyn HttpClient) -> Result .await .map_err(|e| Error::Http { source: e })?; - let content_type = response - .headers - .get("content-type") - .map(|s| s.as_str()) - .unwrap_or("application/json"); - - match ContentType::from(content_type) { - ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { - message: e.to_string(), - }), - ContentType::MsgPack => Err(Error::Serde { - message: "MsgPack not supported".to_string(), - }), - ContentType::Text => { - let text = String::from_utf8(response.body).map_err(|e| Error::Serde { - message: e.to_string(), - })?; - Err(Error::Serde { - message: format!("Unexpected text response: {}", text), - }) - } - ContentType::Unsupported(ct) => Err(Error::Serde { - message: format!("Unsupported content type: {}", ct), - }), - } + String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }) } diff --git a/crates/algod_client/src/apis/transaction_params.rs b/crates/algod_client/src/apis/transaction_params.rs index 57e485009..f15878200 100644 --- a/crates/algod_client/src/apis/transaction_params.rs +++ b/crates/algod_client/src/apis/transaction_params.rs @@ -38,7 +38,6 @@ pub async fn transaction_params(http_client: &dyn HttpClient) -> Result = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algod_client/src/apis/wait_for_block.rs b/crates/algod_client/src/apis/wait_for_block.rs index 378305df5..0321dd919 100644 --- a/crates/algod_client/src/apis/wait_for_block.rs +++ b/crates/algod_client/src/apis/wait_for_block.rs @@ -44,7 +44,6 @@ pub async fn wait_for_block( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/algokit_utils/Cargo.toml b/crates/algokit_utils/Cargo.toml index f8f88b169..d09d35c21 100644 --- a/crates/algokit_utils/Cargo.toml +++ b/crates/algokit_utils/Cargo.toml @@ -9,11 +9,13 @@ default_http_client = [ "algokit_http_client/default_client", "algod_client/default_client", "indexer_client/default_client", -] + "kmd_client/default_client", + ] [dependencies] algod_client = { path = "../algod_client" } indexer_client = { path = "../indexer_client" } +kmd_client = { path = "../kmd_client" } algokit_abi = { path = "../algokit_abi" } algokit_http_client = { version = "0.1.0", path = "../algokit_http_client", default-features = false } algokit_transact = { version = "0.1.0", path = "../algokit_transact", features = [ diff --git a/crates/algokit_utils/tests/kmd/key_management.rs b/crates/algokit_utils/tests/kmd/key_management.rs new file mode 100644 index 000000000..352d13b3b --- /dev/null +++ b/crates/algokit_utils/tests/kmd/key_management.rs @@ -0,0 +1,109 @@ +use kmd_client::apis::client::KmdClient; +use kmd_client::models::{ + CreateWalletRequest, GenerateKeyRequest, InitWalletHandleTokenRequest, ListKeysRequest, + ReleaseWalletHandleTokenRequest, +}; +use rand::{Rng, distributions::Alphanumeric}; + +// Wallet key management flow: create wallet -> init handle token -> list keys -> generate key -> list keys (increment) -> release token +#[tokio::test] +async fn key_management_flow() -> Result<(), Box> { + let client = KmdClient::localnet(); + + let wallet_name: String = format!( + "test_wallet_keys_{}", + rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(12) + .map(char::from) + .collect::() + .to_lowercase() + ); + + // Create wallet + let create_response = client + .create_wallet(CreateWalletRequest { + wallet_name: Some(wallet_name.clone()), + wallet_driver_name: Some("sqlite".to_string()), + wallet_password: Some("testpass".to_string()), + ..Default::default() + }) + .await + .map_err(|e| { + format!( + "Failed to create wallet (possible KMD token/availability issue): {}", + e + ) + })?; + + let created_wallet = create_response + .wallet + .as_ref() + .expect("Expected created wallet in response"); + + let wallet_id = created_wallet + .id + .as_ref() + .expect("Wallet id should be present"); + assert_eq!( + created_wallet.name.as_ref().map(|s| s.as_str()), + Some(wallet_name.as_str()) + ); + + // Init wallet handle token + let init_response = client + .init_wallet_handle_token(InitWalletHandleTokenRequest { + wallet_id: Some(wallet_id.clone()), + wallet_password: Some("testpass".to_string()), + ..Default::default() + }) + .await?; + let wallet_handle_token = init_response + .wallet_handle_token + .as_ref() + .expect("Wallet handle token should be present") + .clone(); + + // Baseline keys list + let list_before = client + .list_keys_in_wallet(ListKeysRequest { + wallet_handle_token: Some(wallet_handle_token.clone()), + ..Default::default() + }) + .await?; + let before_addresses = list_before.addresses.unwrap_or_default(); + + // Generate new key + let _generate_response = client + .generate_key(GenerateKeyRequest { + wallet_handle_token: Some(wallet_handle_token.clone()), + display_mnemonic: Some(false), + ..Default::default() + }) + .await?; + + // List after + let list_after = client + .list_keys_in_wallet(ListKeysRequest { + wallet_handle_token: Some(wallet_handle_token.clone()), + ..Default::default() + }) + .await?; + let after_addresses = list_after.addresses.unwrap_or_default(); + + assert_eq!( + after_addresses.len(), + before_addresses.len() + 1, + "Expected one additional key after generation" + ); + + // Release handle token + let _release_response = client + .release_wallet_handle_token(ReleaseWalletHandleTokenRequest { + wallet_handle_token: Some(wallet_handle_token.clone()), + ..Default::default() + }) + .await?; + + Ok(()) +} diff --git a/crates/algokit_utils/tests/kmd/mod.rs b/crates/algokit_utils/tests/kmd/mod.rs new file mode 100644 index 000000000..7c35e0c7c --- /dev/null +++ b/crates/algokit_utils/tests/kmd/mod.rs @@ -0,0 +1,2 @@ +mod key_management; +mod wallet_lifecycle; diff --git a/crates/algokit_utils/tests/kmd/wallet_lifecycle.rs b/crates/algokit_utils/tests/kmd/wallet_lifecycle.rs new file mode 100644 index 000000000..980f14169 --- /dev/null +++ b/crates/algokit_utils/tests/kmd/wallet_lifecycle.rs @@ -0,0 +1,56 @@ +use kmd_client::apis::client::KmdClient; +use kmd_client::models::CreateWalletRequest; +use rand::{Rng, distributions::Alphanumeric}; + +// Basic wallet lifecycle: create wallet, ensure it appears in list +#[tokio::test] +async fn wallet_lifecycle() -> Result<(), Box> { + // Arrange + let client = KmdClient::localnet(); + + let wallet_name: String = format!( + "test_wallet_{}", + rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(12) + .map(char::from) + .collect::() + .to_lowercase() + ); + + // Act: create wallet + let create_response = client + .create_wallet(CreateWalletRequest { + wallet_name: Some(wallet_name.clone()), + wallet_driver_name: Some("sqlite".to_string()), + wallet_password: Some("testpass".to_string()), + ..Default::default() + }) + .await + .map_err(|e| { + format!( + "Failed to create wallet (possible KMD token/availability issue): {}", + e + ) + })?; + + // Assert create response basic invariants + let created_wallet = create_response + .wallet + .as_ref() + .expect("Expected created wallet in response"); + assert_eq!( + created_wallet.name.as_ref().map(|s| s.as_str()), + Some(wallet_name.as_str()) + ); + + // List wallets and ensure presence + let list_response = client.list_wallets().await?; + let wallets = list_response.wallets.unwrap_or_default(); + let found = wallets + .iter() + .any(|w| w.name.as_ref().map(|n| n.as_str()) == Some(wallet_name.as_str())); + assert!(found, "Created wallet should be present in list of wallets"); + + Ok(()) +} diff --git a/crates/algokit_utils/tests/kmd_tests.rs b/crates/algokit_utils/tests/kmd_tests.rs new file mode 100644 index 000000000..7bb21d00b --- /dev/null +++ b/crates/algokit_utils/tests/kmd_tests.rs @@ -0,0 +1 @@ +mod kmd; diff --git a/crates/indexer_client/src/apis/lookup_account_app_local_states.rs b/crates/indexer_client/src/apis/lookup_account_app_local_states.rs index 0926ec73f..86ac7efd1 100644 --- a/crates/indexer_client/src/apis/lookup_account_app_local_states.rs +++ b/crates/indexer_client/src/apis/lookup_account_app_local_states.rs @@ -64,7 +64,6 @@ pub async fn lookup_account_app_local_states( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_account_assets.rs b/crates/indexer_client/src/apis/lookup_account_assets.rs index 360716779..7d6913d33 100644 --- a/crates/indexer_client/src/apis/lookup_account_assets.rs +++ b/crates/indexer_client/src/apis/lookup_account_assets.rs @@ -64,7 +64,6 @@ pub async fn lookup_account_assets( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_account_by_id.rs b/crates/indexer_client/src/apis/lookup_account_by_id.rs index 1580c0e24..1685c54e9 100644 --- a/crates/indexer_client/src/apis/lookup_account_by_id.rs +++ b/crates/indexer_client/src/apis/lookup_account_by_id.rs @@ -59,7 +59,6 @@ pub async fn lookup_account_by_id( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_account_created_applications.rs b/crates/indexer_client/src/apis/lookup_account_created_applications.rs index 1153e4872..48a90c83d 100644 --- a/crates/indexer_client/src/apis/lookup_account_created_applications.rs +++ b/crates/indexer_client/src/apis/lookup_account_created_applications.rs @@ -64,7 +64,6 @@ pub async fn lookup_account_created_applications( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_account_created_assets.rs b/crates/indexer_client/src/apis/lookup_account_created_assets.rs index c37dbbdc4..f942c5a43 100644 --- a/crates/indexer_client/src/apis/lookup_account_created_assets.rs +++ b/crates/indexer_client/src/apis/lookup_account_created_assets.rs @@ -64,7 +64,6 @@ pub async fn lookup_account_created_assets( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_account_transactions.rs b/crates/indexer_client/src/apis/lookup_account_transactions.rs index 982becd65..6053b42a4 100644 --- a/crates/indexer_client/src/apis/lookup_account_transactions.rs +++ b/crates/indexer_client/src/apis/lookup_account_transactions.rs @@ -119,7 +119,6 @@ pub async fn lookup_account_transactions( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_application_box_by_id_and_name.rs b/crates/indexer_client/src/apis/lookup_application_box_by_id_and_name.rs index 4fb0b5a7a..d132ae328 100644 --- a/crates/indexer_client/src/apis/lookup_application_box_by_id_and_name.rs +++ b/crates/indexer_client/src/apis/lookup_application_box_by_id_and_name.rs @@ -47,7 +47,6 @@ pub async fn lookup_application_box_by_id_and_name( query_params.insert("name".to_string(), p_name.to_string()); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_application_by_id.rs b/crates/indexer_client/src/apis/lookup_application_by_id.rs index ef612bb54..ecc99d6d6 100644 --- a/crates/indexer_client/src/apis/lookup_application_by_id.rs +++ b/crates/indexer_client/src/apis/lookup_application_by_id.rs @@ -48,7 +48,6 @@ pub async fn lookup_application_by_id( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_application_logs_by_id.rs b/crates/indexer_client/src/apis/lookup_application_logs_by_id.rs index 994fc7630..d92f874b3 100644 --- a/crates/indexer_client/src/apis/lookup_application_logs_by_id.rs +++ b/crates/indexer_client/src/apis/lookup_application_logs_by_id.rs @@ -71,7 +71,6 @@ pub async fn lookup_application_logs_by_id( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_asset_balances.rs b/crates/indexer_client/src/apis/lookup_asset_balances.rs index 724f921cb..5abc48d3d 100644 --- a/crates/indexer_client/src/apis/lookup_asset_balances.rs +++ b/crates/indexer_client/src/apis/lookup_asset_balances.rs @@ -65,7 +65,6 @@ pub async fn lookup_asset_balances( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_asset_by_id.rs b/crates/indexer_client/src/apis/lookup_asset_by_id.rs index bb063dfd2..642d1e764 100644 --- a/crates/indexer_client/src/apis/lookup_asset_by_id.rs +++ b/crates/indexer_client/src/apis/lookup_asset_by_id.rs @@ -46,7 +46,6 @@ pub async fn lookup_asset_by_id( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_asset_transactions.rs b/crates/indexer_client/src/apis/lookup_asset_transactions.rs index fc327756f..b982a3518 100644 --- a/crates/indexer_client/src/apis/lookup_asset_transactions.rs +++ b/crates/indexer_client/src/apis/lookup_asset_transactions.rs @@ -126,7 +126,6 @@ pub async fn lookup_asset_transactions( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_block.rs b/crates/indexer_client/src/apis/lookup_block.rs index d9b98f587..18730d611 100644 --- a/crates/indexer_client/src/apis/lookup_block.rs +++ b/crates/indexer_client/src/apis/lookup_block.rs @@ -45,7 +45,6 @@ pub async fn lookup_block( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/lookup_transaction.rs b/crates/indexer_client/src/apis/lookup_transaction.rs index 18e7e1d7a..23b3af6ad 100644 --- a/crates/indexer_client/src/apis/lookup_transaction.rs +++ b/crates/indexer_client/src/apis/lookup_transaction.rs @@ -44,7 +44,6 @@ pub async fn lookup_transaction( let query_params: HashMap = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/make_health_check.rs b/crates/indexer_client/src/apis/make_health_check.rs index 4fbf440f9..b10cf3c4e 100644 --- a/crates/indexer_client/src/apis/make_health_check.rs +++ b/crates/indexer_client/src/apis/make_health_check.rs @@ -34,7 +34,6 @@ pub async fn make_health_check(http_client: &dyn HttpClient) -> Result = HashMap::new(); let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/search_for_accounts.rs b/crates/indexer_client/src/apis/search_for_accounts.rs index 62be621e5..0c9285521 100644 --- a/crates/indexer_client/src/apis/search_for_accounts.rs +++ b/crates/indexer_client/src/apis/search_for_accounts.rs @@ -93,7 +93,6 @@ pub async fn search_for_accounts( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/search_for_application_boxes.rs b/crates/indexer_client/src/apis/search_for_application_boxes.rs index d490330b4..8b2f0866b 100644 --- a/crates/indexer_client/src/apis/search_for_application_boxes.rs +++ b/crates/indexer_client/src/apis/search_for_application_boxes.rs @@ -54,7 +54,6 @@ pub async fn search_for_application_boxes( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/search_for_applications.rs b/crates/indexer_client/src/apis/search_for_applications.rs index 5ed2f9778..533386928 100644 --- a/crates/indexer_client/src/apis/search_for_applications.rs +++ b/crates/indexer_client/src/apis/search_for_applications.rs @@ -62,7 +62,6 @@ pub async fn search_for_applications( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/search_for_assets.rs b/crates/indexer_client/src/apis/search_for_assets.rs index 0f445f857..97cd95921 100644 --- a/crates/indexer_client/src/apis/search_for_assets.rs +++ b/crates/indexer_client/src/apis/search_for_assets.rs @@ -73,7 +73,6 @@ pub async fn search_for_assets( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/search_for_block_headers.rs b/crates/indexer_client/src/apis/search_for_block_headers.rs index 030fb714a..92cf85b83 100644 --- a/crates/indexer_client/src/apis/search_for_block_headers.rs +++ b/crates/indexer_client/src/apis/search_for_block_headers.rs @@ -83,7 +83,6 @@ pub async fn search_for_block_headers( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/indexer_client/src/apis/search_for_transactions.rs b/crates/indexer_client/src/apis/search_for_transactions.rs index 869f349e8..e3bac4823 100644 --- a/crates/indexer_client/src/apis/search_for_transactions.rs +++ b/crates/indexer_client/src/apis/search_for_transactions.rs @@ -139,7 +139,6 @@ pub async fn search_for_transactions( } let mut headers: HashMap = HashMap::new(); - headers.insert("Content-Type".to_string(), "application/json".to_string()); headers.insert("Accept".to_string(), "application/json".to_string()); let body = None; diff --git a/crates/kmd_client/Cargo.toml b/crates/kmd_client/Cargo.toml new file mode 100644 index 000000000..0ac2e5ee2 --- /dev/null +++ b/crates/kmd_client/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "kmd_client" +version = "0.0.1" +authors = ["AlgoKit Core Team"] +description = "API client for KMD (Key Management Daemon) interaction." +license = "MIT" +edition = "2024" + +[features] +default = ["default_client"] +default_client = ["algokit_http_client/default_client"] + +[dependencies] +# Core serialization +serde = { version = "^1.0", features = ["derive"] } +serde_with = { version = "^3.8", default-features = false, features = [ + "base64", + "std", + "macros", +] } +serde_json = "^1.0" +serde_repr = "^0.1" +serde_bytes = "^0.11" + +# HTTP client +algokit_http_client = { path = "../algokit_http_client", features = ["ffi_uniffi"] } +url = "^2.5" + + +# Error handling +snafu = { workspace = true } + +# Utilities +base64 = "^0.22" +uuid = { version = "^1.0", features = ["v4"] } + +[dev-dependencies] +tokio = { version = "1.0", features = ["full"] } +tokio-test = "^0.4" \ No newline at end of file diff --git a/crates/kmd_client/README.md b/crates/kmd_client/README.md new file mode 100644 index 000000000..44f7e277a --- /dev/null +++ b/crates/kmd_client/README.md @@ -0,0 +1,280 @@ +# for KMD HTTP API + +API for KMD (Key Management Daemon) + +**Version:** 0.0.1 +**Contact:** contact@algorand.com + +This Rust crate provides a client library for the for KMD HTTP API API. + +## Installation + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +kmd_client = "0.0.1" +``` + +## Usage + +```rust +use kmd_client::KmdClient; + +#[tokio::main] +async fn main() -> Result<(), Box> { + // Initialize client (choose one based on your network) + let client = KmdClient::localnet(); // For local development + // let client = KmdClient::testnet(); // For TestNet + // let client = KmdClient::mainnet(); // For MainNet + + // Example: Get network status + let status = client.get_status().await?; + println!("Network status: {:?}", status); + + // Example: Get transaction parameters + let params = client.transaction_params().await?; + println!("Min fee: {}", params.min_fee); + println!("Last round: {}", params.last_round); + + // Example: Get account information + let account_address = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + let account_info = client.account_information( + None, // format + account_address, + None, // exclude + ).await?; + println!("Account balance: {}", account_info.amount); + + Ok(()) +} +``` + +## Configuration + +The client provides convenient constructors for different networks: + +```rust +use kmd_client::KmdClient; + +// For local development (uses localhost:4001 with default API token) +let client = KmdClient::localnet(); + +// For Algorand TestNet +let client = KmdClient::testnet(); + +// For Algorand MainNet +let client = KmdClient::mainnet(); +``` + +For custom configurations, you can use a custom HTTP client: + +```rust +use kmd_client::KmdClient; +use algokit_http_client::DefaultHttpClient; +use std::sync::Arc; + +// Custom endpoint with API token +let http_client = Arc::new( + DefaultHttpClient::with_header( + "http://localhost/", + "X-API-Key", + "your-api-key" + )? +); +let client = KmdClient::new(http_client); +``` + +## Complete Example + +Here's a more comprehensive example showing how to check network status, get account information, and prepare for transactions: + +```rust +use kmd_client::KmdClient; + +#[tokio::main] +async fn main() -> Result<(), Box> { + // Connect to localnet + let client = KmdClient::localnet(); + + // Check if the node is healthy and ready + client.health_check().await?; + client.get_ready().await?; + println!("✓ Node is healthy and ready"); + + // Get network information + let status = client.get_status().await?; + println!("✓ Connected to network"); + println!(" Last round: {}", status.last_round); + println!(" Catching up: {}", status.catchup_time.unwrap_or(0)); + + // Get transaction parameters needed for building transactions + let params = client.transaction_params().await?; + println!("✓ Retrieved transaction parameters"); + println!(" Genesis ID: {}", params.genesis_id); + println!(" Min fee: {}", params.min_fee); + + // Example: Get account information + let test_address = "7ZUECA7HFLZTXENRV24SHLU4AVPUTMTTDUFUBNBD64C73F3UHRTHAIOF6Q"; + match client.account_information(None, test_address, None).await { + Ok(account) => { + println!("✓ Account information retrieved"); + println!(" Address: {}", account.address); + println!(" Balance: {} microAlgos", account.amount); + println!(" Min balance: {} microAlgos", account.min_balance); + } + Err(e) => { + println!("⚠ Could not retrieve account info: {}", e); + } + } + + Ok(()) +} +``` + +## API Operations + +This client provides access to 23 API operations: + +- `swagger_handler` - Gets the current swagger spec. +- `generate_key` - Generate a key +- `delete_key` - Delete a key +- `export_key` - Export a key +- `import_key` - Import a key +- `list_keys_in_wallet` - List keys in wallet +- `export_master_key` - Export the master derivation key from a wallet +- `delete_multisig` - Delete a multisig +- `export_multisig` - Export multisig address metadata +- `import_multisig` - Import a multisig account +- `list_multisig` - List multisig accounts +- `sign_multisig_transaction` - Sign a multisig transaction +- `sign_multisig_program` - Sign a program for a multisig account +- `sign_program` - Sign program +- `sign_transaction` - Sign a transaction +- `create_wallet` - Create a wallet +- `get_wallet_info` - Get wallet info +- `init_wallet_handle_token` - Initialize a wallet handle token +- `release_wallet_handle_token` - Release a wallet handle token +- `rename_wallet` - Rename a wallet +- `renew_wallet_handle_token` - Renew a wallet handle token +- `list_wallets` - List wallets +- `get_version` - Retrieves the current version + +## Models + +The following data models are available: + +- `Apiv1DeleteKeyResponse` - APIV1DELETEKeyResponse is the response to `DELETE /v1/key` +friendly:DeleteKeyResponse +- `Apiv1DeleteMultisigResponse` - APIV1DELETEMultisigResponse is the response to POST /v1/multisig/delete` +friendly:DeleteMultisigResponse +- `Apiv1GetWalletsResponse` - APIV1GETWalletsResponse is the response to `GET /v1/wallets` +friendly:ListWalletsResponse +- `Apiv1PostKeyExportResponse` - APIV1POSTKeyExportResponse is the response to `POST /v1/key/export` +friendly:ExportKeyResponse +- `Apiv1PostKeyImportResponse` - APIV1POSTKeyImportResponse is the response to `POST /v1/key/import` +friendly:ImportKeyResponse +- `Apiv1PostKeyListResponse` - APIV1POSTKeyListResponse is the response to `POST /v1/key/list` +friendly:ListKeysResponse +- `Apiv1PostKeyResponse` - APIV1POSTKeyResponse is the response to `POST /v1/key` +friendly:GenerateKeyResponse +- `Apiv1PostMasterKeyExportResponse` - APIV1POSTMasterKeyExportResponse is the response to `POST /v1/master-key/export` +friendly:ExportMasterKeyResponse +- `Apiv1PostMultisigExportResponse` - APIV1POSTMultisigExportResponse is the response to `POST /v1/multisig/export` +friendly:ExportMultisigResponse +- `Apiv1PostMultisigImportResponse` - APIV1POSTMultisigImportResponse is the response to `POST /v1/multisig/import` +friendly:ImportMultisigResponse +- `Apiv1PostMultisigListResponse` - APIV1POSTMultisigListResponse is the response to `POST /v1/multisig/list` +friendly:ListMultisigResponse +- `Apiv1PostMultisigProgramSignResponse` - APIV1POSTMultisigProgramSignResponse is the response to `POST /v1/multisig/signdata` +friendly:SignProgramMultisigResponse +- `Apiv1PostMultisigTransactionSignResponse` - APIV1POSTMultisigTransactionSignResponse is the response to `POST /v1/multisig/sign` +friendly:SignMultisigResponse +- `Apiv1PostProgramSignResponse` - APIV1POSTProgramSignResponse is the response to `POST /v1/data/sign` +friendly:SignProgramResponse +- `Apiv1PostTransactionSignResponse` - APIV1POSTTransactionSignResponse is the response to `POST /v1/transaction/sign` +friendly:SignTransactionResponse +- `Apiv1PostWalletInfoResponse` - APIV1POSTWalletInfoResponse is the response to `POST /v1/wallet/info` +friendly:WalletInfoResponse +- `Apiv1PostWalletInitResponse` - APIV1POSTWalletInitResponse is the response to `POST /v1/wallet/init` +friendly:InitWalletHandleTokenResponse +- `Apiv1PostWalletReleaseResponse` - APIV1POSTWalletReleaseResponse is the response to `POST /v1/wallet/release` +friendly:ReleaseWalletHandleTokenResponse +- `Apiv1PostWalletRenameResponse` - APIV1POSTWalletRenameResponse is the response to `POST /v1/wallet/rename` +friendly:RenameWalletResponse +- `Apiv1PostWalletRenewResponse` - APIV1POSTWalletRenewResponse is the response to `POST /v1/wallet/renew` +friendly:RenewWalletHandleTokenResponse +- `Apiv1PostWalletResponse` - APIV1POSTWalletResponse is the response to `POST /v1/wallet` +friendly:CreateWalletResponse +- `Apiv1Wallet` - APIV1Wallet is the API's representation of a wallet +- `Apiv1WalletHandle` - APIV1WalletHandle includes the wallet the handle corresponds to +and the number of number of seconds to expiration +- `CreateWalletRequest` - APIV1POSTWalletRequest is the request for `POST /v1/wallet` +- `DeleteKeyRequest` - APIV1DELETEKeyRequest is the request for `DELETE /v1/key` +- `DeleteMultisigRequest` - APIV1DELETEMultisigRequest is the request for `DELETE /v1/multisig` +- `Digest` - No description +- `ExportKeyRequest` - APIV1POSTKeyExportRequest is the request for `POST /v1/key/export` +- `ExportMasterKeyRequest` - APIV1POSTMasterKeyExportRequest is the request for `POST /v1/master-key/export` +- `ExportMultisigRequest` - APIV1POSTMultisigExportRequest is the request for `POST /v1/multisig/export` +- `GenerateKeyRequest` - APIV1POSTKeyRequest is the request for `POST /v1/key` +- `ImportKeyRequest` - APIV1POSTKeyImportRequest is the request for `POST /v1/key/import` +- `ImportMultisigRequest` - APIV1POSTMultisigImportRequest is the request for `POST /v1/multisig/import` +- `InitWalletHandleTokenRequest` - APIV1POSTWalletInitRequest is the request for `POST /v1/wallet/init` +- `ListKeysRequest` - APIV1POSTKeyListRequest is the request for `POST /v1/key/list` +- `ListMultisigRequest` - APIV1POSTMultisigListRequest is the request for `POST /v1/multisig/list` +- `ListWalletsRequest` - APIV1GETWalletsRequest is the request for `GET /v1/wallets` +- `MasterDerivationKey` - MasterDerivationKey is used to derive ed25519 keys for use in wallets +- `MultisigSig` - MultisigSig is the structure that holds multiple Subsigs +- `MultisigSubsig` - MultisigSubsig is a struct that holds a pair of public key and signatures +signatures may be empty +- `PrivateKey` - No description +- `PublicKey` - No description +- `ReleaseWalletHandleTokenRequest` - APIV1POSTWalletReleaseRequest is the request for `POST /v1/wallet/release` +- `RenameWalletRequest` - APIV1POSTWalletRenameRequest is the request for `POST /v1/wallet/rename` +- `RenewWalletHandleTokenRequest` - APIV1POSTWalletRenewRequest is the request for `POST /v1/wallet/renew` +- `SignMultisigRequest` - APIV1POSTMultisigTransactionSignRequest is the request for `POST /v1/multisig/sign` +- `SignProgramMultisigRequest` - APIV1POSTMultisigProgramSignRequest is the request for `POST /v1/multisig/signprogram` +- `SignProgramRequest` - APIV1POSTProgramSignRequest is the request for `POST /v1/program/sign` +- `SignTransactionRequest` - APIV1POSTTransactionSignRequest is the request for `POST /v1/transaction/sign` +- `Signature` - No description +- `TxType` - TxType is the type of the transaction written to the ledger +- `VersionsRequest` - VersionsRequest is the request for `GET /versions` +- `VersionsResponse` - VersionsResponse is the response to `GET /versions` +friendly:VersionsResponse +- `WalletInfoRequest` - APIV1POSTWalletInfoRequest is the request for `POST /v1/wallet/info` +- `Ed25519PrivateKey` - No description +- `Ed25519PublicKey` - No description +- `Ed25519Signature` - No description + +## Error Handling + +All API operations return a `Result` type. Errors include: + +- Network errors (connection issues, timeouts) +- HTTP errors (4xx, 5xx status codes) +- Serialization errors (invalid JSON responses) + +```rust +// Example error handling +match client.get_status().await { + Ok(status) => { + println!("Node is running on round: {}", status.last_round); + } + Err(error) => { + eprintln!("Failed to get node status: {:?}", error); + // Handle specific error types if needed + } +} + +// Or use the ? operator for early returns +let params = client.transaction_params().await + .map_err(|e| format!("Failed to get transaction params: {}", e))?; +``` + +## Generated Code + +This client was generated from an OpenAPI specification using a custom Rust code generator. + +**Generated on:** Generated by Rust OpenAPI Generator +**OpenAPI Version:** 3.0.0 +**Generator:** Rust OpenAPI Generator diff --git a/crates/kmd_client/src/apis/client.rs b/crates/kmd_client/src/apis/client.rs new file mode 100644 index 000000000..2cccf2f50 --- /dev/null +++ b/crates/kmd_client/src/apis/client.rs @@ -0,0 +1,251 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use super::Error; +use crate::models::{ + Apiv1DeleteKeyResponse, Apiv1DeleteMultisigResponse, Apiv1GetWalletsResponse, + Apiv1PostKeyExportResponse, Apiv1PostKeyImportResponse, Apiv1PostKeyListResponse, + Apiv1PostKeyResponse, Apiv1PostMasterKeyExportResponse, Apiv1PostMultisigExportResponse, + Apiv1PostMultisigImportResponse, Apiv1PostMultisigListResponse, + Apiv1PostMultisigProgramSignResponse, Apiv1PostMultisigTransactionSignResponse, + Apiv1PostProgramSignResponse, Apiv1PostTransactionSignResponse, Apiv1PostWalletInfoResponse, + Apiv1PostWalletInitResponse, Apiv1PostWalletReleaseResponse, Apiv1PostWalletRenameResponse, + Apiv1PostWalletRenewResponse, Apiv1PostWalletResponse, CreateWalletRequest, DeleteKeyRequest, + DeleteMultisigRequest, ExportKeyRequest, ExportMasterKeyRequest, ExportMultisigRequest, + GenerateKeyRequest, ImportKeyRequest, ImportMultisigRequest, InitWalletHandleTokenRequest, + ListKeysRequest, ListMultisigRequest, ReleaseWalletHandleTokenRequest, RenameWalletRequest, + RenewWalletHandleTokenRequest, SignMultisigRequest, SignProgramMultisigRequest, + SignProgramRequest, SignTransactionRequest, VersionsResponse, WalletInfoRequest, +}; +use algokit_http_client::{DefaultHttpClient, HttpClient}; +use std::sync::Arc; + +/// The main Kmd API client. +/// +/// This client provides convenient access to all Kmd API endpoints. +/// It wraps the lower-level endpoint functions with a more ergonomic interface. +/// All methods return a unified `Error` type that can represent any endpoint error. +#[derive(Clone)] +pub struct KmdClient { + http_client: Arc, +} + +impl KmdClient { + /// Create a new KmdClient with a custom http client. + pub fn new(http_client: Arc) -> Self { + Self { http_client } + } + + /// Create a new KmdClient for a local localnet environment. + #[cfg(feature = "default_client")] + pub fn localnet() -> Self { + let http_client = Arc::new( + DefaultHttpClient::with_header( + "http://localhost:4002", + "X-KMD-API-Token", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + ) + .expect("Failed to create HTTP client with API token header"), + ); + Self::new(http_client) + } + + /// Gets the current swagger spec. + pub async fn swagger_handler(&self) -> Result { + super::swagger_handler::swagger_handler(self.http_client.as_ref()).await + } + + /// Generate a key + pub async fn generate_key( + &self, + request: GenerateKeyRequest, + ) -> Result { + super::generate_key::generate_key(self.http_client.as_ref(), request).await + } + + /// Delete a key + pub async fn delete_key( + &self, + request: DeleteKeyRequest, + ) -> Result { + super::delete_key::delete_key(self.http_client.as_ref(), request).await + } + + /// Export a key + pub async fn export_key( + &self, + request: ExportKeyRequest, + ) -> Result { + super::export_key::export_key(self.http_client.as_ref(), request).await + } + + /// Import a key + pub async fn import_key( + &self, + request: ImportKeyRequest, + ) -> Result { + super::import_key::import_key(self.http_client.as_ref(), request).await + } + + /// List keys in wallet + pub async fn list_keys_in_wallet( + &self, + request: ListKeysRequest, + ) -> Result { + super::list_keys_in_wallet::list_keys_in_wallet(self.http_client.as_ref(), request).await + } + + /// Export the master derivation key from a wallet + pub async fn export_master_key( + &self, + request: ExportMasterKeyRequest, + ) -> Result { + super::export_master_key::export_master_key(self.http_client.as_ref(), request).await + } + + /// Delete a multisig + pub async fn delete_multisig( + &self, + request: DeleteMultisigRequest, + ) -> Result { + super::delete_multisig::delete_multisig(self.http_client.as_ref(), request).await + } + + /// Export multisig address metadata + pub async fn export_multisig( + &self, + request: ExportMultisigRequest, + ) -> Result { + super::export_multisig::export_multisig(self.http_client.as_ref(), request).await + } + + /// Import a multisig account + pub async fn import_multisig( + &self, + request: ImportMultisigRequest, + ) -> Result { + super::import_multisig::import_multisig(self.http_client.as_ref(), request).await + } + + /// List multisig accounts + pub async fn list_multisig( + &self, + request: ListMultisigRequest, + ) -> Result { + super::list_multisig::list_multisig(self.http_client.as_ref(), request).await + } + + /// Sign a multisig transaction + pub async fn sign_multisig_transaction( + &self, + request: SignMultisigRequest, + ) -> Result { + super::sign_multisig_transaction::sign_multisig_transaction( + self.http_client.as_ref(), + request, + ) + .await + } + + /// Sign a program for a multisig account + pub async fn sign_multisig_program( + &self, + request: SignProgramMultisigRequest, + ) -> Result { + super::sign_multisig_program::sign_multisig_program(self.http_client.as_ref(), request) + .await + } + + /// Sign program + pub async fn sign_program( + &self, + request: SignProgramRequest, + ) -> Result { + super::sign_program::sign_program(self.http_client.as_ref(), request).await + } + + /// Sign a transaction + pub async fn sign_transaction( + &self, + request: SignTransactionRequest, + ) -> Result { + super::sign_transaction::sign_transaction(self.http_client.as_ref(), request).await + } + + /// Create a wallet + pub async fn create_wallet( + &self, + request: CreateWalletRequest, + ) -> Result { + super::create_wallet::create_wallet(self.http_client.as_ref(), request).await + } + + /// Get wallet info + pub async fn get_wallet_info( + &self, + request: WalletInfoRequest, + ) -> Result { + super::get_wallet_info::get_wallet_info(self.http_client.as_ref(), request).await + } + + /// Initialize a wallet handle token + pub async fn init_wallet_handle_token( + &self, + request: InitWalletHandleTokenRequest, + ) -> Result { + super::init_wallet_handle_token::init_wallet_handle_token( + self.http_client.as_ref(), + request, + ) + .await + } + + /// Release a wallet handle token + pub async fn release_wallet_handle_token( + &self, + request: ReleaseWalletHandleTokenRequest, + ) -> Result { + super::release_wallet_handle_token::release_wallet_handle_token( + self.http_client.as_ref(), + request, + ) + .await + } + + /// Rename a wallet + pub async fn rename_wallet( + &self, + request: RenameWalletRequest, + ) -> Result { + super::rename_wallet::rename_wallet(self.http_client.as_ref(), request).await + } + + /// Renew a wallet handle token + pub async fn renew_wallet_handle_token( + &self, + request: RenewWalletHandleTokenRequest, + ) -> Result { + super::renew_wallet_handle_token::renew_wallet_handle_token( + self.http_client.as_ref(), + request, + ) + .await + } + + /// List wallets + pub async fn list_wallets(&self) -> Result { + super::list_wallets::list_wallets(self.http_client.as_ref()).await + } + + /// Retrieves the current version + pub async fn get_version(&self) -> Result { + super::get_version::get_version(self.http_client.as_ref()).await + } +} diff --git a/crates/kmd_client/src/apis/create_wallet.rs b/crates/kmd_client/src/apis/create_wallet.rs new file mode 100644 index 000000000..999eae44e --- /dev/null +++ b/crates/kmd_client/src/apis/create_wallet.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostWalletResponse; + +// Import request body type if needed +use crate::models::CreateWalletRequest; + +/// struct for typed errors of method [`create_wallet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateWalletError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Create a new wallet (collection of keys) with the given parameters. +pub async fn create_wallet( + http_client: &dyn HttpClient, + request: CreateWalletRequest, +) -> Result { + let p_request = request; + + let path = "/v1/wallet".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/delete_key.rs b/crates/kmd_client/src/apis/delete_key.rs new file mode 100644 index 000000000..97aa85b21 --- /dev/null +++ b/crates/kmd_client/src/apis/delete_key.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1DeleteKeyResponse; + +// Import request body type if needed +use crate::models::DeleteKeyRequest; + +/// struct for typed errors of method [`delete_key`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteKeyError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Deletes the key with the passed public key from the wallet. +pub async fn delete_key( + http_client: &dyn HttpClient, + request: DeleteKeyRequest, +) -> Result { + let p_request = request; + + let path = "/v1/key".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Delete, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/delete_multisig.rs b/crates/kmd_client/src/apis/delete_multisig.rs new file mode 100644 index 000000000..2e4919f9e --- /dev/null +++ b/crates/kmd_client/src/apis/delete_multisig.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1DeleteMultisigResponse; + +// Import request body type if needed +use crate::models::DeleteMultisigRequest; + +/// struct for typed errors of method [`delete_multisig`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteMultisigError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Deletes multisig preimage information for the passed address from the wallet. +pub async fn delete_multisig( + http_client: &dyn HttpClient, + request: DeleteMultisigRequest, +) -> Result { + let p_request = request; + + let path = "/v1/multisig".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Delete, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/export_key.rs b/crates/kmd_client/src/apis/export_key.rs new file mode 100644 index 000000000..e52321dab --- /dev/null +++ b/crates/kmd_client/src/apis/export_key.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostKeyExportResponse; + +// Import request body type if needed +use crate::models::ExportKeyRequest; + +/// struct for typed errors of method [`export_key`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ExportKeyError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Export the secret key associated with the passed public key. +pub async fn export_key( + http_client: &dyn HttpClient, + request: ExportKeyRequest, +) -> Result { + let p_request = request; + + let path = "/v1/key/export".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/export_master_key.rs b/crates/kmd_client/src/apis/export_master_key.rs new file mode 100644 index 000000000..56c272a27 --- /dev/null +++ b/crates/kmd_client/src/apis/export_master_key.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostMasterKeyExportResponse; + +// Import request body type if needed +use crate::models::ExportMasterKeyRequest; + +/// struct for typed errors of method [`export_master_key`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ExportMasterKeyError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Export the master derivation key from the wallet. This key is a master "backup" key for the underlying wallet. With it, you can regenerate all of the wallets that have been generated with this wallet's `POST /v1/key` endpoint. This key will not allow you to recover keys imported from other wallets, however. +pub async fn export_master_key( + http_client: &dyn HttpClient, + request: ExportMasterKeyRequest, +) -> Result { + let p_request = request; + + let path = "/v1/master-key/export".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/export_multisig.rs b/crates/kmd_client/src/apis/export_multisig.rs new file mode 100644 index 000000000..e87942974 --- /dev/null +++ b/crates/kmd_client/src/apis/export_multisig.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostMultisigExportResponse; + +// Import request body type if needed +use crate::models::ExportMultisigRequest; + +/// struct for typed errors of method [`export_multisig`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ExportMultisigError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Given a multisig address whose preimage this wallet stores, returns the information used to generate the address, including public keys, threshold, and multisig version. +pub async fn export_multisig( + http_client: &dyn HttpClient, + request: ExportMultisigRequest, +) -> Result { + let p_request = request; + + let path = "/v1/multisig/export".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/generate_key.rs b/crates/kmd_client/src/apis/generate_key.rs new file mode 100644 index 000000000..128afb80e --- /dev/null +++ b/crates/kmd_client/src/apis/generate_key.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostKeyResponse; + +// Import request body type if needed +use crate::models::GenerateKeyRequest; + +/// struct for typed errors of method [`generate_key`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GenerateKeyError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Generates the next key in the deterministic key sequence (as determined by the master derivation key) and adds it to the wallet, returning the public key. +pub async fn generate_key( + http_client: &dyn HttpClient, + request: GenerateKeyRequest, +) -> Result { + let p_request = request; + + let path = "/v1/key".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/get_version.rs b/crates/kmd_client/src/apis/get_version.rs new file mode 100644 index 000000000..bbbaf88f6 --- /dev/null +++ b/crates/kmd_client/src/apis/get_version.rs @@ -0,0 +1,77 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::VersionsResponse; + +// Import request body type if needed + +/// struct for typed errors of method [`get_version`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetVersionError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Retrieves the current version +pub async fn get_version(http_client: &dyn HttpClient) -> Result { + let path = "/versions".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = None; + + let response = http_client + .request( + HttpMethod::Get, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/get_wallet_info.rs b/crates/kmd_client/src/apis/get_wallet_info.rs new file mode 100644 index 000000000..bc581ae6b --- /dev/null +++ b/crates/kmd_client/src/apis/get_wallet_info.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostWalletInfoResponse; + +// Import request body type if needed +use crate::models::WalletInfoRequest; + +/// struct for typed errors of method [`get_wallet_info`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWalletInfoError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Returns information about the wallet associated with the passed wallet handle token. Additionally returns expiration information about the token itself. +pub async fn get_wallet_info( + http_client: &dyn HttpClient, + request: WalletInfoRequest, +) -> Result { + let p_request = request; + + let path = "/v1/wallet/info".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/import_key.rs b/crates/kmd_client/src/apis/import_key.rs new file mode 100644 index 000000000..34c07f1c7 --- /dev/null +++ b/crates/kmd_client/src/apis/import_key.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostKeyImportResponse; + +// Import request body type if needed +use crate::models::ImportKeyRequest; + +/// struct for typed errors of method [`import_key`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ImportKeyError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Import an externally generated key into the wallet. Note that if you wish to back up the imported key, you must do so by backing up the entire wallet database, because imported keys were not derived from the wallet's master derivation key. +pub async fn import_key( + http_client: &dyn HttpClient, + request: ImportKeyRequest, +) -> Result { + let p_request = request; + + let path = "/v1/key/import".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/import_multisig.rs b/crates/kmd_client/src/apis/import_multisig.rs new file mode 100644 index 000000000..8861928d1 --- /dev/null +++ b/crates/kmd_client/src/apis/import_multisig.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostMultisigImportResponse; + +// Import request body type if needed +use crate::models::ImportMultisigRequest; + +/// struct for typed errors of method [`import_multisig`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ImportMultisigError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Generates a multisig account from the passed public keys array and multisig metadata, and stores all of this in the wallet. +pub async fn import_multisig( + http_client: &dyn HttpClient, + request: ImportMultisigRequest, +) -> Result { + let p_request = request; + + let path = "/v1/multisig/import".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/init_wallet_handle_token.rs b/crates/kmd_client/src/apis/init_wallet_handle_token.rs new file mode 100644 index 000000000..c713e0755 --- /dev/null +++ b/crates/kmd_client/src/apis/init_wallet_handle_token.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostWalletInitResponse; + +// Import request body type if needed +use crate::models::InitWalletHandleTokenRequest; + +/// struct for typed errors of method [`init_wallet_handle_token`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum InitWalletHandleTokenError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Unlock the wallet and return a wallet handle token that can be used for subsequent operations. These tokens expire periodically and must be renewed. You can `POST` the token to `/v1/wallet/info` to see how much time remains until expiration, and renew it with `/v1/wallet/renew`. When you're done, you can invalidate the token with `/v1/wallet/release`. +pub async fn init_wallet_handle_token( + http_client: &dyn HttpClient, + request: InitWalletHandleTokenRequest, +) -> Result { + let p_request = request; + + let path = "/v1/wallet/init".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/list_keys_in_wallet.rs b/crates/kmd_client/src/apis/list_keys_in_wallet.rs new file mode 100644 index 000000000..71a428987 --- /dev/null +++ b/crates/kmd_client/src/apis/list_keys_in_wallet.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostKeyListResponse; + +// Import request body type if needed +use crate::models::ListKeysRequest; + +/// struct for typed errors of method [`list_keys_in_wallet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListKeysInWalletError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Lists all of the public keys in this wallet. All of them have a stored private key. +pub async fn list_keys_in_wallet( + http_client: &dyn HttpClient, + request: ListKeysRequest, +) -> Result { + let p_request = request; + + let path = "/v1/key/list".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/list_multisig.rs b/crates/kmd_client/src/apis/list_multisig.rs new file mode 100644 index 000000000..a4967175b --- /dev/null +++ b/crates/kmd_client/src/apis/list_multisig.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostMultisigListResponse; + +// Import request body type if needed +use crate::models::ListMultisigRequest; + +/// struct for typed errors of method [`list_multisig`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListMultisigError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Lists all of the multisig accounts whose preimages this wallet stores +pub async fn list_multisig( + http_client: &dyn HttpClient, + request: ListMultisigRequest, +) -> Result { + let p_request = request; + + let path = "/v1/multisig/list".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/list_wallets.rs b/crates/kmd_client/src/apis/list_wallets.rs new file mode 100644 index 000000000..177add2cc --- /dev/null +++ b/crates/kmd_client/src/apis/list_wallets.rs @@ -0,0 +1,77 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1GetWalletsResponse; + +// Import request body type if needed + +/// struct for typed errors of method [`list_wallets`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListWalletsError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Lists all of the wallets that kmd is aware of. +pub async fn list_wallets(http_client: &dyn HttpClient) -> Result { + let path = "/v1/wallets".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = None; + + let response = http_client + .request( + HttpMethod::Get, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/mod.rs b/crates/kmd_client/src/apis/mod.rs new file mode 100644 index 000000000..4a3f2bb79 --- /dev/null +++ b/crates/kmd_client/src/apis/mod.rs @@ -0,0 +1,335 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +// Consolidated client +pub mod client; + +// Individual endpoint modules +pub mod create_wallet; +pub mod delete_key; +pub mod delete_multisig; +pub mod export_key; +pub mod export_master_key; +pub mod export_multisig; +pub mod generate_key; +pub mod get_version; +pub mod get_wallet_info; +pub mod import_key; +pub mod import_multisig; +pub mod init_wallet_handle_token; +pub mod list_keys_in_wallet; +pub mod list_multisig; +pub mod list_wallets; +pub mod release_wallet_handle_token; +pub mod rename_wallet; +pub mod renew_wallet_handle_token; +pub mod sign_multisig_program; +pub mod sign_multisig_transaction; +pub mod sign_program; +pub mod sign_transaction; +pub mod swagger_handler; + +use snafu::Snafu; + +/// Unified error type that can represent any API error from any endpoint +#[derive(Debug, Snafu)] +pub enum KmdApiError { + #[snafu(display("Swagger_handler error: {error:?}"))] + SwaggerHandler { + error: swagger_handler::SwaggerHandlerError, + }, + #[snafu(display("Generate_key error: {error:?}"))] + GenerateKey { + error: generate_key::GenerateKeyError, + }, + #[snafu(display("Delete_key error: {error:?}"))] + DeleteKey { error: delete_key::DeleteKeyError }, + #[snafu(display("Export_key error: {error:?}"))] + ExportKey { error: export_key::ExportKeyError }, + #[snafu(display("Import_key error: {error:?}"))] + ImportKey { error: import_key::ImportKeyError }, + #[snafu(display("List_keys_in_wallet error: {error:?}"))] + ListKeysInWallet { + error: list_keys_in_wallet::ListKeysInWalletError, + }, + #[snafu(display("Export_master_key error: {error:?}"))] + ExportMasterKey { + error: export_master_key::ExportMasterKeyError, + }, + #[snafu(display("Delete_multisig error: {error:?}"))] + DeleteMultisig { + error: delete_multisig::DeleteMultisigError, + }, + #[snafu(display("Export_multisig error: {error:?}"))] + ExportMultisig { + error: export_multisig::ExportMultisigError, + }, + #[snafu(display("Import_multisig error: {error:?}"))] + ImportMultisig { + error: import_multisig::ImportMultisigError, + }, + #[snafu(display("List_multisig error: {error:?}"))] + ListMultisig { + error: list_multisig::ListMultisigError, + }, + #[snafu(display("Sign_multisig_transaction error: {error:?}"))] + SignMultisigTransaction { + error: sign_multisig_transaction::SignMultisigTransactionError, + }, + #[snafu(display("Sign_multisig_program error: {error:?}"))] + SignMultisigProgram { + error: sign_multisig_program::SignMultisigProgramError, + }, + #[snafu(display("Sign_program error: {error:?}"))] + SignProgram { + error: sign_program::SignProgramError, + }, + #[snafu(display("Sign_transaction error: {error:?}"))] + SignTransaction { + error: sign_transaction::SignTransactionError, + }, + #[snafu(display("Create_wallet error: {error:?}"))] + CreateWallet { + error: create_wallet::CreateWalletError, + }, + #[snafu(display("Get_wallet_info error: {error:?}"))] + GetWalletInfo { + error: get_wallet_info::GetWalletInfoError, + }, + #[snafu(display("Init_wallet_handle_token error: {error:?}"))] + InitWalletHandleToken { + error: init_wallet_handle_token::InitWalletHandleTokenError, + }, + #[snafu(display("Release_wallet_handle_token error: {error:?}"))] + ReleaseWalletHandleToken { + error: release_wallet_handle_token::ReleaseWalletHandleTokenError, + }, + #[snafu(display("Rename_wallet error: {error:?}"))] + RenameWallet { + error: rename_wallet::RenameWalletError, + }, + #[snafu(display("Renew_wallet_handle_token error: {error:?}"))] + RenewWalletHandleToken { + error: renew_wallet_handle_token::RenewWalletHandleTokenError, + }, + #[snafu(display("List_wallets error: {error:?}"))] + ListWallets { + error: list_wallets::ListWalletsError, + }, + #[snafu(display("Get_version error: {error:?}"))] + GetVersion { error: get_version::GetVersionError }, + #[snafu(display("Unknown API error: {message}"))] + Unknown { message: String }, +} + +impl From for KmdApiError { + fn from(err: swagger_handler::SwaggerHandlerError) -> Self { + KmdApiError::SwaggerHandler { error: err } + } +} + +impl From for KmdApiError { + fn from(err: generate_key::GenerateKeyError) -> Self { + KmdApiError::GenerateKey { error: err } + } +} + +impl From for KmdApiError { + fn from(err: delete_key::DeleteKeyError) -> Self { + KmdApiError::DeleteKey { error: err } + } +} + +impl From for KmdApiError { + fn from(err: export_key::ExportKeyError) -> Self { + KmdApiError::ExportKey { error: err } + } +} + +impl From for KmdApiError { + fn from(err: import_key::ImportKeyError) -> Self { + KmdApiError::ImportKey { error: err } + } +} + +impl From for KmdApiError { + fn from(err: list_keys_in_wallet::ListKeysInWalletError) -> Self { + KmdApiError::ListKeysInWallet { error: err } + } +} + +impl From for KmdApiError { + fn from(err: export_master_key::ExportMasterKeyError) -> Self { + KmdApiError::ExportMasterKey { error: err } + } +} + +impl From for KmdApiError { + fn from(err: delete_multisig::DeleteMultisigError) -> Self { + KmdApiError::DeleteMultisig { error: err } + } +} + +impl From for KmdApiError { + fn from(err: export_multisig::ExportMultisigError) -> Self { + KmdApiError::ExportMultisig { error: err } + } +} + +impl From for KmdApiError { + fn from(err: import_multisig::ImportMultisigError) -> Self { + KmdApiError::ImportMultisig { error: err } + } +} + +impl From for KmdApiError { + fn from(err: list_multisig::ListMultisigError) -> Self { + KmdApiError::ListMultisig { error: err } + } +} + +impl From for KmdApiError { + fn from(err: sign_multisig_transaction::SignMultisigTransactionError) -> Self { + KmdApiError::SignMultisigTransaction { error: err } + } +} + +impl From for KmdApiError { + fn from(err: sign_multisig_program::SignMultisigProgramError) -> Self { + KmdApiError::SignMultisigProgram { error: err } + } +} + +impl From for KmdApiError { + fn from(err: sign_program::SignProgramError) -> Self { + KmdApiError::SignProgram { error: err } + } +} + +impl From for KmdApiError { + fn from(err: sign_transaction::SignTransactionError) -> Self { + KmdApiError::SignTransaction { error: err } + } +} + +impl From for KmdApiError { + fn from(err: create_wallet::CreateWalletError) -> Self { + KmdApiError::CreateWallet { error: err } + } +} + +impl From for KmdApiError { + fn from(err: get_wallet_info::GetWalletInfoError) -> Self { + KmdApiError::GetWalletInfo { error: err } + } +} + +impl From for KmdApiError { + fn from(err: init_wallet_handle_token::InitWalletHandleTokenError) -> Self { + KmdApiError::InitWalletHandleToken { error: err } + } +} + +impl From for KmdApiError { + fn from(err: release_wallet_handle_token::ReleaseWalletHandleTokenError) -> Self { + KmdApiError::ReleaseWalletHandleToken { error: err } + } +} + +impl From for KmdApiError { + fn from(err: rename_wallet::RenameWalletError) -> Self { + KmdApiError::RenameWallet { error: err } + } +} + +impl From for KmdApiError { + fn from(err: renew_wallet_handle_token::RenewWalletHandleTokenError) -> Self { + KmdApiError::RenewWalletHandleToken { error: err } + } +} + +impl From for KmdApiError { + fn from(err: list_wallets::ListWalletsError) -> Self { + KmdApiError::ListWallets { error: err } + } +} + +impl From for KmdApiError { + fn from(err: get_version::GetVersionError) -> Self { + KmdApiError::GetVersion { error: err } + } +} + +/// The main error type for all kmd client operations +#[derive(Debug, Snafu)] +pub enum Error { + #[snafu(display("HTTP error: {source}"))] + Http { + source: algokit_http_client::HttpError, + }, + #[snafu(display("Serialization error: {message}"))] + Serde { message: String }, + #[snafu(display("API error: {source}"))] + Api { source: KmdApiError }, +} + +#[derive(Debug, PartialEq, Eq)] +pub enum ContentType { + Json, + MsgPack, + Text, + Unsupported(String), +} + +impl From<&str> for ContentType { + fn from(content_type: &str) -> Self { + if content_type.contains("application/json") { + ContentType::Json + } else if content_type.contains("application/msgpack") { + ContentType::MsgPack + } else if content_type.contains("text/plain") { + ContentType::Text + } else { + ContentType::Unsupported(content_type.to_string()) + } + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +// Re-export the consolidated client +pub use client::KmdClient; + +// Re-export all endpoint functions +pub use create_wallet::{CreateWalletError, create_wallet}; +pub use delete_key::{DeleteKeyError, delete_key}; +pub use delete_multisig::{DeleteMultisigError, delete_multisig}; +pub use export_key::{ExportKeyError, export_key}; +pub use export_master_key::{ExportMasterKeyError, export_master_key}; +pub use export_multisig::{ExportMultisigError, export_multisig}; +pub use generate_key::{GenerateKeyError, generate_key}; +pub use get_version::{GetVersionError, get_version}; +pub use get_wallet_info::{GetWalletInfoError, get_wallet_info}; +pub use import_key::{ImportKeyError, import_key}; +pub use import_multisig::{ImportMultisigError, import_multisig}; +pub use init_wallet_handle_token::{InitWalletHandleTokenError, init_wallet_handle_token}; +pub use list_keys_in_wallet::{ListKeysInWalletError, list_keys_in_wallet}; +pub use list_multisig::{ListMultisigError, list_multisig}; +pub use list_wallets::{ListWalletsError, list_wallets}; +pub use release_wallet_handle_token::{ReleaseWalletHandleTokenError, release_wallet_handle_token}; +pub use rename_wallet::{RenameWalletError, rename_wallet}; +pub use renew_wallet_handle_token::{RenewWalletHandleTokenError, renew_wallet_handle_token}; +pub use sign_multisig_program::{SignMultisigProgramError, sign_multisig_program}; +pub use sign_multisig_transaction::{SignMultisigTransactionError, sign_multisig_transaction}; +pub use sign_program::{SignProgramError, sign_program}; +pub use sign_transaction::{SignTransactionError, sign_transaction}; +pub use swagger_handler::{SwaggerHandlerError, swagger_handler}; diff --git a/crates/kmd_client/src/apis/release_wallet_handle_token.rs b/crates/kmd_client/src/apis/release_wallet_handle_token.rs new file mode 100644 index 000000000..e36dc548d --- /dev/null +++ b/crates/kmd_client/src/apis/release_wallet_handle_token.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostWalletReleaseResponse; + +// Import request body type if needed +use crate::models::ReleaseWalletHandleTokenRequest; + +/// struct for typed errors of method [`release_wallet_handle_token`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ReleaseWalletHandleTokenError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Invalidate the passed wallet handle token, making it invalid for use in subsequent requests. +pub async fn release_wallet_handle_token( + http_client: &dyn HttpClient, + request: ReleaseWalletHandleTokenRequest, +) -> Result { + let p_request = request; + + let path = "/v1/wallet/release".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/rename_wallet.rs b/crates/kmd_client/src/apis/rename_wallet.rs new file mode 100644 index 000000000..0ab837fb2 --- /dev/null +++ b/crates/kmd_client/src/apis/rename_wallet.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostWalletRenameResponse; + +// Import request body type if needed +use crate::models::RenameWalletRequest; + +/// struct for typed errors of method [`rename_wallet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RenameWalletError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Rename the underlying wallet to something else +pub async fn rename_wallet( + http_client: &dyn HttpClient, + request: RenameWalletRequest, +) -> Result { + let p_request = request; + + let path = "/v1/wallet/rename".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/renew_wallet_handle_token.rs b/crates/kmd_client/src/apis/renew_wallet_handle_token.rs new file mode 100644 index 000000000..f4ae044b6 --- /dev/null +++ b/crates/kmd_client/src/apis/renew_wallet_handle_token.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostWalletRenewResponse; + +// Import request body type if needed +use crate::models::RenewWalletHandleTokenRequest; + +/// struct for typed errors of method [`renew_wallet_handle_token`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RenewWalletHandleTokenError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Renew a wallet handle token, increasing its expiration duration to its initial value +pub async fn renew_wallet_handle_token( + http_client: &dyn HttpClient, + request: RenewWalletHandleTokenRequest, +) -> Result { + let p_request = request; + + let path = "/v1/wallet/renew".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/sign_multisig_program.rs b/crates/kmd_client/src/apis/sign_multisig_program.rs new file mode 100644 index 000000000..607032d2b --- /dev/null +++ b/crates/kmd_client/src/apis/sign_multisig_program.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostMultisigProgramSignResponse; + +// Import request body type if needed +use crate::models::SignProgramMultisigRequest; + +/// struct for typed errors of method [`sign_multisig_program`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SignMultisigProgramError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Start a multisig signature, or add a signature to a partially completed multisig signature object. +pub async fn sign_multisig_program( + http_client: &dyn HttpClient, + request: SignProgramMultisigRequest, +) -> Result { + let p_request = request; + + let path = "/v1/multisig/signprogram".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/sign_multisig_transaction.rs b/crates/kmd_client/src/apis/sign_multisig_transaction.rs new file mode 100644 index 000000000..c8235656a --- /dev/null +++ b/crates/kmd_client/src/apis/sign_multisig_transaction.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostMultisigTransactionSignResponse; + +// Import request body type if needed +use crate::models::SignMultisigRequest; + +/// struct for typed errors of method [`sign_multisig_transaction`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SignMultisigTransactionError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Start a multisig signature, or add a signature to a partially completed multisig signature object. +pub async fn sign_multisig_transaction( + http_client: &dyn HttpClient, + request: SignMultisigRequest, +) -> Result { + let p_request = request; + + let path = "/v1/multisig/sign".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/sign_program.rs b/crates/kmd_client/src/apis/sign_program.rs new file mode 100644 index 000000000..1ae2c91b2 --- /dev/null +++ b/crates/kmd_client/src/apis/sign_program.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostProgramSignResponse; + +// Import request body type if needed +use crate::models::SignProgramRequest; + +/// struct for typed errors of method [`sign_program`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SignProgramError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Signs the passed program with a key from the wallet, determined by the account named in the request. +pub async fn sign_program( + http_client: &dyn HttpClient, + request: SignProgramRequest, +) -> Result { + let p_request = request; + + let path = "/v1/program/sign".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/sign_transaction.rs b/crates/kmd_client/src/apis/sign_transaction.rs new file mode 100644 index 000000000..da4d9a37e --- /dev/null +++ b/crates/kmd_client/src/apis/sign_transaction.rs @@ -0,0 +1,86 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint +use crate::models::Apiv1PostTransactionSignResponse; + +// Import request body type if needed +use crate::models::SignTransactionRequest; + +/// struct for typed errors of method [`sign_transaction`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SignTransactionError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Signs the passed transaction with a key from the wallet, determined by the sender encoded in the transaction. +pub async fn sign_transaction( + http_client: &dyn HttpClient, + request: SignTransactionRequest, +) -> Result { + let p_request = request; + + let path = "/v1/transaction/sign".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Content-Type".to_string(), "application/json".to_string()); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = Some(serde_json::to_vec(&p_request).map_err(|e| Error::Serde { + message: e.to_string(), + })?); + + let response = http_client + .request( + HttpMethod::Post, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + let content_type = response + .headers + .get("content-type") + .map(|s| s.as_str()) + .unwrap_or("application/json"); + + match ContentType::from(content_type) { + ContentType::Json => serde_json::from_slice(&response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }), + ContentType::MsgPack => Err(Error::Serde { + message: "MsgPack not supported".to_string(), + }), + ContentType::Text => { + let text = String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + })?; + Err(Error::Serde { + message: format!("Unexpected text response: {}", text), + }) + } + ContentType::Unsupported(ct) => Err(Error::Serde { + message: format!("Unsupported content type: {}", ct), + }), + } +} diff --git a/crates/kmd_client/src/apis/swagger_handler.rs b/crates/kmd_client/src/apis/swagger_handler.rs new file mode 100644 index 000000000..d426951e3 --- /dev/null +++ b/crates/kmd_client/src/apis/swagger_handler.rs @@ -0,0 +1,55 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use algokit_http_client::{HttpClient, HttpMethod}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use super::{ContentType, Error, KmdApiError}; + +// Import all custom types used by this endpoint + +// Import request body type if needed + +/// struct for typed errors of method [`swagger_handler`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SwaggerHandlerError { + Statusdefault(), + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// Returns the entire swagger spec in json. +pub async fn swagger_handler(http_client: &dyn HttpClient) -> Result { + let path = "/swagger.json".to_string(); + + let query_params: HashMap = HashMap::new(); + + let mut headers: HashMap = HashMap::new(); + headers.insert("Accept".to_string(), "application/json".to_string()); + + let body = None; + + let response = http_client + .request( + HttpMethod::Get, + path, + Some(query_params), + body, + Some(headers), + ) + .await + .map_err(|e| Error::Http { source: e })?; + + String::from_utf8(response.body).map_err(|e| Error::Serde { + message: e.to_string(), + }) +} diff --git a/crates/kmd_client/src/lib.rs b/crates/kmd_client/src/lib.rs new file mode 100644 index 000000000..468c2150c --- /dev/null +++ b/crates/kmd_client/src/lib.rs @@ -0,0 +1,8 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +pub mod apis; +pub mod models; + +// Re-export the main client for convenience +pub use apis::KmdClient; diff --git a/crates/kmd_client/src/models/apiv1_delete_key_response.rs b/crates/kmd_client/src/models/apiv1_delete_key_response.rs new file mode 100644 index 000000000..8475e3d54 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_delete_key_response.rs @@ -0,0 +1,29 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1DELETEKeyResponse is the response to `DELETE /v1/key` +/// friendly:DeleteKeyResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1DeleteKeyResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1DeleteKeyResponse { + /// Default constructor for Apiv1DeleteKeyResponse + pub fn new() -> Apiv1DeleteKeyResponse { + Apiv1DeleteKeyResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_delete_multisig_response.rs b/crates/kmd_client/src/models/apiv1_delete_multisig_response.rs new file mode 100644 index 000000000..f8a05f2a8 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_delete_multisig_response.rs @@ -0,0 +1,29 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1DELETEMultisigResponse is the response to POST /v1/multisig/delete` +/// friendly:DeleteMultisigResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1DeleteMultisigResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1DeleteMultisigResponse { + /// Default constructor for Apiv1DeleteMultisigResponse + pub fn new() -> Apiv1DeleteMultisigResponse { + Apiv1DeleteMultisigResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_get_wallets_response.rs b/crates/kmd_client/src/models/apiv1_get_wallets_response.rs new file mode 100644 index 000000000..23c7e1ee4 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_get_wallets_response.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::Apiv1Wallet; + +/// APIV1GETWalletsResponse is the response to `GET /v1/wallets` +/// friendly:ListWalletsResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1GetWalletsResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(rename = "wallets", skip_serializing_if = "Option::is_none")] + pub wallets: Option>, +} + +impl Apiv1GetWalletsResponse { + /// Default constructor for Apiv1GetWalletsResponse + pub fn new() -> Apiv1GetWalletsResponse { + Apiv1GetWalletsResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_key_export_response.rs b/crates/kmd_client/src/models/apiv1_post_key_export_response.rs new file mode 100644 index 000000000..c72c19403 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_key_export_response.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::PrivateKey; + +/// APIV1POSTKeyExportResponse is the response to `POST /v1/key/export` +/// friendly:ExportKeyResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostKeyExportResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(rename = "private_key", skip_serializing_if = "Option::is_none")] + pub private_key: Option, +} + +impl Apiv1PostKeyExportResponse { + /// Default constructor for Apiv1PostKeyExportResponse + pub fn new() -> Apiv1PostKeyExportResponse { + Apiv1PostKeyExportResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_key_import_response.rs b/crates/kmd_client/src/models/apiv1_post_key_import_response.rs new file mode 100644 index 000000000..3579a3964 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_key_import_response.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTKeyImportResponse is the response to `POST /v1/key/import` +/// friendly:ImportKeyResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostKeyImportResponse { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1PostKeyImportResponse { + /// Default constructor for Apiv1PostKeyImportResponse + pub fn new() -> Apiv1PostKeyImportResponse { + Apiv1PostKeyImportResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_key_list_response.rs b/crates/kmd_client/src/models/apiv1_post_key_list_response.rs new file mode 100644 index 000000000..daae366d0 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_key_list_response.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTKeyListResponse is the response to `POST /v1/key/list` +/// friendly:ListKeysResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostKeyListResponse { + #[serde(rename = "addresses", skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1PostKeyListResponse { + /// Default constructor for Apiv1PostKeyListResponse + pub fn new() -> Apiv1PostKeyListResponse { + Apiv1PostKeyListResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_key_response.rs b/crates/kmd_client/src/models/apiv1_post_key_response.rs new file mode 100644 index 000000000..7360413c4 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_key_response.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTKeyResponse is the response to `POST /v1/key` +/// friendly:GenerateKeyResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostKeyResponse { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1PostKeyResponse { + /// Default constructor for Apiv1PostKeyResponse + pub fn new() -> Apiv1PostKeyResponse { + Apiv1PostKeyResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_master_key_export_response.rs b/crates/kmd_client/src/models/apiv1_post_master_key_export_response.rs new file mode 100644 index 000000000..dd4617dbc --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_master_key_export_response.rs @@ -0,0 +1,36 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::MasterDerivationKey; + +/// APIV1POSTMasterKeyExportResponse is the response to `POST /v1/master-key/export` +/// friendly:ExportMasterKeyResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostMasterKeyExportResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde( + rename = "master_derivation_key", + skip_serializing_if = "Option::is_none" + )] + pub master_derivation_key: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1PostMasterKeyExportResponse { + /// Default constructor for Apiv1PostMasterKeyExportResponse + pub fn new() -> Apiv1PostMasterKeyExportResponse { + Apiv1PostMasterKeyExportResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_multisig_export_response.rs b/crates/kmd_client/src/models/apiv1_post_multisig_export_response.rs new file mode 100644 index 000000000..19ba00fa8 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_multisig_export_response.rs @@ -0,0 +1,37 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::PublicKey; + +/// APIV1POSTMultisigExportResponse is the response to `POST /v1/multisig/export` +/// friendly:ExportMultisigResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostMultisigExportResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(rename = "multisig_version", skip_serializing_if = "Option::is_none")] + pub multisig_version: Option, + #[serde(rename = "pks", skip_serializing_if = "Option::is_none")] + pub pks: Option>, + #[serde(rename = "threshold", skip_serializing_if = "Option::is_none")] + pub threshold: Option, +} + +impl Apiv1PostMultisigExportResponse { + /// Default constructor for Apiv1PostMultisigExportResponse + pub fn new() -> Apiv1PostMultisigExportResponse { + Apiv1PostMultisigExportResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_multisig_import_response.rs b/crates/kmd_client/src/models/apiv1_post_multisig_import_response.rs new file mode 100644 index 000000000..a22a00d6e --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_multisig_import_response.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTMultisigImportResponse is the response to `POST /v1/multisig/import` +/// friendly:ImportMultisigResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostMultisigImportResponse { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1PostMultisigImportResponse { + /// Default constructor for Apiv1PostMultisigImportResponse + pub fn new() -> Apiv1PostMultisigImportResponse { + Apiv1PostMultisigImportResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_multisig_list_response.rs b/crates/kmd_client/src/models/apiv1_post_multisig_list_response.rs new file mode 100644 index 000000000..8d6af4b51 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_multisig_list_response.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTMultisigListResponse is the response to `POST /v1/multisig/list` +/// friendly:ListMultisigResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostMultisigListResponse { + #[serde(rename = "addresses", skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1PostMultisigListResponse { + /// Default constructor for Apiv1PostMultisigListResponse + pub fn new() -> Apiv1PostMultisigListResponse { + Apiv1PostMultisigListResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_multisig_program_sign_response.rs b/crates/kmd_client/src/models/apiv1_post_multisig_program_sign_response.rs new file mode 100644 index 000000000..6dca2395d --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_multisig_program_sign_response.rs @@ -0,0 +1,34 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use serde_with::{Bytes, serde_as}; + +/// APIV1POSTMultisigProgramSignResponse is the response to `POST /v1/multisig/signdata` +/// friendly:SignProgramMultisigResponse +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostMultisigProgramSignResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde_as(as = "Option")] + #[serde(rename = "multisig", skip_serializing_if = "Option::is_none")] + pub multisig: Option>, +} + +impl Apiv1PostMultisigProgramSignResponse { + /// Default constructor for Apiv1PostMultisigProgramSignResponse + pub fn new() -> Apiv1PostMultisigProgramSignResponse { + Apiv1PostMultisigProgramSignResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_multisig_transaction_sign_response.rs b/crates/kmd_client/src/models/apiv1_post_multisig_transaction_sign_response.rs new file mode 100644 index 000000000..51814e8ae --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_multisig_transaction_sign_response.rs @@ -0,0 +1,34 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use serde_with::{Bytes, serde_as}; + +/// APIV1POSTMultisigTransactionSignResponse is the response to `POST /v1/multisig/sign` +/// friendly:SignMultisigResponse +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostMultisigTransactionSignResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde_as(as = "Option")] + #[serde(rename = "multisig", skip_serializing_if = "Option::is_none")] + pub multisig: Option>, +} + +impl Apiv1PostMultisigTransactionSignResponse { + /// Default constructor for Apiv1PostMultisigTransactionSignResponse + pub fn new() -> Apiv1PostMultisigTransactionSignResponse { + Apiv1PostMultisigTransactionSignResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_program_sign_response.rs b/crates/kmd_client/src/models/apiv1_post_program_sign_response.rs new file mode 100644 index 000000000..25fcf6fa1 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_program_sign_response.rs @@ -0,0 +1,34 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use serde_with::{Bytes, serde_as}; + +/// APIV1POSTProgramSignResponse is the response to `POST /v1/data/sign` +/// friendly:SignProgramResponse +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostProgramSignResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde_as(as = "Option")] + #[serde(rename = "sig", skip_serializing_if = "Option::is_none")] + pub sig: Option>, +} + +impl Apiv1PostProgramSignResponse { + /// Default constructor for Apiv1PostProgramSignResponse + pub fn new() -> Apiv1PostProgramSignResponse { + Apiv1PostProgramSignResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_transaction_sign_response.rs b/crates/kmd_client/src/models/apiv1_post_transaction_sign_response.rs new file mode 100644 index 000000000..a9e01d854 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_transaction_sign_response.rs @@ -0,0 +1,34 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use serde_with::{Bytes, serde_as}; + +/// APIV1POSTTransactionSignResponse is the response to `POST /v1/transaction/sign` +/// friendly:SignTransactionResponse +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostTransactionSignResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde_as(as = "Option")] + #[serde(rename = "signed_transaction", skip_serializing_if = "Option::is_none")] + pub signed_transaction: Option>, +} + +impl Apiv1PostTransactionSignResponse { + /// Default constructor for Apiv1PostTransactionSignResponse + pub fn new() -> Apiv1PostTransactionSignResponse { + Apiv1PostTransactionSignResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_wallet_info_response.rs b/crates/kmd_client/src/models/apiv1_post_wallet_info_response.rs new file mode 100644 index 000000000..a2020b9f3 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_wallet_info_response.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::Apiv1WalletHandle; + +/// APIV1POSTWalletInfoResponse is the response to `POST /v1/wallet/info` +/// friendly:WalletInfoResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostWalletInfoResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(rename = "wallet_handle", skip_serializing_if = "Option::is_none")] + pub wallet_handle: Option, +} + +impl Apiv1PostWalletInfoResponse { + /// Default constructor for Apiv1PostWalletInfoResponse + pub fn new() -> Apiv1PostWalletInfoResponse { + Apiv1PostWalletInfoResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_wallet_init_response.rs b/crates/kmd_client/src/models/apiv1_post_wallet_init_response.rs new file mode 100644 index 000000000..68b481862 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_wallet_init_response.rs @@ -0,0 +1,34 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTWalletInitResponse is the response to `POST /v1/wallet/init` +/// friendly:InitWalletHandleTokenResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostWalletInitResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl Apiv1PostWalletInitResponse { + /// Default constructor for Apiv1PostWalletInitResponse + pub fn new() -> Apiv1PostWalletInitResponse { + Apiv1PostWalletInitResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_wallet_release_response.rs b/crates/kmd_client/src/models/apiv1_post_wallet_release_response.rs new file mode 100644 index 000000000..a88c7d510 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_wallet_release_response.rs @@ -0,0 +1,29 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTWalletReleaseResponse is the response to `POST /v1/wallet/release` +/// friendly:ReleaseWalletHandleTokenResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostWalletReleaseResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl Apiv1PostWalletReleaseResponse { + /// Default constructor for Apiv1PostWalletReleaseResponse + pub fn new() -> Apiv1PostWalletReleaseResponse { + Apiv1PostWalletReleaseResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_wallet_rename_response.rs b/crates/kmd_client/src/models/apiv1_post_wallet_rename_response.rs new file mode 100644 index 000000000..36226ae38 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_wallet_rename_response.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::Apiv1Wallet; + +/// APIV1POSTWalletRenameResponse is the response to `POST /v1/wallet/rename` +/// friendly:RenameWalletResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostWalletRenameResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(rename = "wallet", skip_serializing_if = "Option::is_none")] + pub wallet: Option, +} + +impl Apiv1PostWalletRenameResponse { + /// Default constructor for Apiv1PostWalletRenameResponse + pub fn new() -> Apiv1PostWalletRenameResponse { + Apiv1PostWalletRenameResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_wallet_renew_response.rs b/crates/kmd_client/src/models/apiv1_post_wallet_renew_response.rs new file mode 100644 index 000000000..6c7a989bc --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_wallet_renew_response.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::Apiv1WalletHandle; + +/// APIV1POSTWalletRenewResponse is the response to `POST /v1/wallet/renew` +/// friendly:RenewWalletHandleTokenResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostWalletRenewResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(rename = "wallet_handle", skip_serializing_if = "Option::is_none")] + pub wallet_handle: Option, +} + +impl Apiv1PostWalletRenewResponse { + /// Default constructor for Apiv1PostWalletRenewResponse + pub fn new() -> Apiv1PostWalletRenewResponse { + Apiv1PostWalletRenewResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_post_wallet_response.rs b/crates/kmd_client/src/models/apiv1_post_wallet_response.rs new file mode 100644 index 000000000..64b7568e6 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_post_wallet_response.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::Apiv1Wallet; + +/// APIV1POSTWalletResponse is the response to `POST /v1/wallet` +/// friendly:CreateWalletResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1PostWalletResponse { + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(rename = "wallet", skip_serializing_if = "Option::is_none")] + pub wallet: Option, +} + +impl Apiv1PostWalletResponse { + /// Default constructor for Apiv1PostWalletResponse + pub fn new() -> Apiv1PostWalletResponse { + Apiv1PostWalletResponse::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_wallet.rs b/crates/kmd_client/src/models/apiv1_wallet.rs new file mode 100644 index 000000000..a24c0d8b7 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_wallet.rs @@ -0,0 +1,38 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::TxType; + +/// APIV1Wallet is the API's representation of a wallet +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1Wallet { + #[serde(rename = "driver_name", skip_serializing_if = "Option::is_none")] + pub driver_name: Option, + #[serde(rename = "driver_version", skip_serializing_if = "Option::is_none")] + pub driver_version: Option, + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "mnemonic_ux", skip_serializing_if = "Option::is_none")] + pub mnemonic_ux: Option, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(rename = "supported_txs", skip_serializing_if = "Option::is_none")] + pub supported_txs: Option>, +} + +impl Apiv1Wallet { + /// Default constructor for Apiv1Wallet + pub fn new() -> Apiv1Wallet { + Apiv1Wallet::default() + } +} diff --git a/crates/kmd_client/src/models/apiv1_wallet_handle.rs b/crates/kmd_client/src/models/apiv1_wallet_handle.rs new file mode 100644 index 000000000..b652df482 --- /dev/null +++ b/crates/kmd_client/src/models/apiv1_wallet_handle.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::Apiv1Wallet; + +/// APIV1WalletHandle includes the wallet the handle corresponds to +/// and the number of number of seconds to expiration +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Apiv1WalletHandle { + #[serde(rename = "expires_seconds", skip_serializing_if = "Option::is_none")] + pub expires_seconds: Option, + #[serde(rename = "wallet", skip_serializing_if = "Option::is_none")] + pub wallet: Option, +} + +impl Apiv1WalletHandle { + /// Default constructor for Apiv1WalletHandle + pub fn new() -> Apiv1WalletHandle { + Apiv1WalletHandle::default() + } +} diff --git a/crates/kmd_client/src/models/create_wallet_request.rs b/crates/kmd_client/src/models/create_wallet_request.rs new file mode 100644 index 000000000..8333a1951 --- /dev/null +++ b/crates/kmd_client/src/models/create_wallet_request.rs @@ -0,0 +1,37 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::MasterDerivationKey; + +/// APIV1POSTWalletRequest is the request for `POST /v1/wallet` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateWalletRequest { + #[serde( + rename = "master_derivation_key", + skip_serializing_if = "Option::is_none" + )] + pub master_derivation_key: Option, + #[serde(rename = "wallet_driver_name", skip_serializing_if = "Option::is_none")] + pub wallet_driver_name: Option, + #[serde(rename = "wallet_name", skip_serializing_if = "Option::is_none")] + pub wallet_name: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl CreateWalletRequest { + /// Default constructor for CreateWalletRequest + pub fn new() -> CreateWalletRequest { + CreateWalletRequest::default() + } +} diff --git a/crates/kmd_client/src/models/delete_key_request.rs b/crates/kmd_client/src/models/delete_key_request.rs new file mode 100644 index 000000000..6df09beaa --- /dev/null +++ b/crates/kmd_client/src/models/delete_key_request.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1DELETEKeyRequest is the request for `DELETE /v1/key` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DeleteKeyRequest { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl DeleteKeyRequest { + /// Default constructor for DeleteKeyRequest + pub fn new() -> DeleteKeyRequest { + DeleteKeyRequest::default() + } +} diff --git a/crates/kmd_client/src/models/delete_multisig_request.rs b/crates/kmd_client/src/models/delete_multisig_request.rs new file mode 100644 index 000000000..f5cd8dd31 --- /dev/null +++ b/crates/kmd_client/src/models/delete_multisig_request.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1DELETEMultisigRequest is the request for `DELETE /v1/multisig` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DeleteMultisigRequest { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl DeleteMultisigRequest { + /// Default constructor for DeleteMultisigRequest + pub fn new() -> DeleteMultisigRequest { + DeleteMultisigRequest::default() + } +} diff --git a/crates/kmd_client/src/models/digest.rs b/crates/kmd_client/src/models/digest.rs new file mode 100644 index 000000000..fd84fe173 --- /dev/null +++ b/crates/kmd_client/src/models/digest.rs @@ -0,0 +1,14 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +pub type Digest = Vec; diff --git a/crates/kmd_client/src/models/ed25519_private_key.rs b/crates/kmd_client/src/models/ed25519_private_key.rs new file mode 100644 index 000000000..c0454d405 --- /dev/null +++ b/crates/kmd_client/src/models/ed25519_private_key.rs @@ -0,0 +1,14 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +pub type Ed25519PrivateKey = Vec; diff --git a/crates/kmd_client/src/models/ed25519_public_key.rs b/crates/kmd_client/src/models/ed25519_public_key.rs new file mode 100644 index 000000000..1ee248215 --- /dev/null +++ b/crates/kmd_client/src/models/ed25519_public_key.rs @@ -0,0 +1,14 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +pub type Ed25519PublicKey = Vec; diff --git a/crates/kmd_client/src/models/ed25519_signature.rs b/crates/kmd_client/src/models/ed25519_signature.rs new file mode 100644 index 000000000..525b77426 --- /dev/null +++ b/crates/kmd_client/src/models/ed25519_signature.rs @@ -0,0 +1,14 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +pub type Ed25519Signature = Vec; diff --git a/crates/kmd_client/src/models/export_key_request.rs b/crates/kmd_client/src/models/export_key_request.rs new file mode 100644 index 000000000..352d9bd3f --- /dev/null +++ b/crates/kmd_client/src/models/export_key_request.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTKeyExportRequest is the request for `POST /v1/key/export` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ExportKeyRequest { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl ExportKeyRequest { + /// Default constructor for ExportKeyRequest + pub fn new() -> ExportKeyRequest { + ExportKeyRequest::default() + } +} diff --git a/crates/kmd_client/src/models/export_master_key_request.rs b/crates/kmd_client/src/models/export_master_key_request.rs new file mode 100644 index 000000000..d93d301cc --- /dev/null +++ b/crates/kmd_client/src/models/export_master_key_request.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTMasterKeyExportRequest is the request for `POST /v1/master-key/export` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ExportMasterKeyRequest { + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl ExportMasterKeyRequest { + /// Default constructor for ExportMasterKeyRequest + pub fn new() -> ExportMasterKeyRequest { + ExportMasterKeyRequest::default() + } +} diff --git a/crates/kmd_client/src/models/export_multisig_request.rs b/crates/kmd_client/src/models/export_multisig_request.rs new file mode 100644 index 000000000..c64222799 --- /dev/null +++ b/crates/kmd_client/src/models/export_multisig_request.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTMultisigExportRequest is the request for `POST /v1/multisig/export` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ExportMultisigRequest { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl ExportMultisigRequest { + /// Default constructor for ExportMultisigRequest + pub fn new() -> ExportMultisigRequest { + ExportMultisigRequest::default() + } +} diff --git a/crates/kmd_client/src/models/generate_key_request.rs b/crates/kmd_client/src/models/generate_key_request.rs new file mode 100644 index 000000000..f3f45cb50 --- /dev/null +++ b/crates/kmd_client/src/models/generate_key_request.rs @@ -0,0 +1,31 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTKeyRequest is the request for `POST /v1/key` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GenerateKeyRequest { + #[serde(rename = "display_mnemonic", skip_serializing_if = "Option::is_none")] + pub display_mnemonic: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl GenerateKeyRequest { + /// Default constructor for GenerateKeyRequest + pub fn new() -> GenerateKeyRequest { + GenerateKeyRequest::default() + } +} diff --git a/crates/kmd_client/src/models/import_key_request.rs b/crates/kmd_client/src/models/import_key_request.rs new file mode 100644 index 000000000..b1bd20390 --- /dev/null +++ b/crates/kmd_client/src/models/import_key_request.rs @@ -0,0 +1,33 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::PrivateKey; + +/// APIV1POSTKeyImportRequest is the request for `POST /v1/key/import` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ImportKeyRequest { + #[serde(rename = "private_key", skip_serializing_if = "Option::is_none")] + pub private_key: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl ImportKeyRequest { + /// Default constructor for ImportKeyRequest + pub fn new() -> ImportKeyRequest { + ImportKeyRequest::default() + } +} diff --git a/crates/kmd_client/src/models/import_multisig_request.rs b/crates/kmd_client/src/models/import_multisig_request.rs new file mode 100644 index 000000000..3a720fa64 --- /dev/null +++ b/crates/kmd_client/src/models/import_multisig_request.rs @@ -0,0 +1,37 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::PublicKey; + +/// APIV1POSTMultisigImportRequest is the request for `POST /v1/multisig/import` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ImportMultisigRequest { + #[serde(rename = "multisig_version", skip_serializing_if = "Option::is_none")] + pub multisig_version: Option, + #[serde(rename = "pks", skip_serializing_if = "Option::is_none")] + pub pks: Option>, + #[serde(rename = "threshold", skip_serializing_if = "Option::is_none")] + pub threshold: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl ImportMultisigRequest { + /// Default constructor for ImportMultisigRequest + pub fn new() -> ImportMultisigRequest { + ImportMultisigRequest::default() + } +} diff --git a/crates/kmd_client/src/models/init_wallet_handle_token_request.rs b/crates/kmd_client/src/models/init_wallet_handle_token_request.rs new file mode 100644 index 000000000..2a4fc949b --- /dev/null +++ b/crates/kmd_client/src/models/init_wallet_handle_token_request.rs @@ -0,0 +1,28 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTWalletInitRequest is the request for `POST /v1/wallet/init` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct InitWalletHandleTokenRequest { + #[serde(rename = "wallet_id", skip_serializing_if = "Option::is_none")] + pub wallet_id: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl InitWalletHandleTokenRequest { + /// Default constructor for InitWalletHandleTokenRequest + pub fn new() -> InitWalletHandleTokenRequest { + InitWalletHandleTokenRequest::default() + } +} diff --git a/crates/kmd_client/src/models/list_keys_request.rs b/crates/kmd_client/src/models/list_keys_request.rs new file mode 100644 index 000000000..84e0b734c --- /dev/null +++ b/crates/kmd_client/src/models/list_keys_request.rs @@ -0,0 +1,29 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTKeyListRequest is the request for `POST /v1/key/list` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ListKeysRequest { + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl ListKeysRequest { + /// Default constructor for ListKeysRequest + pub fn new() -> ListKeysRequest { + ListKeysRequest::default() + } +} diff --git a/crates/kmd_client/src/models/list_multisig_request.rs b/crates/kmd_client/src/models/list_multisig_request.rs new file mode 100644 index 000000000..b3e8c5dfa --- /dev/null +++ b/crates/kmd_client/src/models/list_multisig_request.rs @@ -0,0 +1,29 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTMultisigListRequest is the request for `POST /v1/multisig/list` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ListMultisigRequest { + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl ListMultisigRequest { + /// Default constructor for ListMultisigRequest + pub fn new() -> ListMultisigRequest { + ListMultisigRequest::default() + } +} diff --git a/crates/kmd_client/src/models/list_wallets_request.rs b/crates/kmd_client/src/models/list_wallets_request.rs new file mode 100644 index 000000000..89c8469e5 --- /dev/null +++ b/crates/kmd_client/src/models/list_wallets_request.rs @@ -0,0 +1,23 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1GETWalletsRequest is the request for `GET /v1/wallets` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ListWalletsRequest {} + +impl ListWalletsRequest { + /// Default constructor for ListWalletsRequest + pub fn new() -> ListWalletsRequest { + ListWalletsRequest::default() + } +} diff --git a/crates/kmd_client/src/models/master_derivation_key.rs b/crates/kmd_client/src/models/master_derivation_key.rs new file mode 100644 index 000000000..ab3b5cbc5 --- /dev/null +++ b/crates/kmd_client/src/models/master_derivation_key.rs @@ -0,0 +1,15 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// MasterDerivationKey is used to derive ed25519 keys for use in wallets +pub type MasterDerivationKey = Vec; diff --git a/crates/kmd_client/src/models/mod.rs b/crates/kmd_client/src/models/mod.rs new file mode 100644 index 000000000..b993ac847 --- /dev/null +++ b/crates/kmd_client/src/models/mod.rs @@ -0,0 +1,124 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +pub mod apiv1_delete_key_response; +pub use self::apiv1_delete_key_response::Apiv1DeleteKeyResponse; +pub mod apiv1_delete_multisig_response; +pub use self::apiv1_delete_multisig_response::Apiv1DeleteMultisigResponse; +pub mod apiv1_get_wallets_response; +pub use self::apiv1_get_wallets_response::Apiv1GetWalletsResponse; +pub mod apiv1_post_key_export_response; +pub use self::apiv1_post_key_export_response::Apiv1PostKeyExportResponse; +pub mod apiv1_post_key_import_response; +pub use self::apiv1_post_key_import_response::Apiv1PostKeyImportResponse; +pub mod apiv1_post_key_list_response; +pub use self::apiv1_post_key_list_response::Apiv1PostKeyListResponse; +pub mod apiv1_post_key_response; +pub use self::apiv1_post_key_response::Apiv1PostKeyResponse; +pub mod apiv1_post_master_key_export_response; +pub use self::apiv1_post_master_key_export_response::Apiv1PostMasterKeyExportResponse; +pub mod apiv1_post_multisig_export_response; +pub use self::apiv1_post_multisig_export_response::Apiv1PostMultisigExportResponse; +pub mod apiv1_post_multisig_import_response; +pub use self::apiv1_post_multisig_import_response::Apiv1PostMultisigImportResponse; +pub mod apiv1_post_multisig_list_response; +pub use self::apiv1_post_multisig_list_response::Apiv1PostMultisigListResponse; +pub mod apiv1_post_multisig_program_sign_response; +pub use self::apiv1_post_multisig_program_sign_response::Apiv1PostMultisigProgramSignResponse; +pub mod apiv1_post_multisig_transaction_sign_response; +pub use self::apiv1_post_multisig_transaction_sign_response::Apiv1PostMultisigTransactionSignResponse; +pub mod apiv1_post_program_sign_response; +pub use self::apiv1_post_program_sign_response::Apiv1PostProgramSignResponse; +pub mod apiv1_post_transaction_sign_response; +pub use self::apiv1_post_transaction_sign_response::Apiv1PostTransactionSignResponse; +pub mod apiv1_post_wallet_info_response; +pub use self::apiv1_post_wallet_info_response::Apiv1PostWalletInfoResponse; +pub mod apiv1_post_wallet_init_response; +pub use self::apiv1_post_wallet_init_response::Apiv1PostWalletInitResponse; +pub mod apiv1_post_wallet_release_response; +pub use self::apiv1_post_wallet_release_response::Apiv1PostWalletReleaseResponse; +pub mod apiv1_post_wallet_rename_response; +pub use self::apiv1_post_wallet_rename_response::Apiv1PostWalletRenameResponse; +pub mod apiv1_post_wallet_renew_response; +pub use self::apiv1_post_wallet_renew_response::Apiv1PostWalletRenewResponse; +pub mod apiv1_post_wallet_response; +pub use self::apiv1_post_wallet_response::Apiv1PostWalletResponse; +pub mod apiv1_wallet; +pub use self::apiv1_wallet::Apiv1Wallet; +pub mod apiv1_wallet_handle; +pub use self::apiv1_wallet_handle::Apiv1WalletHandle; +pub mod create_wallet_request; +pub use self::create_wallet_request::CreateWalletRequest; +pub mod delete_key_request; +pub use self::delete_key_request::DeleteKeyRequest; +pub mod delete_multisig_request; +pub use self::delete_multisig_request::DeleteMultisigRequest; +pub mod digest; +pub use self::digest::Digest; +pub mod export_key_request; +pub use self::export_key_request::ExportKeyRequest; +pub mod export_master_key_request; +pub use self::export_master_key_request::ExportMasterKeyRequest; +pub mod export_multisig_request; +pub use self::export_multisig_request::ExportMultisigRequest; +pub mod generate_key_request; +pub use self::generate_key_request::GenerateKeyRequest; +pub mod import_key_request; +pub use self::import_key_request::ImportKeyRequest; +pub mod import_multisig_request; +pub use self::import_multisig_request::ImportMultisigRequest; +pub mod init_wallet_handle_token_request; +pub use self::init_wallet_handle_token_request::InitWalletHandleTokenRequest; +pub mod list_keys_request; +pub use self::list_keys_request::ListKeysRequest; +pub mod list_multisig_request; +pub use self::list_multisig_request::ListMultisigRequest; +pub mod list_wallets_request; +pub use self::list_wallets_request::ListWalletsRequest; +pub mod master_derivation_key; +pub use self::master_derivation_key::MasterDerivationKey; +pub mod multisig_sig; +pub use self::multisig_sig::MultisigSig; +pub mod multisig_subsig; +pub use self::multisig_subsig::MultisigSubsig; +pub mod private_key; +pub use self::private_key::PrivateKey; +pub mod public_key; +pub use self::public_key::PublicKey; +pub mod release_wallet_handle_token_request; +pub use self::release_wallet_handle_token_request::ReleaseWalletHandleTokenRequest; +pub mod rename_wallet_request; +pub use self::rename_wallet_request::RenameWalletRequest; +pub mod renew_wallet_handle_token_request; +pub use self::renew_wallet_handle_token_request::RenewWalletHandleTokenRequest; +pub mod sign_multisig_request; +pub use self::sign_multisig_request::SignMultisigRequest; +pub mod sign_program_multisig_request; +pub use self::sign_program_multisig_request::SignProgramMultisigRequest; +pub mod sign_program_request; +pub use self::sign_program_request::SignProgramRequest; +pub mod sign_transaction_request; +pub use self::sign_transaction_request::SignTransactionRequest; +pub mod signature; +pub use self::signature::Signature; +pub mod tx_type; +pub use self::tx_type::TxType; +pub mod versions_request; +pub use self::versions_request::VersionsRequest; +pub mod versions_response; +pub use self::versions_response::VersionsResponse; +pub mod wallet_info_request; +pub use self::wallet_info_request::WalletInfoRequest; +pub mod ed25519_private_key; +pub use self::ed25519_private_key::Ed25519PrivateKey; +pub mod ed25519_public_key; +pub use self::ed25519_public_key::Ed25519PublicKey; +pub mod ed25519_signature; +pub use self::ed25519_signature::Ed25519Signature; diff --git a/crates/kmd_client/src/models/multisig_sig.rs b/crates/kmd_client/src/models/multisig_sig.rs new file mode 100644 index 000000000..1b63b5b3a --- /dev/null +++ b/crates/kmd_client/src/models/multisig_sig.rs @@ -0,0 +1,32 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::MultisigSubsig; + +/// MultisigSig is the structure that holds multiple Subsigs +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct MultisigSig { + #[serde(rename = "Subsigs", skip_serializing_if = "Option::is_none")] + pub subsigs: Option>, + #[serde(rename = "Threshold", skip_serializing_if = "Option::is_none")] + pub threshold: Option, + #[serde(rename = "Version", skip_serializing_if = "Option::is_none")] + pub version: Option, +} + +impl MultisigSig { + /// Default constructor for MultisigSig + pub fn new() -> MultisigSig { + MultisigSig::default() + } +} diff --git a/crates/kmd_client/src/models/multisig_subsig.rs b/crates/kmd_client/src/models/multisig_subsig.rs new file mode 100644 index 000000000..cf34c644c --- /dev/null +++ b/crates/kmd_client/src/models/multisig_subsig.rs @@ -0,0 +1,32 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use crate::models::PublicKey; +use crate::models::Signature; + +/// MultisigSubsig is a struct that holds a pair of public key and signatures +/// signatures may be empty +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct MultisigSubsig { + #[serde(rename = "Key", skip_serializing_if = "Option::is_none")] + pub key: Option, + #[serde(rename = "Sig", skip_serializing_if = "Option::is_none")] + pub sig: Option, +} + +impl MultisigSubsig { + /// Default constructor for MultisigSubsig + pub fn new() -> MultisigSubsig { + MultisigSubsig::default() + } +} diff --git a/crates/kmd_client/src/models/private_key.rs b/crates/kmd_client/src/models/private_key.rs new file mode 100644 index 000000000..baefeca37 --- /dev/null +++ b/crates/kmd_client/src/models/private_key.rs @@ -0,0 +1,22 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PrivateKey {} + +impl PrivateKey { + /// Default constructor for PrivateKey + pub fn new() -> PrivateKey { + PrivateKey::default() + } +} diff --git a/crates/kmd_client/src/models/public_key.rs b/crates/kmd_client/src/models/public_key.rs new file mode 100644 index 000000000..d5098041d --- /dev/null +++ b/crates/kmd_client/src/models/public_key.rs @@ -0,0 +1,22 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PublicKey {} + +impl PublicKey { + /// Default constructor for PublicKey + pub fn new() -> PublicKey { + PublicKey::default() + } +} diff --git a/crates/kmd_client/src/models/release_wallet_handle_token_request.rs b/crates/kmd_client/src/models/release_wallet_handle_token_request.rs new file mode 100644 index 000000000..05c79f8af --- /dev/null +++ b/crates/kmd_client/src/models/release_wallet_handle_token_request.rs @@ -0,0 +1,29 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTWalletReleaseRequest is the request for `POST /v1/wallet/release` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ReleaseWalletHandleTokenRequest { + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl ReleaseWalletHandleTokenRequest { + /// Default constructor for ReleaseWalletHandleTokenRequest + pub fn new() -> ReleaseWalletHandleTokenRequest { + ReleaseWalletHandleTokenRequest::default() + } +} diff --git a/crates/kmd_client/src/models/rename_wallet_request.rs b/crates/kmd_client/src/models/rename_wallet_request.rs new file mode 100644 index 000000000..882085c89 --- /dev/null +++ b/crates/kmd_client/src/models/rename_wallet_request.rs @@ -0,0 +1,30 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTWalletRenameRequest is the request for `POST /v1/wallet/rename` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RenameWalletRequest { + #[serde(rename = "wallet_id", skip_serializing_if = "Option::is_none")] + pub wallet_id: Option, + #[serde(rename = "wallet_name", skip_serializing_if = "Option::is_none")] + pub wallet_name: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl RenameWalletRequest { + /// Default constructor for RenameWalletRequest + pub fn new() -> RenameWalletRequest { + RenameWalletRequest::default() + } +} diff --git a/crates/kmd_client/src/models/renew_wallet_handle_token_request.rs b/crates/kmd_client/src/models/renew_wallet_handle_token_request.rs new file mode 100644 index 000000000..29928dc48 --- /dev/null +++ b/crates/kmd_client/src/models/renew_wallet_handle_token_request.rs @@ -0,0 +1,29 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTWalletRenewRequest is the request for `POST /v1/wallet/renew` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RenewWalletHandleTokenRequest { + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl RenewWalletHandleTokenRequest { + /// Default constructor for RenewWalletHandleTokenRequest + pub fn new() -> RenewWalletHandleTokenRequest { + RenewWalletHandleTokenRequest::default() + } +} diff --git a/crates/kmd_client/src/models/sign_multisig_request.rs b/crates/kmd_client/src/models/sign_multisig_request.rs new file mode 100644 index 000000000..4b418470b --- /dev/null +++ b/crates/kmd_client/src/models/sign_multisig_request.rs @@ -0,0 +1,46 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use serde_with::{Bytes, serde_as}; + +use crate::models::Digest; +use crate::models::MultisigSig; +use crate::models::PublicKey; + +/// APIV1POSTMultisigTransactionSignRequest is the request for `POST /v1/multisig/sign` +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SignMultisigRequest { + #[serde(rename = "partial_multisig", skip_serializing_if = "Option::is_none")] + pub partial_multisig: Option, + #[serde(rename = "public_key", skip_serializing_if = "Option::is_none")] + pub public_key: Option, + #[serde(rename = "signer", skip_serializing_if = "Option::is_none")] + pub signer: Option, + #[serde_as(as = "Option")] + #[serde(rename = "transaction", skip_serializing_if = "Option::is_none")] + pub transaction: Option>, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl SignMultisigRequest { + /// Default constructor for SignMultisigRequest + pub fn new() -> SignMultisigRequest { + SignMultisigRequest::default() + } +} diff --git a/crates/kmd_client/src/models/sign_program_multisig_request.rs b/crates/kmd_client/src/models/sign_program_multisig_request.rs new file mode 100644 index 000000000..c5685c705 --- /dev/null +++ b/crates/kmd_client/src/models/sign_program_multisig_request.rs @@ -0,0 +1,45 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use serde_with::{Bytes, serde_as}; + +use crate::models::MultisigSig; +use crate::models::PublicKey; + +/// APIV1POSTMultisigProgramSignRequest is the request for `POST /v1/multisig/signprogram` +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SignProgramMultisigRequest { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde_as(as = "Option")] + #[serde(rename = "data", skip_serializing_if = "Option::is_none")] + pub data: Option>, + #[serde(rename = "partial_multisig", skip_serializing_if = "Option::is_none")] + pub partial_multisig: Option, + #[serde(rename = "public_key", skip_serializing_if = "Option::is_none")] + pub public_key: Option, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl SignProgramMultisigRequest { + /// Default constructor for SignProgramMultisigRequest + pub fn new() -> SignProgramMultisigRequest { + SignProgramMultisigRequest::default() + } +} diff --git a/crates/kmd_client/src/models/sign_program_request.rs b/crates/kmd_client/src/models/sign_program_request.rs new file mode 100644 index 000000000..48e66f311 --- /dev/null +++ b/crates/kmd_client/src/models/sign_program_request.rs @@ -0,0 +1,38 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use serde_with::{Bytes, serde_as}; + +/// APIV1POSTProgramSignRequest is the request for `POST /v1/program/sign` +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SignProgramRequest { + #[serde(rename = "address", skip_serializing_if = "Option::is_none")] + pub address: Option, + #[serde_as(as = "Option")] + #[serde(rename = "data", skip_serializing_if = "Option::is_none")] + pub data: Option>, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl SignProgramRequest { + /// Default constructor for SignProgramRequest + pub fn new() -> SignProgramRequest { + SignProgramRequest::default() + } +} diff --git a/crates/kmd_client/src/models/sign_transaction_request.rs b/crates/kmd_client/src/models/sign_transaction_request.rs new file mode 100644 index 000000000..7d72549af --- /dev/null +++ b/crates/kmd_client/src/models/sign_transaction_request.rs @@ -0,0 +1,44 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use serde_with::{Bytes, serde_as}; + +use crate::models::PublicKey; + +/// APIV1POSTTransactionSignRequest is the request for `POST /v1/transaction/sign` +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SignTransactionRequest { + #[serde(rename = "public_key", skip_serializing_if = "Option::is_none")] + pub public_key: Option, + /// Base64 encoding of msgpack encoding of a `Transaction` object + /// Note: SDK and goal usually generate `SignedTxn` objects + /// in that case, the field `txn` / `Transaction` of the + /// generated `SignedTxn` object needs to be used + #[serde_as(as = "Option")] + #[serde(rename = "transaction", skip_serializing_if = "Option::is_none")] + pub transaction: Option>, + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, + #[serde(rename = "wallet_password", skip_serializing_if = "Option::is_none")] + pub wallet_password: Option, +} + +impl SignTransactionRequest { + /// Default constructor for SignTransactionRequest + pub fn new() -> SignTransactionRequest { + SignTransactionRequest::default() + } +} diff --git a/crates/kmd_client/src/models/signature.rs b/crates/kmd_client/src/models/signature.rs new file mode 100644 index 000000000..b95e6cbb8 --- /dev/null +++ b/crates/kmd_client/src/models/signature.rs @@ -0,0 +1,22 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Signature {} + +impl Signature { + /// Default constructor for Signature + pub fn new() -> Signature { + Signature::default() + } +} diff --git a/crates/kmd_client/src/models/tx_type.rs b/crates/kmd_client/src/models/tx_type.rs new file mode 100644 index 000000000..85cb1df21 --- /dev/null +++ b/crates/kmd_client/src/models/tx_type.rs @@ -0,0 +1,85 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; +use std::fmt; +use std::str::FromStr; + +/// TxType is the type of the transaction written to the ledger +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] +pub enum TxType { + /// pay + #[serde(rename = "pay")] + #[default] + Pay, + /// keyreg + #[serde(rename = "keyreg")] + Keyreg, + /// acfg + #[serde(rename = "acfg")] + Acfg, + /// axfer + #[serde(rename = "axfer")] + Axfer, + /// afrz + #[serde(rename = "afrz")] + Afrz, + /// appl + #[serde(rename = "appl")] + Appl, + /// stpf + #[serde(rename = "stpf")] + Stpf, + /// hb + #[serde(rename = "hb")] + Hb, +} + +impl fmt::Display for TxType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let value = match self { + TxType::Pay => "pay", + TxType::Keyreg => "keyreg", + TxType::Acfg => "acfg", + TxType::Axfer => "axfer", + TxType::Afrz => "afrz", + TxType::Appl => "appl", + TxType::Stpf => "stpf", + TxType::Hb => "hb", + }; + write!(f, "{}", value) + } +} + +impl FromStr for TxType { + type Err = String; + + fn from_str(s: &str) -> Result { + match s { + "pay" => Ok(TxType::Pay), + "keyreg" => Ok(TxType::Keyreg), + "acfg" => Ok(TxType::Acfg), + "axfer" => Ok(TxType::Axfer), + "afrz" => Ok(TxType::Afrz), + "appl" => Ok(TxType::Appl), + "stpf" => Ok(TxType::Stpf), + "hb" => Ok(TxType::Hb), + _ => Err(format!("Invalid TxType: {}", s)), + } + } +} + +impl TxType { + /// Default constructor for TxType + pub fn new() -> TxType { + TxType::default() + } +} diff --git a/crates/kmd_client/src/models/versions_request.rs b/crates/kmd_client/src/models/versions_request.rs new file mode 100644 index 000000000..d69dd6709 --- /dev/null +++ b/crates/kmd_client/src/models/versions_request.rs @@ -0,0 +1,23 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// VersionsRequest is the request for `GET /versions` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct VersionsRequest {} + +impl VersionsRequest { + /// Default constructor for VersionsRequest + pub fn new() -> VersionsRequest { + VersionsRequest::default() + } +} diff --git a/crates/kmd_client/src/models/versions_response.rs b/crates/kmd_client/src/models/versions_response.rs new file mode 100644 index 000000000..e2b938059 --- /dev/null +++ b/crates/kmd_client/src/models/versions_response.rs @@ -0,0 +1,27 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// VersionsResponse is the response to `GET /versions` +/// friendly:VersionsResponse +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct VersionsResponse { + #[serde(rename = "versions", skip_serializing_if = "Option::is_none")] + pub versions: Option>, +} + +impl VersionsResponse { + /// Default constructor for VersionsResponse + pub fn new() -> VersionsResponse { + VersionsResponse::default() + } +} diff --git a/crates/kmd_client/src/models/wallet_info_request.rs b/crates/kmd_client/src/models/wallet_info_request.rs new file mode 100644 index 000000000..6262434eb --- /dev/null +++ b/crates/kmd_client/src/models/wallet_info_request.rs @@ -0,0 +1,29 @@ +/* + * for KMD HTTP API + * + * API for KMD (Key Management Daemon) + * + * The version of the OpenAPI document: 0.0.1 + * Contact: contact@algorand.com + * Generated by: Rust OpenAPI Generator + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// APIV1POSTWalletInfoRequest is the request for `POST /v1/wallet/info` +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct WalletInfoRequest { + #[serde( + rename = "wallet_handle_token", + skip_serializing_if = "Option::is_none" + )] + pub wallet_handle_token: Option, +} + +impl WalletInfoRequest { + /// Default constructor for WalletInfoRequest + pub fn new() -> WalletInfoRequest { + WalletInfoRequest::default() + } +} diff --git a/tools/api_tools/src/main.rs b/tools/api_tools/src/main.rs index e3ed64e6e..82be88e44 100644 --- a/tools/api_tools/src/main.rs +++ b/tools/api_tools/src/main.rs @@ -32,16 +32,22 @@ enum Commands { /// Format generated indexer Rust code #[command(name = "format-indexer")] FormatIndexer, + /// Format generated KMD Rust code + #[command(name = "format-kmd")] + FormatKmd, /// Generate algod API client #[command(name = "generate-algod")] GenerateAlgod, /// Generate indexer API client #[command(name = "generate-indexer")] GenerateIndexer, - /// Generate both algod and indexer API clients + /// Generate KMD API client + #[command(name = "generate-kmd")] + GenerateKmd, + /// Generate algod, indexer, and KMD API clients #[command(name = "generate-all")] GenerateAll, - /// Convert OpenAPI specifications (both algod and indexer) + /// Convert OpenAPI specifications (algod, indexer, and KMD) #[command(name = "convert-openapi")] ConvertOpenapi, /// Convert algod OpenAPI specification only @@ -50,6 +56,9 @@ enum Commands { /// Convert indexer OpenAPI specification only #[command(name = "convert-indexer")] ConvertIndexer, + /// Convert KMD OpenAPI specification only + #[command(name = "convert-kmd")] + ConvertKmd, } fn get_repo_root() -> PathBuf { @@ -122,6 +131,13 @@ fn execute_command(command: &Commands) -> Result<()> { None, )?; } + Commands::FormatKmd => { + run( + "cargo fmt --manifest-path Cargo.toml -p kmd_client", + None, + None, + )?; + } Commands::GenerateAlgod => { // Generate the client run( @@ -150,6 +166,20 @@ fn execute_command(command: &Commands) -> Result<()> { None, )?; } + Commands::GenerateKmd => { + // Generate the client + run( + "uv run python -m rust_oas_generator.cli ../specs/kmd.oas3.json --output ../../crates/kmd_client/ --package-name kmd_client --description \"API client for KMD (Key Management Daemon) interaction.\"", + Some(Path::new("api/oas_generator")), + None, + )?; + // Format the generated code + run( + "cargo fmt --manifest-path Cargo.toml -p kmd_client", + None, + None, + )?; + } Commands::GenerateAll => { // Generate algod client run( @@ -163,7 +193,13 @@ fn execute_command(command: &Commands) -> Result<()> { Some(Path::new("api/oas_generator")), None, )?; - // Format both generated codes + // Generate KMD client + run( + "uv run python -m rust_oas_generator.cli ../specs/kmd.oas3.json --output ../../crates/kmd_client/ --package-name kmd_client --description \"API client for KMD (Key Management Daemon) interaction.\"", + Some(Path::new("api/oas_generator")), + None, + )?; + // Format all generated codes run( "cargo fmt --manifest-path Cargo.toml -p algod_client", None, @@ -174,6 +210,11 @@ fn execute_command(command: &Commands) -> Result<()> { None, None, )?; + run( + "cargo fmt --manifest-path Cargo.toml -p kmd_client", + None, + None, + )?; } Commands::ConvertOpenapi => { run( @@ -196,6 +237,13 @@ fn execute_command(command: &Commands) -> Result<()> { None, )?; } + Commands::ConvertKmd => { + run( + "bun scripts/convert-openapi.ts --kmd-only", + Some(Path::new("api")), + None, + )?; + } } Ok(()) }