From dabbda504262520a069c927f073b7f55e0a563f8 Mon Sep 17 00:00:00 2001 From: Kyle Peacock Date: Mon, 3 Jun 2024 16:06:46 -0700 Subject: [PATCH 1/4] chore: update management canister interface with latest bitcoin features --- docs/CHANGELOG.md | 1 + packages/agent/src/canisters/management.did | 428 ++++++----------- .../agent/src/canisters/management_idl.ts | 432 ++++++++---------- .../agent/src/canisters/management_service.ts | 405 ++++++++-------- 4 files changed, 515 insertions(+), 751 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 9630cf4e..a711a142 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,7 @@ ### Changed +- chore: update management canister interface with latest bitcoin features - fix: publish script will correctly update the `package-lock.json` file with the correct dependencies when making a new release - chore: updates agent error response to read "Gateway returns error" instead of "Server"` - chore: updates dfinity/conventional-pr-title-action to v4.0.0 diff --git a/packages/agent/src/canisters/management.did b/packages/agent/src/canisters/management.did index 33db98ba..990bdf47 100644 --- a/packages/agent/src/canisters/management.did +++ b/packages/agent/src/canisters/management.did @@ -2,18 +2,11 @@ type canister_id = principal; type wasm_module = blob; -type log_visibility = variant { - controllers; - public; -}; - type canister_settings = record { controllers : opt vec principal; compute_allocation : opt nat; memory_allocation : opt nat; freezing_threshold : opt nat; - reserved_cycles_limit : opt nat; - log_visibility : opt log_visibility; }; type definite_canister_settings = record { @@ -21,8 +14,6 @@ type definite_canister_settings = record { compute_allocation : nat; memory_allocation : nat; freezing_threshold : nat; - reserved_cycles_limit : nat; - log_visibility : log_visibility; }; type change_origin = variant { @@ -41,7 +32,7 @@ type change_details = variant { }; code_uninstall; code_deployment : record { - mode : variant { install; reinstall; upgrade }; + mode : variant {install; reinstall; upgrade}; module_hash : blob; }; controllers_change : record { @@ -56,22 +47,29 @@ type change = record { details : change_details; }; +type canister_install_mode = variant { + install; + reinstall; + upgrade : opt record { + skip_pre_upgrade: opt bool; + wasm_memory_persistence : opt variant { + keep; + replace; + }; + }; +}; + type chunk_hash = blob; -type http_header = record { - name : text; - value : text; -}; +type http_header = record { name: text; value: text }; -type http_request_result = record { - status : nat; - headers : vec http_header; - body : blob; +type http_response = record { + status: nat; + headers: vec http_header; + body: blob; }; -type ecdsa_curve = variant { - secp256k1; -}; +type ecdsa_curve = variant { secp256k1; }; type satoshi = nat64; @@ -86,303 +84,145 @@ type block_hash = blob; type outpoint = record { txid : blob; - vout : nat32; + vout : nat32 }; type utxo = record { - outpoint : outpoint; - value : satoshi; - height : nat32; -}; - -type bitcoin_get_utxos_args = record { - address : bitcoin_address; - network : bitcoin_network; - filter : opt variant { - min_confirmations : nat32; - page : blob; - }; + outpoint: outpoint; + value: satoshi; + height: nat32; }; -type bitcoin_get_utxos_query_args = record { +type get_utxos_request = record { address : bitcoin_address; - network : bitcoin_network; - filter : opt variant { - min_confirmations : nat32; - page : blob; + network: bitcoin_network; + filter: opt variant { + min_confirmations: nat32; + page: blob; }; }; -type bitcoin_get_current_fee_percentiles_args = record { - network : bitcoin_network; +type get_current_fee_percentiles_request = record { + network: bitcoin_network; }; -type bitcoin_get_utxos_result = record { - utxos : vec utxo; - tip_block_hash : block_hash; - tip_height : nat32; - next_page : opt blob; +type get_utxos_response = record { + utxos: vec utxo; + tip_block_hash: block_hash; + tip_height: nat32; + next_page: opt blob; }; -type bitcoin_get_utxos_query_result = record { - utxos : vec utxo; - tip_block_hash : block_hash; - tip_height : nat32; - next_page : opt blob; -}; - -type bitcoin_get_balance_args = record { - address : bitcoin_address; - network : bitcoin_network; - min_confirmations : opt nat32; -}; - -type bitcoin_get_balance_query_args = record { +type get_balance_request = record { address : bitcoin_address; - network : bitcoin_network; - min_confirmations : opt nat32; + network: bitcoin_network; + min_confirmations: opt nat32; }; -type bitcoin_send_transaction_args = record { - transaction : blob; - network : bitcoin_network; +type send_transaction_request = record { + transaction: blob; + network: bitcoin_network; }; type millisatoshi_per_byte = nat64; -type node_metrics = record { - node_id : principal; - num_blocks_total : nat64; - num_block_failures_total : nat64; -}; - -type create_canister_args = record { - settings : opt canister_settings; - sender_canister_version : opt nat64; -}; - -type create_canister_result = record { - canister_id : canister_id; -}; - -type update_settings_args = record { - canister_id : principal; - settings : canister_settings; - sender_canister_version : opt nat64; -}; - -type upload_chunk_args = record { - canister_id : principal; - chunk : blob; -}; - -type clear_chunk_store_args = record { - canister_id : canister_id; -}; - -type stored_chunks_args = record { - canister_id : canister_id; -}; - -type install_code_args = record { - mode : variant { - install; - reinstall; - upgrade : opt record { - skip_pre_upgrade : opt bool; - }; - }; - canister_id : canister_id; - wasm_module : wasm_module; - arg : blob; - sender_canister_version : opt nat64; -}; - -type install_chunked_code_args = record { - mode : variant { - install; - reinstall; - upgrade : opt record { - skip_pre_upgrade : opt bool; - }; - }; - target_canister : canister_id; - storage_canister : opt canister_id; - chunk_hashes_list : vec chunk_hash; - wasm_module_hash : blob; - arg : blob; - sender_canister_version : opt nat64; -}; - -type uninstall_code_args = record { - canister_id : canister_id; - sender_canister_version : opt nat64; -}; - -type start_canister_args = record { - canister_id : canister_id; -}; - -type stop_canister_args = record { - canister_id : canister_id; -}; - -type canister_status_args = record { - canister_id : canister_id; -}; - -type canister_status_result = record { - status : variant { running; stopping; stopped }; - settings : definite_canister_settings; - module_hash : opt blob; - memory_size : nat; - cycles : nat; - reserved_cycles : nat; - idle_cycles_burned_per_day : nat; -}; - -type canister_info_args = record { - canister_id : canister_id; - num_requested_changes : opt nat64; -}; - -type canister_info_result = record { - total_num_changes : nat64; - recent_changes : vec change; - module_hash : opt blob; - controllers : vec principal; -}; - -type delete_canister_args = record { - canister_id : canister_id; -}; - -type deposit_cycles_args = record { - canister_id : canister_id; -}; - -type http_request_args = record { - url : text; - max_response_bytes : opt nat64; - method : variant { get; head; post }; - headers : vec http_header; - body : opt blob; - transform : opt record { - function : func(record { response : http_request_result; context : blob }) -> (http_request_result) query; - context : blob; - }; -}; - -type ecdsa_public_key_args = record { - canister_id : opt canister_id; - derivation_path : vec blob; - key_id : record { curve : ecdsa_curve; name : text }; -}; - -type ecdsa_public_key_result = record { - public_key : blob; - chain_code : blob; -}; - -type sign_with_ecdsa_args = record { - message_hash : blob; - derivation_path : vec blob; - key_id : record { curve : ecdsa_curve; name : text }; -}; - -type sign_with_ecdsa_result = record { - signature : blob; -}; - -type node_metrics_history_args = record { - subnet_id : principal; - start_at_timestamp_nanos : nat64; -}; - -type node_metrics_history_result = vec record { - timestamp_nanos : nat64; - node_metrics : vec node_metrics; -}; - -type provisional_create_canister_with_cycles_args = record { - amount : opt nat; - settings : opt canister_settings; - specified_id : opt canister_id; - sender_canister_version : opt nat64; -}; - -type provisional_create_canister_with_cycles_result = record { - canister_id : canister_id; -}; - -type provisional_top_up_canister_args = record { - canister_id : canister_id; - amount : nat; -}; - -type raw_rand_result = blob; - -type stored_chunks_result = vec chunk_hash; - -type upload_chunk_result = chunk_hash; - -type bitcoin_get_balance_result = satoshi; - -type bitcoin_get_balance_query_result = satoshi; - -type bitcoin_get_current_fee_percentiles_result = vec millisatoshi_per_byte; - -type fetch_canister_logs_args = record { - canister_id : canister_id; -}; - -type canister_log_record = record { - idx : nat64; - timestamp_nanos : nat64; - content : blob; -}; - -type fetch_canister_logs_result = record { - canister_log_records : vec canister_log_record; -}; - service ic : { - create_canister : (create_canister_args) -> (create_canister_result); - update_settings : (update_settings_args) -> (); - upload_chunk : (upload_chunk_args) -> (upload_chunk_result); - clear_chunk_store : (clear_chunk_store_args) -> (); - stored_chunks : (stored_chunks_args) -> (stored_chunks_result); - install_code : (install_code_args) -> (); - install_chunked_code : (install_chunked_code_args) -> (); - uninstall_code : (uninstall_code_args) -> (); - start_canister : (start_canister_args) -> (); - stop_canister : (stop_canister_args) -> (); - canister_status : (canister_status_args) -> (canister_status_result); - canister_info : (canister_info_args) -> (canister_info_result); - delete_canister : (delete_canister_args) -> (); - deposit_cycles : (deposit_cycles_args) -> (); - raw_rand : () -> (raw_rand_result); - http_request : (http_request_args) -> (http_request_result); + create_canister : (record { + settings : opt canister_settings; + sender_canister_version : opt nat64; + }) -> (record {canister_id : canister_id}); + update_settings : (record { + canister_id : principal; + settings : canister_settings; + sender_canister_version : opt nat64; + }) -> (); + upload_chunk : (record { + canister_id : principal; + chunk : blob; + }) -> (chunk_hash); + clear_chunk_store: (record {canister_id : canister_id}) -> (); + stored_chunks: (record {canister_id : canister_id}) -> (vec chunk_hash); + install_code : (record { + mode : canister_install_mode; + canister_id : canister_id; + wasm_module : wasm_module; + arg : blob; + sender_canister_version : opt nat64; + }) -> (); + install_chunked_code: (record { + mode : canister_install_mode; + target_canister: canister_id; + storage_canister: opt canister_id; + chunk_hashes_list: vec chunk_hash; + wasm_module_hash: blob; + arg : blob; + sender_canister_version : opt nat64; + }) -> (); + uninstall_code : (record { + canister_id : canister_id; + sender_canister_version : opt nat64; + }) -> (); + start_canister : (record {canister_id : canister_id}) -> (); + stop_canister : (record {canister_id : canister_id}) -> (); + canister_status : (record {canister_id : canister_id}) -> (record { + status : variant { running; stopping; stopped }; + settings: definite_canister_settings; + module_hash: opt blob; + memory_size: nat; + cycles: nat; + idle_cycles_burned_per_day: nat; + }); + canister_info : (record { + canister_id : canister_id; + num_requested_changes : opt nat64; + }) -> (record { + total_num_changes : nat64; + recent_changes : vec change; + module_hash : opt blob; + controllers : vec principal; + }); + delete_canister : (record {canister_id : canister_id}) -> (); + deposit_cycles : (record {canister_id : canister_id}) -> (); + raw_rand : () -> (blob); + http_request : (record { + url : text; + max_response_bytes: opt nat64; + method : variant { get; head; post }; + headers: vec http_header; + body : opt blob; + transform : opt record { + function : func (record {response : http_response; context : blob}) -> (http_response) query; + context : blob + }; + }) -> (http_response); // Threshold ECDSA signature - ecdsa_public_key : (ecdsa_public_key_args) -> (ecdsa_public_key_result); - sign_with_ecdsa : (sign_with_ecdsa_args) -> (sign_with_ecdsa_result); + ecdsa_public_key : (record { + canister_id : opt canister_id; + derivation_path : vec blob; + key_id : record { curve: ecdsa_curve; name: text }; + }) -> (record { public_key : blob; chain_code : blob; }); + sign_with_ecdsa : (record { + message_hash : blob; + derivation_path : vec blob; + key_id : record { curve: ecdsa_curve; name: text }; + }) -> (record { signature : blob }); // bitcoin interface - bitcoin_get_balance : (bitcoin_get_balance_args) -> (bitcoin_get_balance_result); - bitcoin_get_balance_query : (bitcoin_get_balance_query_args) -> (bitcoin_get_balance_query_result) query; - bitcoin_get_utxos : (bitcoin_get_utxos_args) -> (bitcoin_get_utxos_result); - bitcoin_get_utxos_query : (bitcoin_get_utxos_query_args) -> (bitcoin_get_utxos_query_result) query; - bitcoin_send_transaction : (bitcoin_send_transaction_args) -> (); - bitcoin_get_current_fee_percentiles : (bitcoin_get_current_fee_percentiles_args) -> (bitcoin_get_current_fee_percentiles_result); - - // metrics interface - node_metrics_history : (node_metrics_history_args) -> (node_metrics_history_result); + bitcoin_get_balance: (get_balance_request) -> (satoshi); + bitcoin_get_balance_query: (get_balance_request) -> (satoshi) query; + bitcoin_get_utxos: (get_utxos_request) -> (get_utxos_response); + bitcoin_get_utxos_query: (get_utxos_request) -> (get_utxos_response) query; + bitcoin_send_transaction: (send_transaction_request) -> (); + bitcoin_get_current_fee_percentiles: (get_current_fee_percentiles_request) -> (vec millisatoshi_per_byte); // provisional interfaces for the pre-ledger world - provisional_create_canister_with_cycles : (provisional_create_canister_with_cycles_args) -> (provisional_create_canister_with_cycles_result); - provisional_top_up_canister : (provisional_top_up_canister_args) -> (); - - // canister logging - fetch_canister_logs : (fetch_canister_logs_args) -> (fetch_canister_logs_result) query; -}; + provisional_create_canister_with_cycles : (record { + amount: opt nat; + settings : opt canister_settings; + specified_id: opt canister_id; + sender_canister_version : opt nat64; + }) -> (record {canister_id : canister_id}); + provisional_top_up_canister : + (record { canister_id: canister_id; amount: nat }) -> (); +} diff --git a/packages/agent/src/canisters/management_idl.ts b/packages/agent/src/canisters/management_idl.ts index bad5b8ea..e1eb20c0 100644 --- a/packages/agent/src/canisters/management_idl.ts +++ b/packages/agent/src/canisters/management_idl.ts @@ -1,6 +1,6 @@ /** * This file is generated from the candid for asset management. - * didc version: 0.3.6 + * didc version: 0.4.0 */ // eslint-disable-next-line @typescript-eslint/ban-ts-comment @@ -11,25 +11,17 @@ export default ({ IDL }) => { testnet: IDL.Null, }); const bitcoin_address = IDL.Text; - const bitcoin_get_balance_args = IDL.Record({ + const get_balance_request = IDL.Record({ network: bitcoin_network, address: bitcoin_address, min_confirmations: IDL.Opt(IDL.Nat32), }); const satoshi = IDL.Nat64; - const bitcoin_get_balance_result = satoshi; - const bitcoin_get_balance_query_args = IDL.Record({ - network: bitcoin_network, - address: bitcoin_address, - min_confirmations: IDL.Opt(IDL.Nat32), - }); - const bitcoin_get_balance_query_result = satoshi; - const bitcoin_get_current_fee_percentiles_args = IDL.Record({ + const get_current_fee_percentiles_request = IDL.Record({ network: bitcoin_network, }); const millisatoshi_per_byte = IDL.Nat64; - const bitcoin_get_current_fee_percentiles_result = IDL.Vec(millisatoshi_per_byte); - const bitcoin_get_utxos_args = IDL.Record({ + const get_utxos_request = IDL.Record({ network: bitcoin_network, filter: IDL.Opt( IDL.Variant({ @@ -49,37 +41,17 @@ export default ({ IDL }) => { value: satoshi, outpoint: outpoint, }); - const bitcoin_get_utxos_result = IDL.Record({ + const get_utxos_response = IDL.Record({ next_page: IDL.Opt(IDL.Vec(IDL.Nat8)), tip_height: IDL.Nat32, tip_block_hash: block_hash, utxos: IDL.Vec(utxo), }); - const bitcoin_get_utxos_query_args = IDL.Record({ - network: bitcoin_network, - filter: IDL.Opt( - IDL.Variant({ - page: IDL.Vec(IDL.Nat8), - min_confirmations: IDL.Nat32, - }), - ), - address: bitcoin_address, - }); - const bitcoin_get_utxos_query_result = IDL.Record({ - next_page: IDL.Opt(IDL.Vec(IDL.Nat8)), - tip_height: IDL.Nat32, - tip_block_hash: block_hash, - utxos: IDL.Vec(utxo), - }); - const bitcoin_send_transaction_args = IDL.Record({ + const send_transaction_request = IDL.Record({ transaction: IDL.Vec(IDL.Nat8), network: bitcoin_network, }); const canister_id = IDL.Principal; - const canister_info_args = IDL.Record({ - canister_id: canister_id, - num_requested_changes: IDL.Opt(IDL.Nat64), - }); const change_origin = IDL.Variant({ from_user: IDL.Record({ user_id: IDL.Principal }), from_canister: IDL.Record({ @@ -108,234 +80,234 @@ export default ({ IDL }) => { origin: change_origin, details: change_details, }); - const canister_info_result = IDL.Record({ - controllers: IDL.Vec(IDL.Principal), - module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), - recent_changes: IDL.Vec(change), - total_num_changes: IDL.Nat64, - }); - const canister_status_args = IDL.Record({ canister_id: canister_id }); - const log_visibility = IDL.Variant({ - controllers: IDL.Null, - public: IDL.Null, - }); const definite_canister_settings = IDL.Record({ freezing_threshold: IDL.Nat, controllers: IDL.Vec(IDL.Principal), - reserved_cycles_limit: IDL.Nat, - log_visibility: log_visibility, memory_allocation: IDL.Nat, compute_allocation: IDL.Nat, }); - const canister_status_result = IDL.Record({ - status: IDL.Variant({ - stopped: IDL.Null, - stopping: IDL.Null, - running: IDL.Null, - }), - memory_size: IDL.Nat, - cycles: IDL.Nat, - settings: definite_canister_settings, - idle_cycles_burned_per_day: IDL.Nat, - module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), - reserved_cycles: IDL.Nat, - }); - const clear_chunk_store_args = IDL.Record({ canister_id: canister_id }); const canister_settings = IDL.Record({ freezing_threshold: IDL.Opt(IDL.Nat), controllers: IDL.Opt(IDL.Vec(IDL.Principal)), - reserved_cycles_limit: IDL.Opt(IDL.Nat), - log_visibility: IDL.Opt(log_visibility), memory_allocation: IDL.Opt(IDL.Nat), compute_allocation: IDL.Opt(IDL.Nat), }); - const create_canister_args = IDL.Record({ - settings: IDL.Opt(canister_settings), - sender_canister_version: IDL.Opt(IDL.Nat64), - }); - const create_canister_result = IDL.Record({ canister_id: canister_id }); - const delete_canister_args = IDL.Record({ canister_id: canister_id }); - const deposit_cycles_args = IDL.Record({ canister_id: canister_id }); const ecdsa_curve = IDL.Variant({ secp256k1: IDL.Null }); - const ecdsa_public_key_args = IDL.Record({ - key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), - canister_id: IDL.Opt(canister_id), - derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), - }); - const ecdsa_public_key_result = IDL.Record({ - public_key: IDL.Vec(IDL.Nat8), - chain_code: IDL.Vec(IDL.Nat8), - }); - const fetch_canister_logs_args = IDL.Record({ canister_id: canister_id }); - const canister_log_record = IDL.Record({ - idx: IDL.Nat64, - timestamp_nanos: IDL.Nat64, - content: IDL.Vec(IDL.Nat8), - }); - const fetch_canister_logs_result = IDL.Record({ - canister_log_records: IDL.Vec(canister_log_record), - }); const http_header = IDL.Record({ value: IDL.Text, name: IDL.Text }); - const http_request_result = IDL.Record({ + const http_response = IDL.Record({ status: IDL.Nat, body: IDL.Vec(IDL.Nat8), headers: IDL.Vec(http_header), }); - const http_request_args = IDL.Record({ - url: IDL.Text, - method: IDL.Variant({ - get: IDL.Null, - head: IDL.Null, - post: IDL.Null, - }), - max_response_bytes: IDL.Opt(IDL.Nat64), - body: IDL.Opt(IDL.Vec(IDL.Nat8)), - transform: IDL.Opt( + const canister_install_mode = IDL.Variant({ + reinstall: IDL.Null, + upgrade: IDL.Opt( IDL.Record({ - function: IDL.Func( - [ - IDL.Record({ - context: IDL.Vec(IDL.Nat8), - response: http_request_result, - }), - ], - [http_request_result], - ['query'], - ), - context: IDL.Vec(IDL.Nat8), + wasm_memory_persistence: IDL.Opt(IDL.Variant({ keep: IDL.Null, replace: IDL.Null })), + skip_pre_upgrade: IDL.Opt(IDL.Bool), }), ), - headers: IDL.Vec(http_header), + install: IDL.Null, }); const chunk_hash = IDL.Vec(IDL.Nat8); - const install_chunked_code_args = IDL.Record({ - arg: IDL.Vec(IDL.Nat8), - wasm_module_hash: IDL.Vec(IDL.Nat8), - mode: IDL.Variant({ - reinstall: IDL.Null, - upgrade: IDL.Opt(IDL.Record({ skip_pre_upgrade: IDL.Opt(IDL.Bool) })), - install: IDL.Null, - }), - chunk_hashes_list: IDL.Vec(chunk_hash), - target_canister: canister_id, - sender_canister_version: IDL.Opt(IDL.Nat64), - storage_canister: IDL.Opt(canister_id), - }); const wasm_module = IDL.Vec(IDL.Nat8); - const install_code_args = IDL.Record({ - arg: IDL.Vec(IDL.Nat8), - wasm_module: wasm_module, - mode: IDL.Variant({ - reinstall: IDL.Null, - upgrade: IDL.Opt(IDL.Record({ skip_pre_upgrade: IDL.Opt(IDL.Bool) })), - install: IDL.Null, - }), - canister_id: canister_id, - sender_canister_version: IDL.Opt(IDL.Nat64), - }); - const node_metrics_history_args = IDL.Record({ - start_at_timestamp_nanos: IDL.Nat64, - subnet_id: IDL.Principal, - }); - const node_metrics = IDL.Record({ - num_block_failures_total: IDL.Nat64, - node_id: IDL.Principal, - num_blocks_total: IDL.Nat64, - }); - const node_metrics_history_result = IDL.Vec( - IDL.Record({ - timestamp_nanos: IDL.Nat64, - node_metrics: IDL.Vec(node_metrics), - }), - ); - const provisional_create_canister_with_cycles_args = IDL.Record({ - settings: IDL.Opt(canister_settings), - specified_id: IDL.Opt(canister_id), - amount: IDL.Opt(IDL.Nat), - sender_canister_version: IDL.Opt(IDL.Nat64), - }); - const provisional_create_canister_with_cycles_result = IDL.Record({ - canister_id: canister_id, - }); - const provisional_top_up_canister_args = IDL.Record({ - canister_id: canister_id, - amount: IDL.Nat, - }); - const raw_rand_result = IDL.Vec(IDL.Nat8); - const sign_with_ecdsa_args = IDL.Record({ - key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), - derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), - message_hash: IDL.Vec(IDL.Nat8), - }); - const sign_with_ecdsa_result = IDL.Record({ - signature: IDL.Vec(IDL.Nat8), - }); - const start_canister_args = IDL.Record({ canister_id: canister_id }); - const stop_canister_args = IDL.Record({ canister_id: canister_id }); - const stored_chunks_args = IDL.Record({ canister_id: canister_id }); - const stored_chunks_result = IDL.Vec(chunk_hash); - const uninstall_code_args = IDL.Record({ - canister_id: canister_id, - sender_canister_version: IDL.Opt(IDL.Nat64), - }); - const update_settings_args = IDL.Record({ - canister_id: IDL.Principal, - settings: canister_settings, - sender_canister_version: IDL.Opt(IDL.Nat64), - }); - const upload_chunk_args = IDL.Record({ - chunk: IDL.Vec(IDL.Nat8), - canister_id: IDL.Principal, - }); - const upload_chunk_result = chunk_hash; return IDL.Service({ - bitcoin_get_balance: IDL.Func([bitcoin_get_balance_args], [bitcoin_get_balance_result], []), - bitcoin_get_balance_query: IDL.Func( - [bitcoin_get_balance_query_args], - [bitcoin_get_balance_query_result], - ['query'], - ), + bitcoin_get_balance: IDL.Func([get_balance_request], [satoshi], []), + bitcoin_get_balance_query: IDL.Func([get_balance_request], [satoshi], ['query']), bitcoin_get_current_fee_percentiles: IDL.Func( - [bitcoin_get_current_fee_percentiles_args], - [bitcoin_get_current_fee_percentiles_result], + [get_current_fee_percentiles_request], + [IDL.Vec(millisatoshi_per_byte)], + [], + ), + bitcoin_get_utxos: IDL.Func([get_utxos_request], [get_utxos_response], []), + bitcoin_get_utxos_query: IDL.Func([get_utxos_request], [get_utxos_response], ['query']), + bitcoin_send_transaction: IDL.Func([send_transaction_request], [], []), + canister_info: IDL.Func( + [ + IDL.Record({ + canister_id: canister_id, + num_requested_changes: IDL.Opt(IDL.Nat64), + }), + ], + [ + IDL.Record({ + controllers: IDL.Vec(IDL.Principal), + module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), + recent_changes: IDL.Vec(change), + total_num_changes: IDL.Nat64, + }), + ], + [], + ), + canister_status: IDL.Func( + [IDL.Record({ canister_id: canister_id })], + [ + IDL.Record({ + status: IDL.Variant({ + stopped: IDL.Null, + stopping: IDL.Null, + running: IDL.Null, + }), + memory_size: IDL.Nat, + cycles: IDL.Nat, + settings: definite_canister_settings, + idle_cycles_burned_per_day: IDL.Nat, + module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), + }), + ], + [], + ), + clear_chunk_store: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), + create_canister: IDL.Func( + [ + IDL.Record({ + settings: IDL.Opt(canister_settings), + sender_canister_version: IDL.Opt(IDL.Nat64), + }), + ], + [IDL.Record({ canister_id: canister_id })], + [], + ), + delete_canister: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), + deposit_cycles: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), + ecdsa_public_key: IDL.Func( + [ + IDL.Record({ + key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), + canister_id: IDL.Opt(canister_id), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), + }), + ], + [ + IDL.Record({ + public_key: IDL.Vec(IDL.Nat8), + chain_code: IDL.Vec(IDL.Nat8), + }), + ], + [], + ), + http_request: IDL.Func( + [ + IDL.Record({ + url: IDL.Text, + method: IDL.Variant({ + get: IDL.Null, + head: IDL.Null, + post: IDL.Null, + }), + max_response_bytes: IDL.Opt(IDL.Nat64), + body: IDL.Opt(IDL.Vec(IDL.Nat8)), + transform: IDL.Opt( + IDL.Record({ + function: IDL.Func( + [ + IDL.Record({ + context: IDL.Vec(IDL.Nat8), + response: http_response, + }), + ], + [http_response], + ['query'], + ), + context: IDL.Vec(IDL.Nat8), + }), + ), + headers: IDL.Vec(http_header), + }), + ], + [http_response], [], ), - bitcoin_get_utxos: IDL.Func([bitcoin_get_utxos_args], [bitcoin_get_utxos_result], []), - bitcoin_get_utxos_query: IDL.Func( - [bitcoin_get_utxos_query_args], - [bitcoin_get_utxos_query_result], - ['query'], + install_chunked_code: IDL.Func( + [ + IDL.Record({ + arg: IDL.Vec(IDL.Nat8), + wasm_module_hash: IDL.Vec(IDL.Nat8), + mode: canister_install_mode, + chunk_hashes_list: IDL.Vec(chunk_hash), + target_canister: canister_id, + sender_canister_version: IDL.Opt(IDL.Nat64), + storage_canister: IDL.Opt(canister_id), + }), + ], + [], + [], ), - bitcoin_send_transaction: IDL.Func([bitcoin_send_transaction_args], [], []), - canister_info: IDL.Func([canister_info_args], [canister_info_result], []), - canister_status: IDL.Func([canister_status_args], [canister_status_result], []), - clear_chunk_store: IDL.Func([clear_chunk_store_args], [], []), - create_canister: IDL.Func([create_canister_args], [create_canister_result], []), - delete_canister: IDL.Func([delete_canister_args], [], []), - deposit_cycles: IDL.Func([deposit_cycles_args], [], []), - ecdsa_public_key: IDL.Func([ecdsa_public_key_args], [ecdsa_public_key_result], []), - fetch_canister_logs: IDL.Func( - [fetch_canister_logs_args], - [fetch_canister_logs_result], - ['query'], + install_code: IDL.Func( + [ + IDL.Record({ + arg: IDL.Vec(IDL.Nat8), + wasm_module: wasm_module, + mode: canister_install_mode, + canister_id: canister_id, + sender_canister_version: IDL.Opt(IDL.Nat64), + }), + ], + [], + [], ), - http_request: IDL.Func([http_request_args], [http_request_result], []), - install_chunked_code: IDL.Func([install_chunked_code_args], [], []), - install_code: IDL.Func([install_code_args], [], []), - node_metrics_history: IDL.Func([node_metrics_history_args], [node_metrics_history_result], []), provisional_create_canister_with_cycles: IDL.Func( - [provisional_create_canister_with_cycles_args], - [provisional_create_canister_with_cycles_result], + [ + IDL.Record({ + settings: IDL.Opt(canister_settings), + specified_id: IDL.Opt(canister_id), + amount: IDL.Opt(IDL.Nat), + sender_canister_version: IDL.Opt(IDL.Nat64), + }), + ], + [IDL.Record({ canister_id: canister_id })], + [], + ), + provisional_top_up_canister: IDL.Func( + [IDL.Record({ canister_id: canister_id, amount: IDL.Nat })], + [], + [], + ), + raw_rand: IDL.Func([], [IDL.Vec(IDL.Nat8)], []), + sign_with_ecdsa: IDL.Func( + [ + IDL.Record({ + key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), + message_hash: IDL.Vec(IDL.Nat8), + }), + ], + [IDL.Record({ signature: IDL.Vec(IDL.Nat8) })], + [], + ), + start_canister: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), + stop_canister: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), + stored_chunks: IDL.Func([IDL.Record({ canister_id: canister_id })], [IDL.Vec(chunk_hash)], []), + uninstall_code: IDL.Func( + [ + IDL.Record({ + canister_id: canister_id, + sender_canister_version: IDL.Opt(IDL.Nat64), + }), + ], + [], + [], + ), + update_settings: IDL.Func( + [ + IDL.Record({ + canister_id: IDL.Principal, + settings: canister_settings, + sender_canister_version: IDL.Opt(IDL.Nat64), + }), + ], + [], + [], + ), + upload_chunk: IDL.Func( + [ + IDL.Record({ + chunk: IDL.Vec(IDL.Nat8), + canister_id: IDL.Principal, + }), + ], + [chunk_hash], [], ), - provisional_top_up_canister: IDL.Func([provisional_top_up_canister_args], [], []), - raw_rand: IDL.Func([], [raw_rand_result], []), - sign_with_ecdsa: IDL.Func([sign_with_ecdsa_args], [sign_with_ecdsa_result], []), - start_canister: IDL.Func([start_canister_args], [], []), - stop_canister: IDL.Func([stop_canister_args], [], []), - stored_chunks: IDL.Func([stored_chunks_args], [stored_chunks_result], []), - uninstall_code: IDL.Func([uninstall_code_args], [], []), - update_settings: IDL.Func([update_settings_args], [], []), - upload_chunk: IDL.Func([upload_chunk_args], [upload_chunk_result], []), }); }; diff --git a/packages/agent/src/canisters/management_service.ts b/packages/agent/src/canisters/management_service.ts index 8cedd28d..8c864929 100644 --- a/packages/agent/src/canisters/management_service.ts +++ b/packages/agent/src/canisters/management_service.ts @@ -1,6 +1,6 @@ /** * This file is generated from the candid for asset management. - * didc version: 0.3.6 + * didc version: 0.4.0 */ // eslint-disable-next-line @typescript-eslint/ban-ts-comment @@ -10,86 +10,28 @@ import type { ActorMethod } from '@dfinity/agent'; import type { IDL } from '@dfinity/candid'; export type bitcoin_address = string; -export interface bitcoin_get_balance_args { - network: bitcoin_network; - address: bitcoin_address; - min_confirmations: [] | [number]; -} -export interface bitcoin_get_balance_query_args { - network: bitcoin_network; - address: bitcoin_address; - min_confirmations: [] | [number]; -} -export type bitcoin_get_balance_query_result = satoshi; -export type bitcoin_get_balance_result = satoshi; -export interface bitcoin_get_current_fee_percentiles_args { - network: bitcoin_network; -} -export type bitcoin_get_current_fee_percentiles_result = BigUint64Array | bigint[]; -export interface bitcoin_get_utxos_args { - network: bitcoin_network; - filter: [] | [{ page: Uint8Array | number[] } | { min_confirmations: number }]; - address: bitcoin_address; -} -export interface bitcoin_get_utxos_query_args { - network: bitcoin_network; - filter: [] | [{ page: Uint8Array | number[] } | { min_confirmations: number }]; - address: bitcoin_address; -} -export interface bitcoin_get_utxos_query_result { - next_page: [] | [Uint8Array | number[]]; - tip_height: number; - tip_block_hash: block_hash; - utxos: Array; -} -export interface bitcoin_get_utxos_result { - next_page: [] | [Uint8Array | number[]]; - tip_height: number; - tip_block_hash: block_hash; - utxos: Array; -} export type bitcoin_network = { mainnet: null } | { testnet: null }; -export interface bitcoin_send_transaction_args { - transaction: Uint8Array | number[]; - network: bitcoin_network; -} export type block_hash = Uint8Array | number[]; export type canister_id = Principal; -export interface canister_info_args { - canister_id: canister_id; - num_requested_changes: [] | [bigint]; -} -export interface canister_info_result { - controllers: Array; - module_hash: [] | [Uint8Array | number[]]; - recent_changes: Array; - total_num_changes: bigint; -} -export interface canister_log_record { - idx: bigint; - timestamp_nanos: bigint; - content: Uint8Array | number[]; -} +export type canister_install_mode = + | { reinstall: null } + | { + upgrade: + | [] + | [ + { + wasm_memory_persistence: [] | [{ keep: null } | { replace: null }]; + skip_pre_upgrade: [] | [boolean]; + }, + ]; + } + | { install: null }; export interface canister_settings { freezing_threshold: [] | [bigint]; controllers: [] | [Array]; - reserved_cycles_limit: [] | [bigint]; - log_visibility: [] | [log_visibility]; memory_allocation: [] | [bigint]; compute_allocation: [] | [bigint]; } -export interface canister_status_args { - canister_id: canister_id; -} -export interface canister_status_result { - status: { stopped: null } | { stopping: null } | { running: null }; - memory_size: bigint; - cycles: bigint; - settings: definite_canister_settings; - idle_cycles_burned_per_day: bigint; - module_hash: [] | [Uint8Array | number[]]; - reserved_cycles: bigint; -} export interface change { timestamp_nanos: bigint; canister_version: bigint; @@ -117,198 +59,207 @@ export type change_origin = }; }; export type chunk_hash = Uint8Array | number[]; -export interface clear_chunk_store_args { - canister_id: canister_id; -} -export interface create_canister_args { - settings: [] | [canister_settings]; - sender_canister_version: [] | [bigint]; -} -export interface create_canister_result { - canister_id: canister_id; -} export interface definite_canister_settings { freezing_threshold: bigint; controllers: Array; - reserved_cycles_limit: bigint; - log_visibility: log_visibility; memory_allocation: bigint; compute_allocation: bigint; } -export interface delete_canister_args { - canister_id: canister_id; -} -export interface deposit_cycles_args { - canister_id: canister_id; -} export type ecdsa_curve = { secp256k1: null }; -export interface ecdsa_public_key_args { - key_id: { name: string; curve: ecdsa_curve }; - canister_id: [] | [canister_id]; - derivation_path: Array; +export interface get_balance_request { + network: bitcoin_network; + address: bitcoin_address; + min_confirmations: [] | [number]; } -export interface ecdsa_public_key_result { - public_key: Uint8Array | number[]; - chain_code: Uint8Array | number[]; +export interface get_current_fee_percentiles_request { + network: bitcoin_network; } -export interface fetch_canister_logs_args { - canister_id: canister_id; +export interface get_utxos_request { + network: bitcoin_network; + filter: [] | [{ page: Uint8Array | number[] } | { min_confirmations: number }]; + address: bitcoin_address; } -export interface fetch_canister_logs_result { - canister_log_records: Array; +export interface get_utxos_response { + next_page: [] | [Uint8Array | number[]]; + tip_height: number; + tip_block_hash: block_hash; + utxos: Array; } export interface http_header { value: string; name: string; } -export interface http_request_args { - url: string; - method: { get: null } | { head: null } | { post: null }; - max_response_bytes: [] | [bigint]; - body: [] | [Uint8Array | number[]]; - transform: [] | [{ function: [Principal, string]; context: Uint8Array | number[] }]; - headers: Array; -} -export interface http_request_result { +export interface http_response { status: bigint; body: Uint8Array | number[]; headers: Array; } -export interface install_chunked_code_args { - arg: Uint8Array | number[]; - wasm_module_hash: Uint8Array | number[]; - mode: - | { reinstall: null } - | { upgrade: [] | [{ skip_pre_upgrade: [] | [boolean] }] } - | { install: null }; - chunk_hashes_list: Array; - target_canister: canister_id; - sender_canister_version: [] | [bigint]; - storage_canister: [] | [canister_id]; -} -export interface install_code_args { - arg: Uint8Array | number[]; - wasm_module: wasm_module; - mode: - | { reinstall: null } - | { upgrade: [] | [{ skip_pre_upgrade: [] | [boolean] }] } - | { install: null }; - canister_id: canister_id; - sender_canister_version: [] | [bigint]; -} -export type log_visibility = { controllers: null } | { public: null }; export type millisatoshi_per_byte = bigint; -export interface node_metrics { - num_block_failures_total: bigint; - node_id: Principal; - num_blocks_total: bigint; -} -export interface node_metrics_history_args { - start_at_timestamp_nanos: bigint; - subnet_id: Principal; -} -export type node_metrics_history_result = Array<{ - timestamp_nanos: bigint; - node_metrics: Array; -}>; export interface outpoint { txid: Uint8Array | number[]; vout: number; } -export interface provisional_create_canister_with_cycles_args { - settings: [] | [canister_settings]; - specified_id: [] | [canister_id]; - amount: [] | [bigint]; - sender_canister_version: [] | [bigint]; -} -export interface provisional_create_canister_with_cycles_result { - canister_id: canister_id; -} -export interface provisional_top_up_canister_args { - canister_id: canister_id; - amount: bigint; -} -export type raw_rand_result = Uint8Array | number[]; export type satoshi = bigint; -export interface sign_with_ecdsa_args { - key_id: { name: string; curve: ecdsa_curve }; - derivation_path: Array; - message_hash: Uint8Array | number[]; -} -export interface sign_with_ecdsa_result { - signature: Uint8Array | number[]; -} -export interface start_canister_args { - canister_id: canister_id; -} -export interface stop_canister_args { - canister_id: canister_id; -} -export interface stored_chunks_args { - canister_id: canister_id; -} -export type stored_chunks_result = Array; -export interface uninstall_code_args { - canister_id: canister_id; - sender_canister_version: [] | [bigint]; -} -export interface update_settings_args { - canister_id: Principal; - settings: canister_settings; - sender_canister_version: [] | [bigint]; -} -export interface upload_chunk_args { - chunk: Uint8Array | number[]; - canister_id: Principal; +export interface send_transaction_request { + transaction: Uint8Array | number[]; + network: bitcoin_network; } -export type upload_chunk_result = chunk_hash; export interface utxo { height: number; value: satoshi; outpoint: outpoint; } export type wasm_module = Uint8Array | number[]; -export default interface _SERVICE { - bitcoin_get_balance: ActorMethod<[bitcoin_get_balance_args], bitcoin_get_balance_result>; - bitcoin_get_balance_query: ActorMethod< - [bitcoin_get_balance_query_args], - bitcoin_get_balance_query_result - >; +export interface _SERVICE { + bitcoin_get_balance: ActorMethod<[get_balance_request], satoshi>; + bitcoin_get_balance_query: ActorMethod<[get_balance_request], satoshi>; bitcoin_get_current_fee_percentiles: ActorMethod< - [bitcoin_get_current_fee_percentiles_args], - bitcoin_get_current_fee_percentiles_result + [get_current_fee_percentiles_request], + BigUint64Array | bigint[] + >; + bitcoin_get_utxos: ActorMethod<[get_utxos_request], get_utxos_response>; + bitcoin_get_utxos_query: ActorMethod<[get_utxos_request], get_utxos_response>; + bitcoin_send_transaction: ActorMethod<[send_transaction_request], undefined>; + canister_info: ActorMethod< + [{ canister_id: canister_id; num_requested_changes: [] | [bigint] }], + { + controllers: Array; + module_hash: [] | [Uint8Array | number[]]; + recent_changes: Array; + total_num_changes: bigint; + } + >; + canister_status: ActorMethod< + [{ canister_id: canister_id }], + { + status: { stopped: null } | { stopping: null } | { running: null }; + memory_size: bigint; + cycles: bigint; + settings: definite_canister_settings; + idle_cycles_burned_per_day: bigint; + module_hash: [] | [Uint8Array | number[]]; + } + >; + clear_chunk_store: ActorMethod<[{ canister_id: canister_id }], undefined>; + create_canister: ActorMethod< + [ + { + settings: [] | [canister_settings]; + sender_canister_version: [] | [bigint]; + }, + ], + { canister_id: canister_id } + >; + delete_canister: ActorMethod<[{ canister_id: canister_id }], undefined>; + deposit_cycles: ActorMethod<[{ canister_id: canister_id }], undefined>; + ecdsa_public_key: ActorMethod< + [ + { + key_id: { name: string; curve: ecdsa_curve }; + canister_id: [] | [canister_id]; + derivation_path: Array; + }, + ], + { + public_key: Uint8Array | number[]; + chain_code: Uint8Array | number[]; + } + >; + http_request: ActorMethod< + [ + { + url: string; + method: { get: null } | { head: null } | { post: null }; + max_response_bytes: [] | [bigint]; + body: [] | [Uint8Array | number[]]; + transform: + | [] + | [ + { + function: [Principal, string]; + context: Uint8Array | number[]; + }, + ]; + headers: Array; + }, + ], + http_response + >; + install_chunked_code: ActorMethod< + [ + { + arg: Uint8Array | number[]; + wasm_module_hash: Uint8Array | number[]; + mode: canister_install_mode; + chunk_hashes_list: Array; + target_canister: canister_id; + sender_canister_version: [] | [bigint]; + storage_canister: [] | [canister_id]; + }, + ], + undefined >; - bitcoin_get_utxos: ActorMethod<[bitcoin_get_utxos_args], bitcoin_get_utxos_result>; - bitcoin_get_utxos_query: ActorMethod< - [bitcoin_get_utxos_query_args], - bitcoin_get_utxos_query_result + install_code: ActorMethod< + [ + { + arg: Uint8Array | number[]; + wasm_module: wasm_module; + mode: canister_install_mode; + canister_id: canister_id; + sender_canister_version: [] | [bigint]; + }, + ], + undefined >; - bitcoin_send_transaction: ActorMethod<[bitcoin_send_transaction_args], undefined>; - canister_info: ActorMethod<[canister_info_args], canister_info_result>; - canister_status: ActorMethod<[canister_status_args], canister_status_result>; - clear_chunk_store: ActorMethod<[clear_chunk_store_args], undefined>; - create_canister: ActorMethod<[create_canister_args], create_canister_result>; - delete_canister: ActorMethod<[delete_canister_args], undefined>; - deposit_cycles: ActorMethod<[deposit_cycles_args], undefined>; - ecdsa_public_key: ActorMethod<[ecdsa_public_key_args], ecdsa_public_key_result>; - fetch_canister_logs: ActorMethod<[fetch_canister_logs_args], fetch_canister_logs_result>; - http_request: ActorMethod<[http_request_args], http_request_result>; - install_chunked_code: ActorMethod<[install_chunked_code_args], undefined>; - install_code: ActorMethod<[install_code_args], undefined>; - node_metrics_history: ActorMethod<[node_metrics_history_args], node_metrics_history_result>; provisional_create_canister_with_cycles: ActorMethod< - [provisional_create_canister_with_cycles_args], - provisional_create_canister_with_cycles_result + [ + { + settings: [] | [canister_settings]; + specified_id: [] | [canister_id]; + amount: [] | [bigint]; + sender_canister_version: [] | [bigint]; + }, + ], + { canister_id: canister_id } + >; + provisional_top_up_canister: ActorMethod< + [{ canister_id: canister_id; amount: bigint }], + undefined + >; + raw_rand: ActorMethod<[], Uint8Array | number[]>; + sign_with_ecdsa: ActorMethod< + [ + { + key_id: { name: string; curve: ecdsa_curve }; + derivation_path: Array; + message_hash: Uint8Array | number[]; + }, + ], + { signature: Uint8Array | number[] } + >; + start_canister: ActorMethod<[{ canister_id: canister_id }], undefined>; + stop_canister: ActorMethod<[{ canister_id: canister_id }], undefined>; + stored_chunks: ActorMethod<[{ canister_id: canister_id }], Array>; + uninstall_code: ActorMethod< + [ + { + canister_id: canister_id; + sender_canister_version: [] | [bigint]; + }, + ], + undefined + >; + update_settings: ActorMethod< + [ + { + canister_id: Principal; + settings: canister_settings; + sender_canister_version: [] | [bigint]; + }, + ], + undefined >; - provisional_top_up_canister: ActorMethod<[provisional_top_up_canister_args], undefined>; - raw_rand: ActorMethod<[], raw_rand_result>; - sign_with_ecdsa: ActorMethod<[sign_with_ecdsa_args], sign_with_ecdsa_result>; - start_canister: ActorMethod<[start_canister_args], undefined>; - stop_canister: ActorMethod<[stop_canister_args], undefined>; - stored_chunks: ActorMethod<[stored_chunks_args], stored_chunks_result>; - uninstall_code: ActorMethod<[uninstall_code_args], undefined>; - update_settings: ActorMethod<[update_settings_args], undefined>; - upload_chunk: ActorMethod<[upload_chunk_args], upload_chunk_result>; + upload_chunk: ActorMethod<[{ chunk: Uint8Array | number[]; canister_id: Principal }], chunk_hash>; } export declare const idlFactory: IDL.InterfaceFactory; export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; From b4f4682b318315233456b6852ffff8cc262b9ed6 Mon Sep 17 00:00:00 2001 From: Kyle Peacock Date: Mon, 3 Jun 2024 16:26:18 -0700 Subject: [PATCH 2/4] updating actor and management_service --- packages/agent/src/actor.ts | 6 ++---- packages/agent/src/canisters/management_service.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/agent/src/actor.ts b/packages/agent/src/actor.ts index 42834339..e221775c 100644 --- a/packages/agent/src/actor.ts +++ b/packages/agent/src/actor.ts @@ -16,7 +16,7 @@ import { RequestId } from './request_id'; import { toHex } from './utils/buffer'; import { CreateCertificateOptions } from './certificate'; import managementCanisterIdl from './canisters/management_idl'; -import _SERVICE, { canister_settings } from './canisters/management_service'; +import _SERVICE, { canister_install_mode, canister_settings } from './canisters/management_service'; export class ActorCallError extends AgentError { constructor( @@ -243,7 +243,7 @@ export class Actor { public static async install( fields: { module: ArrayBuffer; - mode?: CanisterInstallMode; + mode?: canister_install_mode; arg?: ArrayBuffer; }, config: ActorConfig, @@ -278,8 +278,6 @@ export class Actor { compute_allocation: settings.compute_allocation ? [settings.compute_allocation] : [], freezing_threshold: settings.freezing_threshold ? [settings.freezing_threshold] : [], memory_allocation: settings.memory_allocation ? [settings.memory_allocation] : [], - reserved_cycles_limit: [], - log_visibility: [], }, ]; } diff --git a/packages/agent/src/canisters/management_service.ts b/packages/agent/src/canisters/management_service.ts index 8c864929..617c0687 100644 --- a/packages/agent/src/canisters/management_service.ts +++ b/packages/agent/src/canisters/management_service.ts @@ -110,7 +110,7 @@ export interface utxo { outpoint: outpoint; } export type wasm_module = Uint8Array | number[]; -export interface _SERVICE { +export default interface _SERVICE { bitcoin_get_balance: ActorMethod<[get_balance_request], satoshi>; bitcoin_get_balance_query: ActorMethod<[get_balance_request], satoshi>; bitcoin_get_current_fee_percentiles: ActorMethod< From 883091ac23ff9f9d757e445c32cb28bb442f529a Mon Sep 17 00:00:00 2001 From: Kyle Peacock Date: Tue, 4 Jun 2024 11:15:30 -0700 Subject: [PATCH 3/4] feat: automation to update the management canister IDL --- README.md | 2 + bin/update-management-idl.ts | 46 ++ docs/CHANGELOG.md | 1 + package-lock.json | 24 +- package.json | 6 +- packages/agent/src/canisters/management.did | 464 ++++++++++++------ .../agent/src/canisters/management_idl.ts | 437 +++++++++-------- .../agent/src/canisters/management_service.ts | 398 ++++++++------- 8 files changed, 859 insertions(+), 519 deletions(-) create mode 100644 bin/update-management-idl.ts diff --git a/README.md b/README.md index a93fdd35..09b83944 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ commands to keep in mind; The following scripts can be found in [./bin](./bin): +- update-management-idl - Update the management canister IDL in @dfinity/agent + Monorepo-related scripts run in this order, but are usually invoked by `npm install`: - npm-postinstall - Run with `npm run postinstall` in this monorepo package. diff --git a/bin/update-management-idl.ts b/bin/update-management-idl.ts new file mode 100644 index 00000000..664cce51 --- /dev/null +++ b/bin/update-management-idl.ts @@ -0,0 +1,46 @@ +import { $, cd, fetch } from 'zx'; +import path from 'path'; + +fetch( + 'https://raw.githubusercontent.com/dfinity/interface-spec/master/spec/_attachments/ic.did', +).then(async res => { + res.text().then(async text => { + const root = path.resolve(__dirname, '..'); + + const candid = text; + + await cd(`${root}/packages/agent/src/canisters`); + + await $`echo ${candid} > management.did`; + let ts = (await $`didc bind management.did -t ts`).toString(); + let js = (await $`didc bind management.did -t js`).toString(); + + const didcVersion = await $`didc --version`; + + const prefix = `/* + * This file is generated from the candid for asset management. + * didc version: ${didcVersion.toString().split(' ')[1].trim()} + */ +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore + +`; + + // replace first line of service + + ts.replace(`export interface _SERVICE {`, `export default interface _SERVICE {`); + js.replace(`export const idlFactory = ({ IDL }) => {`, `export default ({ IDL }) => {`); + + ts = prefix + ts; + js = prefix + js; + + await $`echo ${js} > management_idl.ts`; + await $`echo ${ts} > management_service.ts`; + + await cd(`${root}`); + + await $`npm run prettier:format`; + + console.log('Done!'); + }); +}); diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a711a142..6721977a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - feat!: add support for proof of absence in Certificate lookups +- feat: `update-management-idl` automation to update the management canister IDL in `@dfinity/agent` ### Changed diff --git a/package-lock.json b/package-lock.json index 10abd6e7..ed362955 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,8 @@ "typescript": "^5.2.2", "url": "^0.11.3", "webcrypto-core": "^1.7.7", - "yargs": "^17.7.2" + "yargs": "^17.7.2", + "zx": "^8.1.2" }, "engines": { "node": "^12 || ^14 || ^16 || >=17", @@ -5358,9 +5359,10 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.11.19", + "version": "20.14.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.1.tgz", + "integrity": "sha512-T2MzSGEu+ysB/FkWfqmhV3PLyQlowdptmmgD20C6QxsS8Fmv5SjpZ1ayXaEC0S21/h5UJ9iA6W/5vSNU5l00OA==", "dev": true, - "license": "MIT", "dependencies": { "undici-types": "~5.26.4" } @@ -20682,6 +20684,22 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/zx": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/zx/-/zx-8.1.2.tgz", + "integrity": "sha512-zkCiXKh8D/eo6r58OmJvO5mc2NthcSRvysb3fuS6VQlHPbEPBcxduRwM3m6ZfHj+7cLHcrahCnuO2TDAbW+6xw==", + "dev": true, + "bin": { + "zx": "build/cli.js" + }, + "engines": { + "node": ">= 12.17.0" + }, + "optionalDependencies": { + "@types/fs-extra": "^11.0.4", + "@types/node": ">=20.12.12" + } + }, "packages/agent": { "name": "@dfinity/agent", "version": "1.3.0", diff --git a/package.json b/package.json index 7be5da62..7f30f593 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "typescript": "^5.2.2", "url": "^0.11.3", "webcrypto-core": "^1.7.7", - "yargs": "^17.7.2" + "yargs": "^17.7.2", + "zx": "^8.1.2" }, "engines": { "node": "^12 || ^14 || ^16 || >=17", @@ -68,7 +69,8 @@ "prepare": "husky install", "prettier:check": "npx -p prettier -p pretty-quick pretty-quick --check", "prettier:format": "npx -p prettier -p pretty-quick pretty-quick", - "postversion": "npm run prettier:format" + "postversion": "npm run prettier:format", + "update-management-idl": "ts-node bin/update-management-idl.ts" }, "repository": { "type": "git", diff --git a/packages/agent/src/canisters/management.did b/packages/agent/src/canisters/management.did index 990bdf47..5af5069a 100644 --- a/packages/agent/src/canisters/management.did +++ b/packages/agent/src/canisters/management.did @@ -1,81 +1,84 @@ -// https://github.com/dfinity/interface-spec/blob/master/spec/_attachments/ic.did type canister_id = principal; type wasm_module = blob; +type log_visibility = variant { + controllers; + public; +}; + type canister_settings = record { - controllers : opt vec principal; - compute_allocation : opt nat; - memory_allocation : opt nat; - freezing_threshold : opt nat; + controllers : opt vec principal; + compute_allocation : opt nat; + memory_allocation : opt nat; + freezing_threshold : opt nat; + reserved_cycles_limit : opt nat; + log_visibility : opt log_visibility; }; type definite_canister_settings = record { - controllers : vec principal; - compute_allocation : nat; - memory_allocation : nat; - freezing_threshold : nat; + controllers : vec principal; + compute_allocation : nat; + memory_allocation : nat; + freezing_threshold : nat; + reserved_cycles_limit : nat; + log_visibility : log_visibility; }; type change_origin = variant { - from_user : record { - user_id : principal; - }; - from_canister : record { - canister_id : principal; - canister_version : opt nat64; - }; + from_user : record { + user_id : principal; + }; + from_canister : record { + canister_id : principal; + canister_version : opt nat64; + }; }; type change_details = variant { - creation : record { - controllers : vec principal; - }; - code_uninstall; - code_deployment : record { - mode : variant {install; reinstall; upgrade}; - module_hash : blob; - }; - controllers_change : record { - controllers : vec principal; - }; + creation : record { + controllers : vec principal; + }; + code_uninstall; + code_deployment : record { + mode : variant { install; reinstall; upgrade }; + module_hash : blob; + }; + controllers_change : record { + controllers : vec principal; + }; }; type change = record { - timestamp_nanos : nat64; - canister_version : nat64; - origin : change_origin; - details : change_details; + timestamp_nanos : nat64; + canister_version : nat64; + origin : change_origin; + details : change_details; }; -type canister_install_mode = variant { - install; - reinstall; - upgrade : opt record { - skip_pre_upgrade: opt bool; - wasm_memory_persistence : opt variant { - keep; - replace; - }; - }; +type chunk_hash = record { + hash : blob; }; -type chunk_hash = blob; - -type http_header = record { name: text; value: text }; +type http_header = record { + name : text; + value : text; +}; -type http_response = record { - status: nat; - headers: vec http_header; - body: blob; +type http_request_result = record { + status : nat; + headers : vec http_header; + body : blob; }; -type ecdsa_curve = variant { secp256k1; }; +type ecdsa_curve = variant { + secp256k1; +}; type satoshi = nat64; type bitcoin_network = variant { - mainnet; - testnet; + mainnet; + testnet; }; type bitcoin_address = text; @@ -83,146 +86,311 @@ type bitcoin_address = text; type block_hash = blob; type outpoint = record { - txid : blob; - vout : nat32 + txid : blob; + vout : nat32; }; type utxo = record { - outpoint: outpoint; - value: satoshi; - height: nat32; + outpoint : outpoint; + value : satoshi; + height : nat32; +}; + +type bitcoin_get_utxos_args = record { + address : bitcoin_address; + network : bitcoin_network; + filter : opt variant { + min_confirmations : nat32; + page : blob; + }; }; -type get_utxos_request = record { - address : bitcoin_address; - network: bitcoin_network; - filter: opt variant { - min_confirmations: nat32; - page: blob; - }; +type bitcoin_get_utxos_query_args = record { + address : bitcoin_address; + network : bitcoin_network; + filter : opt variant { + min_confirmations : nat32; + page : blob; + }; +}; + +type bitcoin_get_current_fee_percentiles_args = record { + network : bitcoin_network; }; -type get_current_fee_percentiles_request = record { - network: bitcoin_network; +type bitcoin_get_utxos_result = record { + utxos : vec utxo; + tip_block_hash : block_hash; + tip_height : nat32; + next_page : opt blob; }; -type get_utxos_response = record { - utxos: vec utxo; - tip_block_hash: block_hash; - tip_height: nat32; - next_page: opt blob; +type bitcoin_get_utxos_query_result = record { + utxos : vec utxo; + tip_block_hash : block_hash; + tip_height : nat32; + next_page : opt blob; }; -type get_balance_request = record { - address : bitcoin_address; - network: bitcoin_network; - min_confirmations: opt nat32; +type bitcoin_get_balance_args = record { + address : bitcoin_address; + network : bitcoin_network; + min_confirmations : opt nat32; }; -type send_transaction_request = record { - transaction: blob; - network: bitcoin_network; +type bitcoin_get_balance_query_args = record { + address : bitcoin_address; + network : bitcoin_network; + min_confirmations : opt nat32; +}; + +type bitcoin_send_transaction_args = record { + transaction : blob; + network : bitcoin_network; }; type millisatoshi_per_byte = nat64; -service ic : { - create_canister : (record { +type node_metrics = record { + node_id : principal; + num_blocks_proposed_total : nat64; + num_block_failures_total : nat64; +}; + +type create_canister_args = record { settings : opt canister_settings; sender_canister_version : opt nat64; - }) -> (record {canister_id : canister_id}); - update_settings : (record { +}; + +type create_canister_result = record { + canister_id : canister_id; +}; + +type update_settings_args = record { canister_id : principal; settings : canister_settings; sender_canister_version : opt nat64; - }) -> (); - upload_chunk : (record { +}; + +type upload_chunk_args = record { canister_id : principal; chunk : blob; - }) -> (chunk_hash); - clear_chunk_store: (record {canister_id : canister_id}) -> (); - stored_chunks: (record {canister_id : canister_id}) -> (vec chunk_hash); - install_code : (record { +}; + +type clear_chunk_store_args = record { + canister_id : canister_id; +}; + +type stored_chunks_args = record { + canister_id : canister_id; +}; + +type canister_install_mode = variant { + install; + reinstall; + upgrade : opt record { + skip_pre_upgrade : opt bool; + wasm_memory_persistence : opt variant { + keep; + replace; + }; + }; +}; + +type install_code_args = record { mode : canister_install_mode; canister_id : canister_id; wasm_module : wasm_module; arg : blob; sender_canister_version : opt nat64; - }) -> (); - install_chunked_code: (record { +}; + +type install_chunked_code_args = record { mode : canister_install_mode; - target_canister: canister_id; - storage_canister: opt canister_id; - chunk_hashes_list: vec chunk_hash; - wasm_module_hash: blob; + target_canister : canister_id; + store_canister : opt canister_id; + chunk_hashes_list : vec chunk_hash; + wasm_module_hash : blob; arg : blob; sender_canister_version : opt nat64; - }) -> (); - uninstall_code : (record { +}; + +type uninstall_code_args = record { canister_id : canister_id; sender_canister_version : opt nat64; - }) -> (); - start_canister : (record {canister_id : canister_id}) -> (); - stop_canister : (record {canister_id : canister_id}) -> (); - canister_status : (record {canister_id : canister_id}) -> (record { - status : variant { running; stopping; stopped }; - settings: definite_canister_settings; - module_hash: opt blob; - memory_size: nat; - cycles: nat; - idle_cycles_burned_per_day: nat; - }); - canister_info : (record { - canister_id : canister_id; - num_requested_changes : opt nat64; - }) -> (record { - total_num_changes : nat64; - recent_changes : vec change; - module_hash : opt blob; - controllers : vec principal; - }); - delete_canister : (record {canister_id : canister_id}) -> (); - deposit_cycles : (record {canister_id : canister_id}) -> (); - raw_rand : () -> (blob); - http_request : (record { +}; + +type start_canister_args = record { + canister_id : canister_id; +}; + +type stop_canister_args = record { + canister_id : canister_id; +}; + +type canister_status_args = record { + canister_id : canister_id; +}; + +type canister_status_result = record { + status : variant { running; stopping; stopped }; + settings : definite_canister_settings; + module_hash : opt blob; + memory_size : nat; + cycles : nat; + reserved_cycles : nat; + idle_cycles_burned_per_day : nat; + query_stats: record { + num_calls_total: nat; + num_instructions_total: nat; + request_payload_bytes_total: nat; + response_payload_bytes_total: nat; + }; +}; + +type canister_info_args = record { + canister_id : canister_id; + num_requested_changes : opt nat64; +}; + +type canister_info_result = record { + total_num_changes : nat64; + recent_changes : vec change; + module_hash : opt blob; + controllers : vec principal; +}; + +type delete_canister_args = record { + canister_id : canister_id; +}; + +type deposit_cycles_args = record { + canister_id : canister_id; +}; + +type http_request_args = record { url : text; - max_response_bytes: opt nat64; + max_response_bytes : opt nat64; method : variant { get; head; post }; - headers: vec http_header; + headers : vec http_header; body : opt blob; transform : opt record { - function : func (record {response : http_response; context : blob}) -> (http_response) query; - context : blob + function : func(record { response : http_request_result; context : blob }) -> (http_request_result) query; + context : blob; }; - }) -> (http_response); +}; - // Threshold ECDSA signature - ecdsa_public_key : (record { +type ecdsa_public_key_args = record { canister_id : opt canister_id; derivation_path : vec blob; - key_id : record { curve: ecdsa_curve; name: text }; - }) -> (record { public_key : blob; chain_code : blob; }); - sign_with_ecdsa : (record { + key_id : record { curve : ecdsa_curve; name : text }; +}; + +type ecdsa_public_key_result = record { + public_key : blob; + chain_code : blob; +}; + +type sign_with_ecdsa_args = record { message_hash : blob; derivation_path : vec blob; - key_id : record { curve: ecdsa_curve; name: text }; - }) -> (record { signature : blob }); - - // bitcoin interface - bitcoin_get_balance: (get_balance_request) -> (satoshi); - bitcoin_get_balance_query: (get_balance_request) -> (satoshi) query; - bitcoin_get_utxos: (get_utxos_request) -> (get_utxos_response); - bitcoin_get_utxos_query: (get_utxos_request) -> (get_utxos_response) query; - bitcoin_send_transaction: (send_transaction_request) -> (); - bitcoin_get_current_fee_percentiles: (get_current_fee_percentiles_request) -> (vec millisatoshi_per_byte); - - // provisional interfaces for the pre-ledger world - provisional_create_canister_with_cycles : (record { - amount: opt nat; + key_id : record { curve : ecdsa_curve; name : text }; +}; + +type sign_with_ecdsa_result = record { + signature : blob; +}; + +type node_metrics_history_args = record { + subnet_id : principal; + start_at_timestamp_nanos : nat64; +}; + +type node_metrics_history_result = vec record { + timestamp_nanos : nat64; + node_metrics : vec node_metrics; +}; + +type provisional_create_canister_with_cycles_args = record { + amount : opt nat; settings : opt canister_settings; - specified_id: opt canister_id; + specified_id : opt canister_id; sender_canister_version : opt nat64; - }) -> (record {canister_id : canister_id}); - provisional_top_up_canister : - (record { canister_id: canister_id; amount: nat }) -> (); -} +}; + +type provisional_create_canister_with_cycles_result = record { + canister_id : canister_id; +}; + +type provisional_top_up_canister_args = record { + canister_id : canister_id; + amount : nat; +}; + +type raw_rand_result = blob; + +type stored_chunks_result = vec chunk_hash; + +type upload_chunk_result = chunk_hash; + +type bitcoin_get_balance_result = satoshi; + +type bitcoin_get_balance_query_result = satoshi; + +type bitcoin_get_current_fee_percentiles_result = vec millisatoshi_per_byte; + +type fetch_canister_logs_args = record { + canister_id : canister_id; +}; + +type canister_log_record = record { + idx: nat64; + timestamp_nanos: nat64; + content: blob; +}; + +type fetch_canister_logs_result = record { + canister_log_records: vec canister_log_record; +}; + +service ic : { + create_canister : (create_canister_args) -> (create_canister_result); + update_settings : (update_settings_args) -> (); + upload_chunk : (upload_chunk_args) -> (upload_chunk_result); + clear_chunk_store : (clear_chunk_store_args) -> (); + stored_chunks : (stored_chunks_args) -> (stored_chunks_result); + install_code : (install_code_args) -> (); + install_chunked_code : (install_chunked_code_args) -> (); + uninstall_code : (uninstall_code_args) -> (); + start_canister : (start_canister_args) -> (); + stop_canister : (stop_canister_args) -> (); + canister_status : (canister_status_args) -> (canister_status_result); + canister_info : (canister_info_args) -> (canister_info_result); + delete_canister : (delete_canister_args) -> (); + deposit_cycles : (deposit_cycles_args) -> (); + raw_rand : () -> (raw_rand_result); + http_request : (http_request_args) -> (http_request_result); + + // Threshold ECDSA signature + ecdsa_public_key : (ecdsa_public_key_args) -> (ecdsa_public_key_result); + sign_with_ecdsa : (sign_with_ecdsa_args) -> (sign_with_ecdsa_result); + + // bitcoin interface + bitcoin_get_balance : (bitcoin_get_balance_args) -> (bitcoin_get_balance_result); + bitcoin_get_balance_query : (bitcoin_get_balance_query_args) -> (bitcoin_get_balance_query_result) query; + bitcoin_get_utxos : (bitcoin_get_utxos_args) -> (bitcoin_get_utxos_result); + bitcoin_get_utxos_query : (bitcoin_get_utxos_query_args) -> (bitcoin_get_utxos_query_result) query; + bitcoin_send_transaction : (bitcoin_send_transaction_args) -> (); + bitcoin_get_current_fee_percentiles : (bitcoin_get_current_fee_percentiles_args) -> (bitcoin_get_current_fee_percentiles_result); + + // metrics interface + node_metrics_history : (node_metrics_history_args) -> (node_metrics_history_result); + + // provisional interfaces for the pre-ledger world + provisional_create_canister_with_cycles : (provisional_create_canister_with_cycles_args) -> (provisional_create_canister_with_cycles_result); + provisional_top_up_canister : (provisional_top_up_canister_args) -> (); + + // canister logging + fetch_canister_logs : (fetch_canister_logs_args) -> (fetch_canister_logs_result) query; +}; + diff --git a/packages/agent/src/canisters/management_idl.ts b/packages/agent/src/canisters/management_idl.ts index e1eb20c0..d1cd62a5 100644 --- a/packages/agent/src/canisters/management_idl.ts +++ b/packages/agent/src/canisters/management_idl.ts @@ -1,27 +1,35 @@ -/** +/* * This file is generated from the candid for asset management. * didc version: 0.4.0 */ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore -export default ({ IDL }) => { + +export const idlFactory = ({ IDL }) => { const bitcoin_network = IDL.Variant({ mainnet: IDL.Null, testnet: IDL.Null, }); const bitcoin_address = IDL.Text; - const get_balance_request = IDL.Record({ + const bitcoin_get_balance_args = IDL.Record({ network: bitcoin_network, address: bitcoin_address, min_confirmations: IDL.Opt(IDL.Nat32), }); const satoshi = IDL.Nat64; - const get_current_fee_percentiles_request = IDL.Record({ + const bitcoin_get_balance_result = satoshi; + const bitcoin_get_balance_query_args = IDL.Record({ + network: bitcoin_network, + address: bitcoin_address, + min_confirmations: IDL.Opt(IDL.Nat32), + }); + const bitcoin_get_balance_query_result = satoshi; + const bitcoin_get_current_fee_percentiles_args = IDL.Record({ network: bitcoin_network, }); const millisatoshi_per_byte = IDL.Nat64; - const get_utxos_request = IDL.Record({ + const bitcoin_get_current_fee_percentiles_result = IDL.Vec(millisatoshi_per_byte); + const bitcoin_get_utxos_args = IDL.Record({ network: bitcoin_network, filter: IDL.Opt( IDL.Variant({ @@ -41,17 +49,37 @@ export default ({ IDL }) => { value: satoshi, outpoint: outpoint, }); - const get_utxos_response = IDL.Record({ + const bitcoin_get_utxos_result = IDL.Record({ + next_page: IDL.Opt(IDL.Vec(IDL.Nat8)), + tip_height: IDL.Nat32, + tip_block_hash: block_hash, + utxos: IDL.Vec(utxo), + }); + const bitcoin_get_utxos_query_args = IDL.Record({ + network: bitcoin_network, + filter: IDL.Opt( + IDL.Variant({ + page: IDL.Vec(IDL.Nat8), + min_confirmations: IDL.Nat32, + }), + ), + address: bitcoin_address, + }); + const bitcoin_get_utxos_query_result = IDL.Record({ next_page: IDL.Opt(IDL.Vec(IDL.Nat8)), tip_height: IDL.Nat32, tip_block_hash: block_hash, utxos: IDL.Vec(utxo), }); - const send_transaction_request = IDL.Record({ + const bitcoin_send_transaction_args = IDL.Record({ transaction: IDL.Vec(IDL.Nat8), network: bitcoin_network, }); const canister_id = IDL.Principal; + const canister_info_args = IDL.Record({ + canister_id: canister_id, + num_requested_changes: IDL.Opt(IDL.Nat64), + }); const change_origin = IDL.Variant({ from_user: IDL.Record({ user_id: IDL.Principal }), from_canister: IDL.Record({ @@ -80,25 +108,111 @@ export default ({ IDL }) => { origin: change_origin, details: change_details, }); + const canister_info_result = IDL.Record({ + controllers: IDL.Vec(IDL.Principal), + module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), + recent_changes: IDL.Vec(change), + total_num_changes: IDL.Nat64, + }); + const canister_status_args = IDL.Record({ canister_id: canister_id }); + const log_visibility = IDL.Variant({ + controllers: IDL.Null, + public: IDL.Null, + }); const definite_canister_settings = IDL.Record({ freezing_threshold: IDL.Nat, controllers: IDL.Vec(IDL.Principal), + reserved_cycles_limit: IDL.Nat, + log_visibility: log_visibility, memory_allocation: IDL.Nat, compute_allocation: IDL.Nat, }); + const canister_status_result = IDL.Record({ + status: IDL.Variant({ + stopped: IDL.Null, + stopping: IDL.Null, + running: IDL.Null, + }), + memory_size: IDL.Nat, + cycles: IDL.Nat, + settings: definite_canister_settings, + query_stats: IDL.Record({ + response_payload_bytes_total: IDL.Nat, + num_instructions_total: IDL.Nat, + num_calls_total: IDL.Nat, + request_payload_bytes_total: IDL.Nat, + }), + idle_cycles_burned_per_day: IDL.Nat, + module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), + reserved_cycles: IDL.Nat, + }); + const clear_chunk_store_args = IDL.Record({ canister_id: canister_id }); const canister_settings = IDL.Record({ freezing_threshold: IDL.Opt(IDL.Nat), controllers: IDL.Opt(IDL.Vec(IDL.Principal)), + reserved_cycles_limit: IDL.Opt(IDL.Nat), + log_visibility: IDL.Opt(log_visibility), memory_allocation: IDL.Opt(IDL.Nat), compute_allocation: IDL.Opt(IDL.Nat), }); + const create_canister_args = IDL.Record({ + settings: IDL.Opt(canister_settings), + sender_canister_version: IDL.Opt(IDL.Nat64), + }); + const create_canister_result = IDL.Record({ canister_id: canister_id }); + const delete_canister_args = IDL.Record({ canister_id: canister_id }); + const deposit_cycles_args = IDL.Record({ canister_id: canister_id }); const ecdsa_curve = IDL.Variant({ secp256k1: IDL.Null }); + const ecdsa_public_key_args = IDL.Record({ + key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), + canister_id: IDL.Opt(canister_id), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), + }); + const ecdsa_public_key_result = IDL.Record({ + public_key: IDL.Vec(IDL.Nat8), + chain_code: IDL.Vec(IDL.Nat8), + }); + const fetch_canister_logs_args = IDL.Record({ canister_id: canister_id }); + const canister_log_record = IDL.Record({ + idx: IDL.Nat64, + timestamp_nanos: IDL.Nat64, + content: IDL.Vec(IDL.Nat8), + }); + const fetch_canister_logs_result = IDL.Record({ + canister_log_records: IDL.Vec(canister_log_record), + }); const http_header = IDL.Record({ value: IDL.Text, name: IDL.Text }); - const http_response = IDL.Record({ + const http_request_result = IDL.Record({ status: IDL.Nat, body: IDL.Vec(IDL.Nat8), headers: IDL.Vec(http_header), }); + const http_request_args = IDL.Record({ + url: IDL.Text, + method: IDL.Variant({ + get: IDL.Null, + head: IDL.Null, + post: IDL.Null, + }), + max_response_bytes: IDL.Opt(IDL.Nat64), + body: IDL.Opt(IDL.Vec(IDL.Nat8)), + transform: IDL.Opt( + IDL.Record({ + function: IDL.Func( + [ + IDL.Record({ + context: IDL.Vec(IDL.Nat8), + response: http_request_result, + }), + ], + [http_request_result], + ['query'], + ), + context: IDL.Vec(IDL.Nat8), + }), + ), + headers: IDL.Vec(http_header), + }); const canister_install_mode = IDL.Variant({ reinstall: IDL.Null, upgrade: IDL.Opt( @@ -109,205 +223,130 @@ export default ({ IDL }) => { ), install: IDL.Null, }); - const chunk_hash = IDL.Vec(IDL.Nat8); + const chunk_hash = IDL.Record({ hash: IDL.Vec(IDL.Nat8) }); + const install_chunked_code_args = IDL.Record({ + arg: IDL.Vec(IDL.Nat8), + wasm_module_hash: IDL.Vec(IDL.Nat8), + mode: canister_install_mode, + chunk_hashes_list: IDL.Vec(chunk_hash), + target_canister: canister_id, + store_canister: IDL.Opt(canister_id), + sender_canister_version: IDL.Opt(IDL.Nat64), + }); const wasm_module = IDL.Vec(IDL.Nat8); + const install_code_args = IDL.Record({ + arg: IDL.Vec(IDL.Nat8), + wasm_module: wasm_module, + mode: canister_install_mode, + canister_id: canister_id, + sender_canister_version: IDL.Opt(IDL.Nat64), + }); + const node_metrics_history_args = IDL.Record({ + start_at_timestamp_nanos: IDL.Nat64, + subnet_id: IDL.Principal, + }); + const node_metrics = IDL.Record({ + num_block_failures_total: IDL.Nat64, + node_id: IDL.Principal, + num_blocks_proposed_total: IDL.Nat64, + }); + const node_metrics_history_result = IDL.Vec( + IDL.Record({ + timestamp_nanos: IDL.Nat64, + node_metrics: IDL.Vec(node_metrics), + }), + ); + const provisional_create_canister_with_cycles_args = IDL.Record({ + settings: IDL.Opt(canister_settings), + specified_id: IDL.Opt(canister_id), + amount: IDL.Opt(IDL.Nat), + sender_canister_version: IDL.Opt(IDL.Nat64), + }); + const provisional_create_canister_with_cycles_result = IDL.Record({ + canister_id: canister_id, + }); + const provisional_top_up_canister_args = IDL.Record({ + canister_id: canister_id, + amount: IDL.Nat, + }); + const raw_rand_result = IDL.Vec(IDL.Nat8); + const sign_with_ecdsa_args = IDL.Record({ + key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), + message_hash: IDL.Vec(IDL.Nat8), + }); + const sign_with_ecdsa_result = IDL.Record({ + signature: IDL.Vec(IDL.Nat8), + }); + const start_canister_args = IDL.Record({ canister_id: canister_id }); + const stop_canister_args = IDL.Record({ canister_id: canister_id }); + const stored_chunks_args = IDL.Record({ canister_id: canister_id }); + const stored_chunks_result = IDL.Vec(chunk_hash); + const uninstall_code_args = IDL.Record({ + canister_id: canister_id, + sender_canister_version: IDL.Opt(IDL.Nat64), + }); + const update_settings_args = IDL.Record({ + canister_id: IDL.Principal, + settings: canister_settings, + sender_canister_version: IDL.Opt(IDL.Nat64), + }); + const upload_chunk_args = IDL.Record({ + chunk: IDL.Vec(IDL.Nat8), + canister_id: IDL.Principal, + }); + const upload_chunk_result = chunk_hash; return IDL.Service({ - bitcoin_get_balance: IDL.Func([get_balance_request], [satoshi], []), - bitcoin_get_balance_query: IDL.Func([get_balance_request], [satoshi], ['query']), - bitcoin_get_current_fee_percentiles: IDL.Func( - [get_current_fee_percentiles_request], - [IDL.Vec(millisatoshi_per_byte)], - [], - ), - bitcoin_get_utxos: IDL.Func([get_utxos_request], [get_utxos_response], []), - bitcoin_get_utxos_query: IDL.Func([get_utxos_request], [get_utxos_response], ['query']), - bitcoin_send_transaction: IDL.Func([send_transaction_request], [], []), - canister_info: IDL.Func( - [ - IDL.Record({ - canister_id: canister_id, - num_requested_changes: IDL.Opt(IDL.Nat64), - }), - ], - [ - IDL.Record({ - controllers: IDL.Vec(IDL.Principal), - module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), - recent_changes: IDL.Vec(change), - total_num_changes: IDL.Nat64, - }), - ], - [], - ), - canister_status: IDL.Func( - [IDL.Record({ canister_id: canister_id })], - [ - IDL.Record({ - status: IDL.Variant({ - stopped: IDL.Null, - stopping: IDL.Null, - running: IDL.Null, - }), - memory_size: IDL.Nat, - cycles: IDL.Nat, - settings: definite_canister_settings, - idle_cycles_burned_per_day: IDL.Nat, - module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), - }), - ], - [], + bitcoin_get_balance: IDL.Func([bitcoin_get_balance_args], [bitcoin_get_balance_result], []), + bitcoin_get_balance_query: IDL.Func( + [bitcoin_get_balance_query_args], + [bitcoin_get_balance_query_result], + ['query'], ), - clear_chunk_store: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), - create_canister: IDL.Func( - [ - IDL.Record({ - settings: IDL.Opt(canister_settings), - sender_canister_version: IDL.Opt(IDL.Nat64), - }), - ], - [IDL.Record({ canister_id: canister_id })], - [], - ), - delete_canister: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), - deposit_cycles: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), - ecdsa_public_key: IDL.Func( - [ - IDL.Record({ - key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), - canister_id: IDL.Opt(canister_id), - derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), - }), - ], - [ - IDL.Record({ - public_key: IDL.Vec(IDL.Nat8), - chain_code: IDL.Vec(IDL.Nat8), - }), - ], - [], - ), - http_request: IDL.Func( - [ - IDL.Record({ - url: IDL.Text, - method: IDL.Variant({ - get: IDL.Null, - head: IDL.Null, - post: IDL.Null, - }), - max_response_bytes: IDL.Opt(IDL.Nat64), - body: IDL.Opt(IDL.Vec(IDL.Nat8)), - transform: IDL.Opt( - IDL.Record({ - function: IDL.Func( - [ - IDL.Record({ - context: IDL.Vec(IDL.Nat8), - response: http_response, - }), - ], - [http_response], - ['query'], - ), - context: IDL.Vec(IDL.Nat8), - }), - ), - headers: IDL.Vec(http_header), - }), - ], - [http_response], + bitcoin_get_current_fee_percentiles: IDL.Func( + [bitcoin_get_current_fee_percentiles_args], + [bitcoin_get_current_fee_percentiles_result], [], ), - install_chunked_code: IDL.Func( - [ - IDL.Record({ - arg: IDL.Vec(IDL.Nat8), - wasm_module_hash: IDL.Vec(IDL.Nat8), - mode: canister_install_mode, - chunk_hashes_list: IDL.Vec(chunk_hash), - target_canister: canister_id, - sender_canister_version: IDL.Opt(IDL.Nat64), - storage_canister: IDL.Opt(canister_id), - }), - ], - [], - [], + bitcoin_get_utxos: IDL.Func([bitcoin_get_utxos_args], [bitcoin_get_utxos_result], []), + bitcoin_get_utxos_query: IDL.Func( + [bitcoin_get_utxos_query_args], + [bitcoin_get_utxos_query_result], + ['query'], ), - install_code: IDL.Func( - [ - IDL.Record({ - arg: IDL.Vec(IDL.Nat8), - wasm_module: wasm_module, - mode: canister_install_mode, - canister_id: canister_id, - sender_canister_version: IDL.Opt(IDL.Nat64), - }), - ], - [], - [], + bitcoin_send_transaction: IDL.Func([bitcoin_send_transaction_args], [], []), + canister_info: IDL.Func([canister_info_args], [canister_info_result], []), + canister_status: IDL.Func([canister_status_args], [canister_status_result], []), + clear_chunk_store: IDL.Func([clear_chunk_store_args], [], []), + create_canister: IDL.Func([create_canister_args], [create_canister_result], []), + delete_canister: IDL.Func([delete_canister_args], [], []), + deposit_cycles: IDL.Func([deposit_cycles_args], [], []), + ecdsa_public_key: IDL.Func([ecdsa_public_key_args], [ecdsa_public_key_result], []), + fetch_canister_logs: IDL.Func( + [fetch_canister_logs_args], + [fetch_canister_logs_result], + ['query'], ), + http_request: IDL.Func([http_request_args], [http_request_result], []), + install_chunked_code: IDL.Func([install_chunked_code_args], [], []), + install_code: IDL.Func([install_code_args], [], []), + node_metrics_history: IDL.Func([node_metrics_history_args], [node_metrics_history_result], []), provisional_create_canister_with_cycles: IDL.Func( - [ - IDL.Record({ - settings: IDL.Opt(canister_settings), - specified_id: IDL.Opt(canister_id), - amount: IDL.Opt(IDL.Nat), - sender_canister_version: IDL.Opt(IDL.Nat64), - }), - ], - [IDL.Record({ canister_id: canister_id })], - [], - ), - provisional_top_up_canister: IDL.Func( - [IDL.Record({ canister_id: canister_id, amount: IDL.Nat })], - [], - [], - ), - raw_rand: IDL.Func([], [IDL.Vec(IDL.Nat8)], []), - sign_with_ecdsa: IDL.Func( - [ - IDL.Record({ - key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), - derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), - message_hash: IDL.Vec(IDL.Nat8), - }), - ], - [IDL.Record({ signature: IDL.Vec(IDL.Nat8) })], - [], - ), - start_canister: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), - stop_canister: IDL.Func([IDL.Record({ canister_id: canister_id })], [], []), - stored_chunks: IDL.Func([IDL.Record({ canister_id: canister_id })], [IDL.Vec(chunk_hash)], []), - uninstall_code: IDL.Func( - [ - IDL.Record({ - canister_id: canister_id, - sender_canister_version: IDL.Opt(IDL.Nat64), - }), - ], - [], - [], - ), - update_settings: IDL.Func( - [ - IDL.Record({ - canister_id: IDL.Principal, - settings: canister_settings, - sender_canister_version: IDL.Opt(IDL.Nat64), - }), - ], - [], - [], - ), - upload_chunk: IDL.Func( - [ - IDL.Record({ - chunk: IDL.Vec(IDL.Nat8), - canister_id: IDL.Principal, - }), - ], - [chunk_hash], + [provisional_create_canister_with_cycles_args], + [provisional_create_canister_with_cycles_result], [], ), + provisional_top_up_canister: IDL.Func([provisional_top_up_canister_args], [], []), + raw_rand: IDL.Func([], [raw_rand_result], []), + sign_with_ecdsa: IDL.Func([sign_with_ecdsa_args], [sign_with_ecdsa_result], []), + start_canister: IDL.Func([start_canister_args], [], []), + stop_canister: IDL.Func([stop_canister_args], [], []), + stored_chunks: IDL.Func([stored_chunks_args], [stored_chunks_result], []), + uninstall_code: IDL.Func([uninstall_code_args], [], []), + update_settings: IDL.Func([update_settings_args], [], []), + upload_chunk: IDL.Func([upload_chunk_args], [upload_chunk_result], []), }); }; +export const init = ({ IDL }) => { + return []; +}; diff --git a/packages/agent/src/canisters/management_service.ts b/packages/agent/src/canisters/management_service.ts index 617c0687..0f96933e 100644 --- a/packages/agent/src/canisters/management_service.ts +++ b/packages/agent/src/canisters/management_service.ts @@ -1,18 +1,70 @@ -/** +/* * This file is generated from the candid for asset management. * didc version: 0.4.0 */ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore + import type { Principal } from '@dfinity/principal'; import type { ActorMethod } from '@dfinity/agent'; import type { IDL } from '@dfinity/candid'; export type bitcoin_address = string; +export interface bitcoin_get_balance_args { + network: bitcoin_network; + address: bitcoin_address; + min_confirmations: [] | [number]; +} +export interface bitcoin_get_balance_query_args { + network: bitcoin_network; + address: bitcoin_address; + min_confirmations: [] | [number]; +} +export type bitcoin_get_balance_query_result = satoshi; +export type bitcoin_get_balance_result = satoshi; +export interface bitcoin_get_current_fee_percentiles_args { + network: bitcoin_network; +} +export type bitcoin_get_current_fee_percentiles_result = BigUint64Array | bigint[]; +export interface bitcoin_get_utxos_args { + network: bitcoin_network; + filter: [] | [{ page: Uint8Array | number[] } | { min_confirmations: number }]; + address: bitcoin_address; +} +export interface bitcoin_get_utxos_query_args { + network: bitcoin_network; + filter: [] | [{ page: Uint8Array | number[] } | { min_confirmations: number }]; + address: bitcoin_address; +} +export interface bitcoin_get_utxos_query_result { + next_page: [] | [Uint8Array | number[]]; + tip_height: number; + tip_block_hash: block_hash; + utxos: Array; +} +export interface bitcoin_get_utxos_result { + next_page: [] | [Uint8Array | number[]]; + tip_height: number; + tip_block_hash: block_hash; + utxos: Array; +} export type bitcoin_network = { mainnet: null } | { testnet: null }; +export interface bitcoin_send_transaction_args { + transaction: Uint8Array | number[]; + network: bitcoin_network; +} export type block_hash = Uint8Array | number[]; export type canister_id = Principal; +export interface canister_info_args { + canister_id: canister_id; + num_requested_changes: [] | [bigint]; +} +export interface canister_info_result { + controllers: Array; + module_hash: [] | [Uint8Array | number[]]; + recent_changes: Array; + total_num_changes: bigint; +} export type canister_install_mode = | { reinstall: null } | { @@ -26,12 +78,37 @@ export type canister_install_mode = ]; } | { install: null }; +export interface canister_log_record { + idx: bigint; + timestamp_nanos: bigint; + content: Uint8Array | number[]; +} export interface canister_settings { freezing_threshold: [] | [bigint]; controllers: [] | [Array]; + reserved_cycles_limit: [] | [bigint]; + log_visibility: [] | [log_visibility]; memory_allocation: [] | [bigint]; compute_allocation: [] | [bigint]; } +export interface canister_status_args { + canister_id: canister_id; +} +export interface canister_status_result { + status: { stopped: null } | { stopping: null } | { running: null }; + memory_size: bigint; + cycles: bigint; + settings: definite_canister_settings; + query_stats: { + response_payload_bytes_total: bigint; + num_instructions_total: bigint; + num_calls_total: bigint; + request_payload_bytes_total: bigint; + }; + idle_cycles_burned_per_day: bigint; + module_hash: [] | [Uint8Array | number[]]; + reserved_cycles: bigint; +} export interface change { timestamp_nanos: bigint; canister_version: bigint; @@ -58,208 +135,195 @@ export type change_origin = canister_id: Principal; }; }; -export type chunk_hash = Uint8Array | number[]; +export interface chunk_hash { + hash: Uint8Array | number[]; +} +export interface clear_chunk_store_args { + canister_id: canister_id; +} +export interface create_canister_args { + settings: [] | [canister_settings]; + sender_canister_version: [] | [bigint]; +} +export interface create_canister_result { + canister_id: canister_id; +} export interface definite_canister_settings { freezing_threshold: bigint; controllers: Array; + reserved_cycles_limit: bigint; + log_visibility: log_visibility; memory_allocation: bigint; compute_allocation: bigint; } +export interface delete_canister_args { + canister_id: canister_id; +} +export interface deposit_cycles_args { + canister_id: canister_id; +} export type ecdsa_curve = { secp256k1: null }; -export interface get_balance_request { - network: bitcoin_network; - address: bitcoin_address; - min_confirmations: [] | [number]; +export interface ecdsa_public_key_args { + key_id: { name: string; curve: ecdsa_curve }; + canister_id: [] | [canister_id]; + derivation_path: Array; } -export interface get_current_fee_percentiles_request { - network: bitcoin_network; +export interface ecdsa_public_key_result { + public_key: Uint8Array | number[]; + chain_code: Uint8Array | number[]; } -export interface get_utxos_request { - network: bitcoin_network; - filter: [] | [{ page: Uint8Array | number[] } | { min_confirmations: number }]; - address: bitcoin_address; +export interface fetch_canister_logs_args { + canister_id: canister_id; } -export interface get_utxos_response { - next_page: [] | [Uint8Array | number[]]; - tip_height: number; - tip_block_hash: block_hash; - utxos: Array; +export interface fetch_canister_logs_result { + canister_log_records: Array; } export interface http_header { value: string; name: string; } -export interface http_response { +export interface http_request_args { + url: string; + method: { get: null } | { head: null } | { post: null }; + max_response_bytes: [] | [bigint]; + body: [] | [Uint8Array | number[]]; + transform: [] | [{ function: [Principal, string]; context: Uint8Array | number[] }]; + headers: Array; +} +export interface http_request_result { status: bigint; body: Uint8Array | number[]; headers: Array; } +export interface install_chunked_code_args { + arg: Uint8Array | number[]; + wasm_module_hash: Uint8Array | number[]; + mode: canister_install_mode; + chunk_hashes_list: Array; + target_canister: canister_id; + store_canister: [] | [canister_id]; + sender_canister_version: [] | [bigint]; +} +export interface install_code_args { + arg: Uint8Array | number[]; + wasm_module: wasm_module; + mode: canister_install_mode; + canister_id: canister_id; + sender_canister_version: [] | [bigint]; +} +export type log_visibility = { controllers: null } | { public: null }; export type millisatoshi_per_byte = bigint; +export interface node_metrics { + num_block_failures_total: bigint; + node_id: Principal; + num_blocks_proposed_total: bigint; +} +export interface node_metrics_history_args { + start_at_timestamp_nanos: bigint; + subnet_id: Principal; +} +export type node_metrics_history_result = Array<{ + timestamp_nanos: bigint; + node_metrics: Array; +}>; export interface outpoint { txid: Uint8Array | number[]; vout: number; } +export interface provisional_create_canister_with_cycles_args { + settings: [] | [canister_settings]; + specified_id: [] | [canister_id]; + amount: [] | [bigint]; + sender_canister_version: [] | [bigint]; +} +export interface provisional_create_canister_with_cycles_result { + canister_id: canister_id; +} +export interface provisional_top_up_canister_args { + canister_id: canister_id; + amount: bigint; +} +export type raw_rand_result = Uint8Array | number[]; export type satoshi = bigint; -export interface send_transaction_request { - transaction: Uint8Array | number[]; - network: bitcoin_network; +export interface sign_with_ecdsa_args { + key_id: { name: string; curve: ecdsa_curve }; + derivation_path: Array; + message_hash: Uint8Array | number[]; } +export interface sign_with_ecdsa_result { + signature: Uint8Array | number[]; +} +export interface start_canister_args { + canister_id: canister_id; +} +export interface stop_canister_args { + canister_id: canister_id; +} +export interface stored_chunks_args { + canister_id: canister_id; +} +export type stored_chunks_result = Array; +export interface uninstall_code_args { + canister_id: canister_id; + sender_canister_version: [] | [bigint]; +} +export interface update_settings_args { + canister_id: Principal; + settings: canister_settings; + sender_canister_version: [] | [bigint]; +} +export interface upload_chunk_args { + chunk: Uint8Array | number[]; + canister_id: Principal; +} +export type upload_chunk_result = chunk_hash; export interface utxo { height: number; value: satoshi; outpoint: outpoint; } export type wasm_module = Uint8Array | number[]; -export default interface _SERVICE { - bitcoin_get_balance: ActorMethod<[get_balance_request], satoshi>; - bitcoin_get_balance_query: ActorMethod<[get_balance_request], satoshi>; - bitcoin_get_current_fee_percentiles: ActorMethod< - [get_current_fee_percentiles_request], - BigUint64Array | bigint[] - >; - bitcoin_get_utxos: ActorMethod<[get_utxos_request], get_utxos_response>; - bitcoin_get_utxos_query: ActorMethod<[get_utxos_request], get_utxos_response>; - bitcoin_send_transaction: ActorMethod<[send_transaction_request], undefined>; - canister_info: ActorMethod< - [{ canister_id: canister_id; num_requested_changes: [] | [bigint] }], - { - controllers: Array; - module_hash: [] | [Uint8Array | number[]]; - recent_changes: Array; - total_num_changes: bigint; - } - >; - canister_status: ActorMethod< - [{ canister_id: canister_id }], - { - status: { stopped: null } | { stopping: null } | { running: null }; - memory_size: bigint; - cycles: bigint; - settings: definite_canister_settings; - idle_cycles_burned_per_day: bigint; - module_hash: [] | [Uint8Array | number[]]; - } - >; - clear_chunk_store: ActorMethod<[{ canister_id: canister_id }], undefined>; - create_canister: ActorMethod< - [ - { - settings: [] | [canister_settings]; - sender_canister_version: [] | [bigint]; - }, - ], - { canister_id: canister_id } - >; - delete_canister: ActorMethod<[{ canister_id: canister_id }], undefined>; - deposit_cycles: ActorMethod<[{ canister_id: canister_id }], undefined>; - ecdsa_public_key: ActorMethod< - [ - { - key_id: { name: string; curve: ecdsa_curve }; - canister_id: [] | [canister_id]; - derivation_path: Array; - }, - ], - { - public_key: Uint8Array | number[]; - chain_code: Uint8Array | number[]; - } - >; - http_request: ActorMethod< - [ - { - url: string; - method: { get: null } | { head: null } | { post: null }; - max_response_bytes: [] | [bigint]; - body: [] | [Uint8Array | number[]]; - transform: - | [] - | [ - { - function: [Principal, string]; - context: Uint8Array | number[]; - }, - ]; - headers: Array; - }, - ], - http_response +export interface _SERVICE { + bitcoin_get_balance: ActorMethod<[bitcoin_get_balance_args], bitcoin_get_balance_result>; + bitcoin_get_balance_query: ActorMethod< + [bitcoin_get_balance_query_args], + bitcoin_get_balance_query_result >; - install_chunked_code: ActorMethod< - [ - { - arg: Uint8Array | number[]; - wasm_module_hash: Uint8Array | number[]; - mode: canister_install_mode; - chunk_hashes_list: Array; - target_canister: canister_id; - sender_canister_version: [] | [bigint]; - storage_canister: [] | [canister_id]; - }, - ], - undefined + bitcoin_get_current_fee_percentiles: ActorMethod< + [bitcoin_get_current_fee_percentiles_args], + bitcoin_get_current_fee_percentiles_result >; - install_code: ActorMethod< - [ - { - arg: Uint8Array | number[]; - wasm_module: wasm_module; - mode: canister_install_mode; - canister_id: canister_id; - sender_canister_version: [] | [bigint]; - }, - ], - undefined + bitcoin_get_utxos: ActorMethod<[bitcoin_get_utxos_args], bitcoin_get_utxos_result>; + bitcoin_get_utxos_query: ActorMethod< + [bitcoin_get_utxos_query_args], + bitcoin_get_utxos_query_result >; + bitcoin_send_transaction: ActorMethod<[bitcoin_send_transaction_args], undefined>; + canister_info: ActorMethod<[canister_info_args], canister_info_result>; + canister_status: ActorMethod<[canister_status_args], canister_status_result>; + clear_chunk_store: ActorMethod<[clear_chunk_store_args], undefined>; + create_canister: ActorMethod<[create_canister_args], create_canister_result>; + delete_canister: ActorMethod<[delete_canister_args], undefined>; + deposit_cycles: ActorMethod<[deposit_cycles_args], undefined>; + ecdsa_public_key: ActorMethod<[ecdsa_public_key_args], ecdsa_public_key_result>; + fetch_canister_logs: ActorMethod<[fetch_canister_logs_args], fetch_canister_logs_result>; + http_request: ActorMethod<[http_request_args], http_request_result>; + install_chunked_code: ActorMethod<[install_chunked_code_args], undefined>; + install_code: ActorMethod<[install_code_args], undefined>; + node_metrics_history: ActorMethod<[node_metrics_history_args], node_metrics_history_result>; provisional_create_canister_with_cycles: ActorMethod< - [ - { - settings: [] | [canister_settings]; - specified_id: [] | [canister_id]; - amount: [] | [bigint]; - sender_canister_version: [] | [bigint]; - }, - ], - { canister_id: canister_id } - >; - provisional_top_up_canister: ActorMethod< - [{ canister_id: canister_id; amount: bigint }], - undefined - >; - raw_rand: ActorMethod<[], Uint8Array | number[]>; - sign_with_ecdsa: ActorMethod< - [ - { - key_id: { name: string; curve: ecdsa_curve }; - derivation_path: Array; - message_hash: Uint8Array | number[]; - }, - ], - { signature: Uint8Array | number[] } - >; - start_canister: ActorMethod<[{ canister_id: canister_id }], undefined>; - stop_canister: ActorMethod<[{ canister_id: canister_id }], undefined>; - stored_chunks: ActorMethod<[{ canister_id: canister_id }], Array>; - uninstall_code: ActorMethod< - [ - { - canister_id: canister_id; - sender_canister_version: [] | [bigint]; - }, - ], - undefined - >; - update_settings: ActorMethod< - [ - { - canister_id: Principal; - settings: canister_settings; - sender_canister_version: [] | [bigint]; - }, - ], - undefined + [provisional_create_canister_with_cycles_args], + provisional_create_canister_with_cycles_result >; - upload_chunk: ActorMethod<[{ chunk: Uint8Array | number[]; canister_id: Principal }], chunk_hash>; + provisional_top_up_canister: ActorMethod<[provisional_top_up_canister_args], undefined>; + raw_rand: ActorMethod<[], raw_rand_result>; + sign_with_ecdsa: ActorMethod<[sign_with_ecdsa_args], sign_with_ecdsa_result>; + start_canister: ActorMethod<[start_canister_args], undefined>; + stop_canister: ActorMethod<[stop_canister_args], undefined>; + stored_chunks: ActorMethod<[stored_chunks_args], stored_chunks_result>; + uninstall_code: ActorMethod<[uninstall_code_args], undefined>; + update_settings: ActorMethod<[update_settings_args], undefined>; + upload_chunk: ActorMethod<[upload_chunk_args], upload_chunk_result>; } export declare const idlFactory: IDL.InterfaceFactory; export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; From dc26d71162aea0cd497c4e4fbb96c54e101e3fbe Mon Sep 17 00:00:00 2001 From: Kyle Peacock Date: Tue, 4 Jun 2024 15:49:11 -0700 Subject: [PATCH 4/4] cleaning up ts errors --- bin/update-management-idl.ts | 7 +++++-- packages/agent/src/actor.ts | 2 ++ packages/agent/src/canisters/management_idl.ts | 5 +---- packages/agent/src/canisters/management_service.ts | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/update-management-idl.ts b/bin/update-management-idl.ts index 664cce51..638255f8 100644 --- a/bin/update-management-idl.ts +++ b/bin/update-management-idl.ts @@ -28,8 +28,11 @@ fetch( // replace first line of service - ts.replace(`export interface _SERVICE {`, `export default interface _SERVICE {`); - js.replace(`export const idlFactory = ({ IDL }) => {`, `export default ({ IDL }) => {`); + ts = ts.replace(`export interface _SERVICE {`, `export default interface _SERVICE {`); + js = js.replace(`export const idlFactory = ({ IDL }) => {`, `export default ({ IDL }) => {`); + + // remove init function + js = js.split('export const init = ({ IDL }) => {')[0]; ts = prefix + ts; js = prefix + js; diff --git a/packages/agent/src/actor.ts b/packages/agent/src/actor.ts index e221775c..cc4193ea 100644 --- a/packages/agent/src/actor.ts +++ b/packages/agent/src/actor.ts @@ -278,6 +278,8 @@ export class Actor { compute_allocation: settings.compute_allocation ? [settings.compute_allocation] : [], freezing_threshold: settings.freezing_threshold ? [settings.freezing_threshold] : [], memory_allocation: settings.memory_allocation ? [settings.memory_allocation] : [], + reserved_cycles_limit: [], + log_visibility: [], }, ]; } diff --git a/packages/agent/src/canisters/management_idl.ts b/packages/agent/src/canisters/management_idl.ts index d1cd62a5..aaf376a2 100644 --- a/packages/agent/src/canisters/management_idl.ts +++ b/packages/agent/src/canisters/management_idl.ts @@ -5,7 +5,7 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore -export const idlFactory = ({ IDL }) => { +export default ({ IDL }) => { const bitcoin_network = IDL.Variant({ mainnet: IDL.Null, testnet: IDL.Null, @@ -347,6 +347,3 @@ export const idlFactory = ({ IDL }) => { upload_chunk: IDL.Func([upload_chunk_args], [upload_chunk_result], []), }); }; -export const init = ({ IDL }) => { - return []; -}; diff --git a/packages/agent/src/canisters/management_service.ts b/packages/agent/src/canisters/management_service.ts index 0f96933e..10041ac2 100644 --- a/packages/agent/src/canisters/management_service.ts +++ b/packages/agent/src/canisters/management_service.ts @@ -283,7 +283,7 @@ export interface utxo { outpoint: outpoint; } export type wasm_module = Uint8Array | number[]; -export interface _SERVICE { +export default interface _SERVICE { bitcoin_get_balance: ActorMethod<[bitcoin_get_balance_args], bitcoin_get_balance_result>; bitcoin_get_balance_query: ActorMethod< [bitcoin_get_balance_query_args],