diff --git a/canisters/management/bitcoin.ts b/canisters/management/bitcoin.ts deleted file mode 100644 index f794201109..0000000000 --- a/canisters/management/bitcoin.ts +++ /dev/null @@ -1,102 +0,0 @@ -// TODO I am thinking we should use the same names as ic-btc-types - -import { IDL } from '../../src/lib/stable'; - -export const BitcoinAddress = IDL.Text; -export type BitcoinAddress = string; - -export const BlockHash = IDL.Vec(IDL.Nat8); -export type BlockHash = Uint8Array; - -export const Page = IDL.Vec(IDL.Nat8); -export type Page = Uint8Array; - -export const MillisatoshiPerByte = IDL.Nat64; -export type MillisatoshiPerByte = bigint; - -export const Satoshi = IDL.Nat64; -export type Satoshi = bigint; - -export const BitcoinNetwork = IDL.Variant({ - mainnet: IDL.Null, - regtest: IDL.Null, - testnet: IDL.Null -}); -export type BitcoinNetwork = - | { mainnet: null } - | { regtest: null } - | { testnet: null }; - -export const Outpoint = IDL.Record({ - txid: IDL.Vec(IDL.Nat8), - vout: IDL.Nat32 -}); -export type Outpoint = { txid: Uint8Array; vout: number }; - -export const Utxo = IDL.Record({ - height: IDL.Nat32, - outpoint: Outpoint, - value: Satoshi -}); -export type Utxo = { height: number; outpoint: Outpoint; value: Satoshi }; - -export const UtxosFilter = IDL.Variant({ - MinConfirmations: IDL.Nat32, - Page: Page -}); -export type UtxosFilter = { MinConfirmations: number } | { Page: Page }; - -export const GetBalanceArgs = IDL.Record({ - address: BitcoinAddress, - min_confirmations: IDL.Opt(IDL.Nat32), - network: BitcoinNetwork -}); -export type GetBalanceArgs = { - address: BitcoinAddress; - min_confirmations: [number] | []; -}; - -export const GetCurrentFeePercentilesArgs = IDL.Record({ - network: BitcoinNetwork -}); -export type GetCurrentFeePercentilesArgs = { network: BitcoinNetwork }; - -export const GetUtxosArgs = IDL.Record({ - address: BitcoinAddress, - filter: IDL.Opt(UtxosFilter), - network: BitcoinNetwork -}); -export type GetUtxosArgs = { - address: BitcoinAddress; - filter: [UtxosFilter] | []; -}; - -export const GetUtxosResult = IDL.Record({ - next_page: IDL.Opt(Page), - tip_block_hash: BlockHash, - tip_height: IDL.Nat32, - utxos: IDL.Vec(Utxo) -}); -export type GetUtxosResult = { - next_page: [Page] | []; - tip_block_hash: BlockHash; - tip_height: number; - utxos: Utxo[]; -}; - -export const SendTransactionArgs = IDL.Record({ - transaction: IDL.Vec(IDL.Nat8), - network: BitcoinNetwork -}); -export type SendTransactionArgs = { - transaction: Uint8Array; - network: BitcoinNetwork; -}; - -export const SendTransactionError = IDL.Variant({ - MalformedTransaction: IDL.Null, - QueueFull: IDL.Null -}); -export type SendTransactionError = - | { MalformedTransaction: null } - | { QueueFull: null }; diff --git a/canisters/management/canister_info.ts b/canisters/management/canister_info.ts deleted file mode 100644 index dddab18789..0000000000 --- a/canisters/management/canister_info.ts +++ /dev/null @@ -1,191 +0,0 @@ -// JS docs licensed under: -// -// - https://github.com/dfinity/cdk-rs/blob/main/LICENSE -// -// Some documentation changed from original work. - -import { IDL } from '@dfinity/candid'; -import { Principal } from '@dfinity/principal'; - -/** Argument type of managementCanister.canister_info. */ -export const CanisterInfoArgs = IDL.Record({ - /** Principal of the canister. */ - canister_id: IDL.Principal, - /** - * Number of most recent changes requested to be retrieved from canister - * history. No changes are retrieved if this field is `None`. - */ - num_requested_changes: IDL.Opt(IDL.Nat64) -}); -export type CanisterInfoArgs = { - canister_id: Principal; - num_requested_changes: [bigint] | []; -}; - -/** Details about a canister creation. */ -export const CreationRecord = IDL.Record({ - /** Initial set of canister controllers. */ - controllers: IDL.Vec(IDL.Principal) -}); -export type CreationRecord = { - controllers: Principal[]; -}; - -/** The mode with which a canister is installed. */ -export const CanisterInstallMode = IDL.Variant({ - /** A fresh install of a new canister. */ - install: IDL.Null, - /** Reinstalling a canister that was already installed. */ - reinstall: IDL.Null, - /** Upgrade an existing canister. */ - upgrade: IDL.Null -}); -export type CanisterInstallMode = - | { - install: null; - } - | { - reinstall: null; - } - | { - upgrade: null; - }; - -/** Details about a canister code deployment. */ -export const CodeDeploymentRecord = IDL.Record({ - /** See {@link CanisterInstallMode}. */ - mode: CanisterInstallMode, - /** A SHA256 hash of the new module installed on the canister. */ - module_hash: IDL.Vec(IDL.Nat8) -}); -export type CodeDeploymentRecord = { - mode: CanisterInstallMode; - module_hash: Uint8Array; -}; - -/** Details about updating canister controllers. */ -export const ControllersChangeRecord = IDL.Record({ - /** The full new set of canister controllers. */ - controllers: IDL.Vec(IDL.Principal) -}); -export type ControllersChangeRecord = { - controllers: Principal[]; -}; - -/** Provides details on the respective canister change. */ -export const CanisterChangeDetails = IDL.Variant({ - /** See {@link CreationRecord}. */ - creation: CreationRecord, - /** Uninstalling canister's module */ - code_uninstall: IDL.Null, - /** See {@link CodeDeploymentRecord}. */ - code_deployment: CodeDeploymentRecord, - /** See {@link ControllersChangeRecord}. */ - controllers_change: ControllersChangeRecord -}); -export type CanisterChangeDetails = - | { - creation: CreationRecord; - } - | { - code_uninstall: null; - } - | { - code_deployment: CodeDeploymentRecord; - } - | { - controllers_change: ControllersChangeRecord; - }; - -/** Details about a canister change initiated by a user. */ -export const FromUserRecord = IDL.Record({ - /** Principle of the user. */ - user_id: IDL.Principal -}); -export type FromUserRecord = { - user_id: Principal; -}; - -/** - * Details about a canister change initiated by a canister (called *originator*). - */ -export const FromCanisterRecord = IDL.Record({ - /** Principle of the originator. */ - canister_id: IDL.Principal, - /** - * Canister version of the originator when the originator initiated the - * change. This is `None` if the original does not include its canister - * version in the field `sender_canister_version` of the management canister - * payload. - */ - canister_version: IDL.Opt(IDL.Nat64) -}); -export type FromCanisterRecord = { - canister_id: Principal; - canister_version: [bigint] | []; -}; - -/** Provides details on who initiated a canister change. */ -export const CanisterChangeOrigin = IDL.Variant({ - /** See {@link FromUserRecord}. */ - from_user: FromUserRecord, - /** See {@link FromCanisterRecord}. */ - from_canister: FromCanisterRecord -}); -export type CanisterChangeOrigin = - | { - from_user: FromUserRecord; - } - | { - from_canister: FromCanisterRecord; - }; - -/** Represents a canister change as stored in the canister history. */ -export const CanisterChange = IDL.Record({ - /** - * The system timestamp (in nanoseconds since Unix Epoch) at which the - * change was performed - */ - timestamp_nanos: IDL.Nat64, - /** The canister version after performing the change. */ - canister_version: IDL.Nat64, - /** The change’s origin (a user or a canister). */ - origin: CanisterChangeOrigin, - /** The change’s details. */ - details: CanisterChangeDetails -}); -export type CanisterChange = { - timestamp_nanos: bigint; - canister_version: bigint; - origin: CanisterChangeOrigin; - details: CanisterChangeDetails; -}; - -/** Return type of managementCanister.canister_info. */ -export const CanisterInfoResult = IDL.Record({ - /** - * Total number of changes ever recorded in canister history. This might be - * higher than the number of canister changes in recent_changes because the - * IC might drop old canister changes from its history (with 20 most recent - * canister changes to always remain in the list). - */ - total_num_changes: IDL.Nat64, - /** - * The canister changes stored in the order from the oldest to the most - * recent. - */ - recent_changes: IDL.Vec(CanisterChange), - /** - * A SHA256 hash of the module installed on the canister. This is null if - * the canister is empty. - */ - module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), - /** Controllers of the canister. */ - controllers: IDL.Vec(IDL.Principal) -}); -export type CanisterInfoResult = { - total_num_changes: bigint; - recent_changes: CanisterChange[]; - module_hash: [Uint8Array] | []; - controllers: Principal[]; -}; diff --git a/canisters/management/canister_management.ts b/canisters/management/canister_management.ts deleted file mode 100644 index 37fc55cfbb..0000000000 --- a/canisters/management/canister_management.ts +++ /dev/null @@ -1,263 +0,0 @@ -import { IDL } from '@dfinity/candid'; -import { Principal } from '@dfinity/principal'; - -export const CanisterId = IDL.Principal; -export type CanisterId = Principal; - -export const UserId = IDL.Principal; -export type UserId = Principal; - -export const WasmModule = IDL.Vec(IDL.Nat8); -export type WasmModule = Uint8Array; - -export const CanisterSettings = IDL.Record({ - /** - * A list of principals. Must be between 0 and 10 in size. This - * value is assigned to the controllers attribute of the canister. - * - * Default value: A list containing only the caller of the - * {@link Management.create_canister} call - */ - controllers: IDL.Opt(IDL.Vec(IDL.Principal)), - compute_allocation: IDL.Opt(IDL.Nat), - memory_allocation: IDL.Opt(IDL.Nat), - freezing_threshold: IDL.Opt(IDL.Nat), - reserved_cycles_limit: IDL.Opt(IDL.Nat) -}); -export type CanisterSettings = { - controllers: [Principal[]] | []; - compute_allocation: [bigint] | []; - memory_allocation: [bigint] | []; - freezing_threshold: [bigint] | []; - reserved_cycles_limit: [bigint] | []; -}; - -export const ChunkHash = IDL.Record({ - hash: IDL.Vec(IDL.Nat8) -}); -export type ChunkHash = { - hash: Uint8Array; -}; - -/** - * The arguments to provide to the management canister's create_canister - * method - */ -export const CreateCanisterArgs = IDL.Record({ - settings: IDL.Opt(CanisterSettings), - sender_canister_version: IDL.Opt(IDL.Nat64) -}); -export type CreateCanisterArgs = { - settings: [CanisterSettings] | []; - sender_canister_version: [bigint] | []; -}; - -export const CreateCanisterResult = IDL.Record({ - canister_id: IDL.Principal -}); -export type CreateCanisterResult = { - canister_id: Principal; -}; - -export const CanisterStatus = IDL.Variant({ - running: IDL.Null, - stopping: IDL.Null, - stopped: IDL.Null -}); -export type CanisterStatus = { - running: null; - stopping: null; - stopped: null; -}; - -export const DefiniteCanisterSettings = IDL.Record({ - controllers: IDL.Vec(IDL.Principal), - compute_allocation: IDL.Nat, - memory_allocation: IDL.Nat, - freezing_threshold: IDL.Nat, - reserved_cycles_limit: IDL.Nat -}); -export type DefiniteCanisterSettings = { - controllers: Principal[]; - compute_allocation: bigint; - memory_allocation: bigint; - freezing_threshold: bigint; - reserved_cycles_limit: bigint; -}; - -export const CanisterStatusResult = IDL.Record({ - status: CanisterStatus, - settings: DefiniteCanisterSettings, - module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)), - memory_size: IDL.Nat, - cycles: IDL.Nat, - reserved_cycles: IDL.Nat, - idle_cycles_burned_per_day: IDL.Nat -}); -export type CanisterStatusResult = { - status: CanisterStatus; - settings: DefiniteCanisterSettings; - module_hash: [Uint8Array] | []; - memory_size: bigint; - cycles: bigint; - reserved_cycles: bigint; - idle_cycles_burned_per_day: bigint; -}; - -export const CanisterStatusArgs = IDL.Record({ - canister_id: IDL.Principal -}); -export type CanisterStatusArgs = { - canister_id: Principal; -}; - -export const UpdateSettingsArgs = IDL.Record({ - canister_id: CanisterId, - settings: CanisterSettings, - sender_canister_version: IDL.Opt(IDL.Nat64) -}); -export type UpdateSettingsArgs = { - canister_id: CanisterId; - settings: CanisterSettings; - sender_canister_version: [bigint] | []; -}; - -export const UploadChunkArgs = IDL.Record({ - canister_id: CanisterId, - chunk: IDL.Vec(IDL.Nat8) -}); -export type UploadChunkArgs = { - canister_id: CanisterId; - chunk: Uint8Array; -}; - -export const UploadChunkResult = ChunkHash; -export type UploadChunkResult = ChunkHash; - -export const ClearChunkStoreArgs = IDL.Record({ - canister_id: CanisterId -}); -export type ClearChunkStoreArgs = { - canister_id: CanisterId; -}; - -export const StoredChunksArgs = IDL.Record({ - canister_id: CanisterId -}); -export type StoredChunksArgs = { - canister_id: CanisterId; -}; - -export const StoredChunksResult = IDL.Vec(ChunkHash); -export type StoredChunksResult = ChunkHash[]; - -export const InstallCodeMode = IDL.Variant({ - install: IDL.Null, - reinstall: IDL.Null, - upgrade: IDL.Null -}); -export type InstallCodeMode = { - install: null; - reinstall: null; - upgrade: null; -}; - -export const InstallCodeArgs = IDL.Record({ - mode: InstallCodeMode, - canister_id: CanisterId, - wasm_module: WasmModule, - arg: IDL.Vec(IDL.Nat8), - sender_canister_version: IDL.Opt(IDL.Nat64) -}); -export type InstallCodeArgs = { - mode: InstallCodeMode; - canister_id: CanisterId; - wasm_module: WasmModule; - arg: Uint8Array; - sender_canister_version: [bigint] | []; -}; - -export const InstallChunkedCodeArgs = IDL.Record({ - mode: InstallCodeMode, - target_canister: CanisterId, - store_canister: IDL.Opt(CanisterId), - chunk_hashes_list: IDL.Vec(ChunkHash), - wasm_module_hash: IDL.Vec(IDL.Nat8), - arg: IDL.Vec(IDL.Nat8), - sender_canister_version: IDL.Opt(IDL.Nat64) -}); -export type InstallChunkedCodeArgs = { - mode: InstallCodeMode; - target_canister: CanisterId; - store_canister: [CanisterId] | []; - chunk_hashes_list: ChunkHash[]; - wasm_module_hash: Uint8Array; - arg: Uint8Array; - sender_canister_version: [bigint] | []; -}; - -export const UninstallCodeArgs = IDL.Record({ - canister_id: CanisterId, - sender_canister_version: IDL.Opt(IDL.Nat64) -}); -export type UninstallCodeArgs = { - canister_id: CanisterId; - sender_canister_version: [bigint] | []; -}; - -export const StartCanisterArgs = IDL.Record({ - canister_id: CanisterId -}); -export type StartCanisterArgs = { - canister_id: CanisterId; -}; - -export const StopCanisterArgs = IDL.Record({ - canister_id: CanisterId -}); -export type StopCanisterArgs = { - canister_id: CanisterId; -}; - -export const DeleteCanisterArgs = IDL.Record({ - canister_id: CanisterId -}); -export type DeleteCanisterArgs = { - canister_id: CanisterId; -}; - -export const ProvisionalCreateCanisterWithCyclesArgs = IDL.Record({ - amount: IDL.Opt(IDL.Nat), - settings: IDL.Opt(CanisterSettings), - specified_id: IDL.Opt(CanisterId), - sender_canister_version: IDL.Opt(IDL.Nat64) -}); -export type ProvisionalCreateCanisterWithCyclesArgs = { - amount: [bigint] | []; - settings: [CanisterSettings] | []; - specified_id: [CanisterId] | []; - sender_canister_version: [bigint] | []; -}; - -export const ProvisionalCreateCanisterWithCyclesResult = IDL.Record({ - canister_id: CanisterId -}); -export type ProvisionalCreateCanisterWithCyclesResult = { - canister_id: CanisterId; -}; - -export const ProvisionalTopUpCanisterArgs = IDL.Record({ - canister_id: CanisterId, - amount: IDL.Nat -}); -export type ProvisionalTopUpCanisterArgs = { - canister_id: CanisterId; - amount: bigint; -}; - -export const DepositCyclesArgs = IDL.Record({ - canister_id: CanisterId -}); -export type DepositCyclesArgs = { - canister_id: CanisterId; -}; diff --git a/canisters/management/http_request.ts b/canisters/management/http_request.ts deleted file mode 100644 index 332788ac7d..0000000000 --- a/canisters/management/http_request.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { IDL } from '@dfinity/candid'; -import { Principal } from '@dfinity/principal'; - -export const HttpHeader = IDL.Record({ - name: IDL.Text, - value: IDL.Text -}); -export type HttpHeader = { - name: string; - value: string; -}; - -export const HttpMethod = IDL.Variant({ - get: IDL.Null, - head: IDL.Null, - post: IDL.Null -}); -export type HttpMethod = - | { - get: null; - } - | { head: null } - | { post: null }; - -export const HttpResponse = IDL.Record({ - /** - * The response status (e.g., 200, 404) - */ - status: IDL.Nat, - /** - * List of HTTP response headers and their corresponding values. The number - * of headers must not exceed 64. The total number of bytes representing the - * header names and values must not exceed 48KiB. The total number of bytes - * representing the header names and values must not exceed 48KiB. - */ - headers: IDL.Vec(HttpHeader), - /** - * The response's body encoded as bytes - */ - body: IDL.Vec(IDL.Nat8) -}); -export type HttpResponse = { - status: bigint; - headers: HttpHeader[]; - body: Uint8Array; -}; - -export const HttpTransformArgs = IDL.Record({ - response: HttpResponse, - context: IDL.Vec(IDL.Nat8) -}); -export type HttpTransformArgs = { - response: HttpResponse; - context: Uint8Array; -}; - -export const HttpTransformFunc = IDL.Func( - [HttpTransformArgs], - [HttpResponse], - ['query'] -); -export type HttpTransformFunc = [Principal, string]; - -export const HttpTransform = IDL.Record({ - /** - * Transforms raw responses to sanitized responses. Must be an exported - * canister method. - */ - function: HttpTransformFunc, - /** - * A byte-encoded value that is provided to the function upon - * invocation, along with the response to be sanitized. - */ - context: IDL.Vec(IDL.Nat8) -}); -export type HttpTransform = { - function: HttpTransformFunc; - context: Uint8Array; -}; - -export const HttpRequestArgs = IDL.Record({ - /** - * The requested URL. The URL must be valid according to - * https://www.ietf.org/rfc/rfc3986.txt[RFC-3986] and its length must not - * exceed 8192. The URL may specify a custom port number. - */ - url: IDL.Text, - /** - * Specifies the maximal size of the response in bytes. If provided, the - * value must not exceed 2MB (2,000,000B). The call will be charged based on - * this parameter. If not provided, the maximum of 2MB will be used. - */ - max_response_bytes: IDL.Opt(IDL.Nat64), - /** - * Currently, only GET, HEAD, and POST are supported - */ - method: HttpMethod, - /** - * List of HTTP request headers and their corresponding values. The number - * of headers must not exceed 64. The total number of bytes representing the - * header names and values must not exceed 48KiB. The total number of bytes - * representing the header names and values must not exceed 48KiB. - */ - headers: IDL.Vec(HttpHeader), - /** - * The content of the request's body - */ - body: IDL.Opt(IDL.Vec(IDL.Nat8)), - /** - * An optional function that transforms raw responses to sanitized responses, - * and a byte-encoded context that is provided to the function upon - * invocation, along with the response to be sanitized. - * If provided, the calling canister itself must export this function. - */ - transform: IDL.Opt(HttpTransform) -}); -export type HttpRequestArgs = { - url: string; - max_response_bytes: [bigint] | []; - method: HttpMethod; - headers: HttpHeader[]; - body: [Uint8Array] | []; - transform: [HttpTransform] | []; -}; diff --git a/canisters/management/ic.did b/canisters/management/ic.did index 28b974ffa1..0d60e8dfd9 100644 --- a/canisters/management/ic.did +++ b/canisters/management/ic.did @@ -1,4 +1,4 @@ -// Taken from: https://github.com/dfinity/interface-spec/blob/6e00887946b612a1169964fc75ee14f57c0ce65d/spec/_attachments/ic.did +// Taken from: https://github.com/dfinity/interface-spec/blob/c28afe4269b14f102c78b69225b7c380b826cf0f/spec/_attachments/ic.did // Copyright 2021 DFINITY Foundation // @@ -17,12 +17,19 @@ 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; + wasm_memory_limit : opt nat; }; type definite_canister_settings = record { @@ -31,6 +38,8 @@ type definite_canister_settings = record { memory_allocation : nat; freezing_threshold : nat; reserved_cycles_limit : nat; + log_visibility : log_visibility; + wasm_memory_limit : nat; }; type change_origin = variant { @@ -83,17 +92,29 @@ type ecdsa_curve = variant { secp256k1; }; +type schnorr_algorithm = variant { + bip340secp256k1; + ed25519; +}; + type satoshi = nat64; +// TODO https://forum.dfinity.org/t/regtest-removed-from-management-canister-candid-file/35277 type bitcoin_network = variant { mainnet; testnet; - regtest; + regtest; // TODO Added by Demergent Labs }; type bitcoin_address = text; -type block_hash = blob; +type bitcoin_block_hash = blob; + +type bitcoin_block_header = blob; + +type millisatoshi_per_byte = nat64; + +type bitcoin_block_height = nat32; type outpoint = record { txid : blob; @@ -115,30 +136,10 @@ type bitcoin_get_utxos_args = record { }; }; -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 bitcoin_get_utxos_result = 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; + tip_block_hash : bitcoin_block_hash; + tip_height : bitcoin_block_height; next_page : opt blob; }; @@ -148,22 +149,33 @@ type bitcoin_get_balance_args = record { min_confirmations : opt nat32; }; -type bitcoin_get_balance_query_args = record { - address : bitcoin_address; +type bitcoin_get_balance_result = satoshi; + +type bitcoin_get_current_fee_percentiles_args = record { network : bitcoin_network; - min_confirmations : opt nat32; }; +type bitcoin_get_current_fee_percentiles_result = vec millisatoshi_per_byte; + type bitcoin_send_transaction_args = record { transaction : blob; network : bitcoin_network; }; -type millisatoshi_per_byte = nat64; +type bitcoin_get_block_headers_args = record { + start_height : bitcoin_block_height; + end_height : opt bitcoin_block_height; + network: bitcoin_network; +}; + +type bitcoin_get_block_headers_result = record { + tip_height : bitcoin_block_height; + block_headers : vec bitcoin_block_header; +}; type node_metrics = record { node_id : principal; - num_blocks_total : nat64; + num_blocks_proposed_total : nat64; num_block_failures_total : nat64; }; @@ -200,6 +212,10 @@ type canister_install_mode = variant { reinstall; upgrade : opt record { skip_pre_upgrade : opt bool; + wasm_memory_persistence : opt variant { + keep; + replace; + }; }; }; @@ -246,6 +262,12 @@ type canister_status_result = record { 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 { @@ -274,12 +296,18 @@ type http_request_args = record { 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; - }; + transform : opt http_transform; // TODO added by Demergent Labs +}; + +// TODO added by Demergent Labs +type http_transform = record { + function : func(http_transform_args) -> (http_request_result) query; + context : blob; }; +// TODO this was added by Demergent Labs for use in the transform method parameters, it would be nice to upstream this +type http_transform_args = record { response : http_request_result; context : blob }; + type ecdsa_public_key_args = record { canister_id : opt canister_id; derivation_path : vec blob; @@ -301,6 +329,27 @@ type sign_with_ecdsa_result = record { signature : blob; }; +type schnorr_public_key_args = record { + canister_id : opt canister_id; + derivation_path : vec blob; + key_id : record { algorithm : schnorr_algorithm; name : text }; +}; + +type schnorr_public_key_result = record { + public_key : blob; + chain_code : blob; +}; + +type sign_with_schnorr_args = record { + message : blob; + derivation_path : vec blob; + key_id : record { algorithm : schnorr_algorithm; name : text }; +}; + +type sign_with_schnorr_result = record { + signature : blob; +}; + type node_metrics_history_args = record { subnet_id : principal; start_at_timestamp_nanos : nat64; @@ -333,11 +382,19 @@ type stored_chunks_result = vec chunk_hash; type upload_chunk_result = chunk_hash; -type bitcoin_get_balance_result = satoshi; +type fetch_canister_logs_args = record { + canister_id : canister_id; +}; -type bitcoin_get_balance_query_result = satoshi; +type canister_log_record = record { + idx: nat64; + timestamp_nanos: nat64; + content: blob; +}; -type bitcoin_get_current_fee_percentiles_result = vec millisatoshi_per_byte; +type fetch_canister_logs_result = record { + canister_log_records: vec canister_log_record; +}; service ic : { create_canister : (create_canister_args) -> (create_canister_result); @@ -361,13 +418,16 @@ service ic : { ecdsa_public_key : (ecdsa_public_key_args) -> (ecdsa_public_key_result); sign_with_ecdsa : (sign_with_ecdsa_args) -> (sign_with_ecdsa_result); + // Threshold Schnorr signature + schnorr_public_key : (schnorr_public_key_args) -> (schnorr_public_key_result); + sign_with_schnorr : (sign_with_schnorr_args) -> (sign_with_schnorr_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); + bitcoin_get_block_headers : (bitcoin_get_block_headers_args) -> (bitcoin_get_block_headers_result); // metrics interface node_metrics_history : (node_metrics_history_args) -> (node_metrics_history_result); @@ -375,4 +435,7 @@ service ic : { // 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) -> (); -}; \ No newline at end of file + + // canister logging + fetch_canister_logs : (fetch_canister_logs_args) -> (fetch_canister_logs_result) query; +}; diff --git a/canisters/management/index.ts b/canisters/management/index.ts index b0da32a48d..f6f8ea669c 100644 --- a/canisters/management/index.ts +++ b/canisters/management/index.ts @@ -1,40 +1,1106 @@ -// Some JS docs licensed under: -// -// - https://github.com/dfinity/cdk-rs/blob/main/LICENSE -// -// Some documentation changed from original work. - -export * from './bitcoin'; -export * from './canister_info'; -export * from './canister_management'; -export * from './http_request'; -export * from './t_ecdsa'; - -export const PRINCIPAL = 'aaaaa-aa'; -export const FUNCS = { - bitcoin_get_balance: 'bitcoin_get_balance', - bitcoin_get_current_fee_percentiles: 'bitcoin_get_current_fee_percentiles', - bitcoin_get_utxos: 'bitcoin_get_utxos', - bitcoin_send_transaction: 'bitcoin_send_transaction', - create_canister: 'create_canister', - update_settings: 'update_settings', - upload_chunk: 'upload_chunk', - clear_chunk_store: 'clear_chunk_store', - stored_chunks: 'stored_chunks', - install_code: 'install_code', - install_chunked_code: 'install_chunked_code', - uninstall_code: 'uninstall_code', - start_canister: 'start_canister', - stop_canister: 'stop_canister', - canister_info: 'canister_info', - canister_status: 'canister_status', - delete_canister: 'delete_canister', - deposit_cycles: 'deposit_cycles', - provisional_create_canister_with_cycles: - 'provisional_create_canister_with_cycles', - provisional_top_up_canister: 'provisional_top_up_canister', - http_request: 'http_request', - raw_rand: 'raw_rand', - ecdsa_public_key: 'ecdsa_public_key', - sign_with_ecdsa: 'sign_with_ecdsa' +import { ActorMethod } from '@dfinity/agent'; +import { IDL } from '@dfinity/candid'; +import { Principal } from '@dfinity/principal'; +export type bitcoin_address = string; +export type bitcoin_block_hash = Uint8Array | number[]; +export type bitcoin_block_header = Uint8Array | number[]; +export type bitcoin_block_height = number; +export interface bitcoin_get_balance_args { + network: bitcoin_network; + address: bitcoin_address; + min_confirmations: [] | [number]; +} +export type bitcoin_get_balance_result = satoshi; +export interface bitcoin_get_block_headers_args { + start_height: bitcoin_block_height; + end_height: [] | [bitcoin_block_height]; + network: bitcoin_network; +} +export interface bitcoin_get_block_headers_result { + tip_height: bitcoin_block_height; + block_headers: Array; +} +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_result { + next_page: [] | [Uint8Array | number[]]; + tip_height: bitcoin_block_height; + tip_block_hash: bitcoin_block_hash; + utxos: Array; +} +export type bitcoin_network = + | { mainnet: null } + | { regtest: null } + | { testnet: null }; +export interface bitcoin_send_transaction_args { + transaction: Uint8Array | number[]; + network: bitcoin_network; +} +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 } + | { + upgrade: + | [] + | [ + { + wasm_memory_persistence: + | [] + | [{ keep: null } | { replace: null }]; + skip_pre_upgrade: [] | [boolean]; + } + ]; + } + | { 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]; + wasm_memory_limit: [] | [bigint]; + 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; + origin: change_origin; + details: change_details; +} +export type change_details = + | { + creation: { controllers: Array }; + } + | { + code_deployment: { + mode: { reinstall: null } | { upgrade: null } | { install: null }; + module_hash: Uint8Array | number[]; + }; + } + | { controllers_change: { controllers: Array } } + | { code_uninstall: null }; +export type change_origin = + | { from_user: { user_id: Principal } } + | { + from_canister: { + canister_version: [] | [bigint]; + canister_id: Principal; + }; + }; +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; + wasm_memory_limit: bigint; + 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 ecdsa_public_key_result { + public_key: Uint8Array | number[]; + chain_code: Uint8Array | number[]; +} +export interface fetch_canister_logs_args { + canister_id: canister_id; +} +export interface fetch_canister_logs_result { + canister_log_records: 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: [] | [http_transform]; + headers: Array; +} +export interface http_request_result { + status: bigint; + body: Uint8Array | number[]; + headers: Array; +} +export interface http_transform { + function: [Principal, string]; + context: Uint8Array | number[]; +} +export interface http_transform_args { + context: Uint8Array | number[]; + response: http_request_result; +} +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 type schnorr_algorithm = { ed25519: null } | { bip340secp256k1: null }; +export interface schnorr_public_key_args { + key_id: { algorithm: schnorr_algorithm; name: string }; + canister_id: [] | [canister_id]; + derivation_path: Array; +} +export interface schnorr_public_key_result { + public_key: Uint8Array | number[]; + chain_code: Uint8Array | number[]; +} +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 sign_with_schnorr_args { + key_id: { algorithm: schnorr_algorithm; name: string }; + derivation_path: Array; + message: Uint8Array | number[]; +} +export interface sign_with_schnorr_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 interface _SERVICE { + bitcoin_get_balance: ActorMethod< + [bitcoin_get_balance_args], + bitcoin_get_balance_result + >; + bitcoin_get_block_headers: ActorMethod< + [bitcoin_get_block_headers_args], + bitcoin_get_block_headers_result + >; + bitcoin_get_current_fee_percentiles: ActorMethod< + [bitcoin_get_current_fee_percentiles_args], + bitcoin_get_current_fee_percentiles_result + >; + bitcoin_get_utxos: ActorMethod< + [bitcoin_get_utxos_args], + bitcoin_get_utxos_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< + [provisional_create_canister_with_cycles_args], + provisional_create_canister_with_cycles_result + >; + provisional_top_up_canister: ActorMethod< + [provisional_top_up_canister_args], + undefined + >; + raw_rand: ActorMethod<[], raw_rand_result>; + schnorr_public_key: ActorMethod< + [schnorr_public_key_args], + schnorr_public_key_result + >; + sign_with_ecdsa: ActorMethod< + [sign_with_ecdsa_args], + sign_with_ecdsa_result + >; + sign_with_schnorr: ActorMethod< + [sign_with_schnorr_args], + sign_with_schnorr_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 type idlFactory = IDL.InterfaceFactory; +export type init = (args: { IDL: typeof IDL }) => IDL.Type[]; +export const bitcoin_network = IDL.Variant({ + mainnet: IDL.Null, + regtest: IDL.Null, + testnet: IDL.Null +}); +export const bitcoin_address = IDL.Text; +export const bitcoin_get_balance_args = IDL.Record({ + network: bitcoin_network, + address: bitcoin_address, + min_confirmations: IDL.Opt(IDL.Nat32) +}); +export const satoshi = IDL.Nat64; +export const bitcoin_get_balance_result = satoshi; +export const bitcoin_block_height = IDL.Nat32; +export const bitcoin_get_block_headers_args = IDL.Record({ + start_height: bitcoin_block_height, + end_height: IDL.Opt(bitcoin_block_height), + network: bitcoin_network +}); +export const bitcoin_block_header = IDL.Vec(IDL.Nat8); +export const bitcoin_get_block_headers_result = IDL.Record({ + tip_height: bitcoin_block_height, + block_headers: IDL.Vec(bitcoin_block_header) +}); +export const bitcoin_get_current_fee_percentiles_args = IDL.Record({ + network: bitcoin_network +}); +export const millisatoshi_per_byte = IDL.Nat64; +export const bitcoin_get_current_fee_percentiles_result = IDL.Vec( + millisatoshi_per_byte +); +export const bitcoin_get_utxos_args = IDL.Record({ + network: bitcoin_network, + filter: IDL.Opt( + IDL.Variant({ page: IDL.Vec(IDL.Nat8), min_confirmations: IDL.Nat32 }) + ), + address: bitcoin_address +}); +export const bitcoin_block_hash = IDL.Vec(IDL.Nat8); +export const outpoint = IDL.Record({ + txid: IDL.Vec(IDL.Nat8), + vout: IDL.Nat32 +}); +export const utxo = IDL.Record({ + height: IDL.Nat32, + value: satoshi, + outpoint: outpoint +}); +export const bitcoin_get_utxos_result = IDL.Record({ + next_page: IDL.Opt(IDL.Vec(IDL.Nat8)), + tip_height: bitcoin_block_height, + tip_block_hash: bitcoin_block_hash, + utxos: IDL.Vec(utxo) +}); +export const bitcoin_send_transaction_args = IDL.Record({ + transaction: IDL.Vec(IDL.Nat8), + network: bitcoin_network +}); +export const canister_id = IDL.Principal; +export const canister_info_args = IDL.Record({ + canister_id: canister_id, + num_requested_changes: IDL.Opt(IDL.Nat64) +}); +export const change_origin = IDL.Variant({ + from_user: IDL.Record({ user_id: IDL.Principal }), + from_canister: IDL.Record({ + canister_version: IDL.Opt(IDL.Nat64), + canister_id: IDL.Principal + }) +}); +export const change_details = IDL.Variant({ + creation: IDL.Record({ controllers: IDL.Vec(IDL.Principal) }), + code_deployment: IDL.Record({ + mode: IDL.Variant({ + reinstall: IDL.Null, + upgrade: IDL.Null, + install: IDL.Null + }), + module_hash: IDL.Vec(IDL.Nat8) + }), + controllers_change: IDL.Record({ controllers: IDL.Vec(IDL.Principal) }), + code_uninstall: IDL.Null +}); +export const change = IDL.Record({ + timestamp_nanos: IDL.Nat64, + canister_version: IDL.Nat64, + origin: change_origin, + details: change_details +}); +export 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 +}); +export const canister_status_args = IDL.Record({ canister_id: canister_id }); +export const log_visibility = IDL.Variant({ + controllers: IDL.Null, + public: IDL.Null +}); +export const definite_canister_settings = IDL.Record({ + freezing_threshold: IDL.Nat, + controllers: IDL.Vec(IDL.Principal), + reserved_cycles_limit: IDL.Nat, + log_visibility: log_visibility, + wasm_memory_limit: IDL.Nat, + memory_allocation: IDL.Nat, + compute_allocation: IDL.Nat +}); +export 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 +}); +export const clear_chunk_store_args = IDL.Record({ + canister_id: canister_id +}); +export 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), + wasm_memory_limit: IDL.Opt(IDL.Nat), + memory_allocation: IDL.Opt(IDL.Nat), + compute_allocation: IDL.Opt(IDL.Nat) +}); +export const create_canister_args = IDL.Record({ + settings: IDL.Opt(canister_settings), + sender_canister_version: IDL.Opt(IDL.Nat64) +}); +export const create_canister_result = IDL.Record({ + canister_id: canister_id +}); +export const delete_canister_args = IDL.Record({ canister_id: canister_id }); +export const deposit_cycles_args = IDL.Record({ canister_id: canister_id }); +export const ecdsa_curve = IDL.Variant({ secp256k1: IDL.Null }); +export 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)) +}); +export const ecdsa_public_key_result = IDL.Record({ + public_key: IDL.Vec(IDL.Nat8), + chain_code: IDL.Vec(IDL.Nat8) +}); +export const fetch_canister_logs_args = IDL.Record({ + canister_id: canister_id +}); +export const canister_log_record = IDL.Record({ + idx: IDL.Nat64, + timestamp_nanos: IDL.Nat64, + content: IDL.Vec(IDL.Nat8) +}); +export const fetch_canister_logs_result = IDL.Record({ + canister_log_records: IDL.Vec(canister_log_record) +}); +export const http_header = IDL.Record({ + value: IDL.Text, + name: IDL.Text +}); +export const http_request_result = IDL.Record({ + status: IDL.Nat, + body: IDL.Vec(IDL.Nat8), + headers: IDL.Vec(http_header) +}); +export const http_transform_args = IDL.Record({ + context: IDL.Vec(IDL.Nat8), + response: http_request_result +}); +export const http_transform = IDL.Record({ + function: IDL.Func([http_transform_args], [http_request_result], ['query']), + context: IDL.Vec(IDL.Nat8) +}); +export 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(http_transform), + headers: IDL.Vec(http_header) +}); +export const canister_install_mode = IDL.Variant({ + reinstall: IDL.Null, + upgrade: IDL.Opt( + IDL.Record({ + wasm_memory_persistence: IDL.Opt( + IDL.Variant({ keep: IDL.Null, replace: IDL.Null }) + ), + skip_pre_upgrade: IDL.Opt(IDL.Bool) + }) + ), + install: IDL.Null +}); +export const chunk_hash = IDL.Record({ hash: IDL.Vec(IDL.Nat8) }); +export 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) +}); +export const wasm_module = IDL.Vec(IDL.Nat8); +export 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) +}); +export const node_metrics_history_args = IDL.Record({ + start_at_timestamp_nanos: IDL.Nat64, + subnet_id: IDL.Principal +}); +export const node_metrics = IDL.Record({ + num_block_failures_total: IDL.Nat64, + node_id: IDL.Principal, + num_blocks_proposed_total: IDL.Nat64 +}); +export const node_metrics_history_result = IDL.Vec( + IDL.Record({ + timestamp_nanos: IDL.Nat64, + node_metrics: IDL.Vec(node_metrics) + }) +); +export 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) +}); +export const provisional_create_canister_with_cycles_result = IDL.Record({ + canister_id: canister_id +}); +export const provisional_top_up_canister_args = IDL.Record({ + canister_id: canister_id, + amount: IDL.Nat +}); +export const raw_rand_result = IDL.Vec(IDL.Nat8); +export const schnorr_algorithm = IDL.Variant({ + ed25519: IDL.Null, + bip340secp256k1: IDL.Null +}); +export const schnorr_public_key_args = IDL.Record({ + key_id: IDL.Record({ algorithm: schnorr_algorithm, name: IDL.Text }), + canister_id: IDL.Opt(canister_id), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)) +}); +export const schnorr_public_key_result = IDL.Record({ + public_key: IDL.Vec(IDL.Nat8), + chain_code: IDL.Vec(IDL.Nat8) +}); +export 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) +}); +export const sign_with_ecdsa_result = IDL.Record({ + signature: IDL.Vec(IDL.Nat8) +}); +export const sign_with_schnorr_args = IDL.Record({ + key_id: IDL.Record({ algorithm: schnorr_algorithm, name: IDL.Text }), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), + message: IDL.Vec(IDL.Nat8) +}); +export const sign_with_schnorr_result = IDL.Record({ + signature: IDL.Vec(IDL.Nat8) +}); +export const start_canister_args = IDL.Record({ canister_id: canister_id }); +export const stop_canister_args = IDL.Record({ canister_id: canister_id }); +export const stored_chunks_args = IDL.Record({ canister_id: canister_id }); +export const stored_chunks_result = IDL.Vec(chunk_hash); +export const uninstall_code_args = IDL.Record({ + canister_id: canister_id, + sender_canister_version: IDL.Opt(IDL.Nat64) +}); +export const update_settings_args = IDL.Record({ + canister_id: IDL.Principal, + settings: canister_settings, + sender_canister_version: IDL.Opt(IDL.Nat64) +}); +export const upload_chunk_args = IDL.Record({ + chunk: IDL.Vec(IDL.Nat8), + canister_id: IDL.Principal +}); +export const upload_chunk_result = chunk_hash; +export const idlFactory: idlFactory = ({ IDL }) => { + const bitcoin_network = IDL.Variant({ + mainnet: IDL.Null, + regtest: IDL.Null, + testnet: IDL.Null + }); + const bitcoin_address = IDL.Text; + const bitcoin_get_balance_args = 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_block_height = IDL.Nat32; + const bitcoin_get_block_headers_args = IDL.Record({ + start_height: bitcoin_block_height, + end_height: IDL.Opt(bitcoin_block_height), + network: bitcoin_network + }); + const bitcoin_block_header = IDL.Vec(IDL.Nat8); + const bitcoin_get_block_headers_result = IDL.Record({ + tip_height: bitcoin_block_height, + block_headers: IDL.Vec(bitcoin_block_header) + }); + const bitcoin_get_current_fee_percentiles_args = 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({ + network: bitcoin_network, + filter: IDL.Opt( + IDL.Variant({ + page: IDL.Vec(IDL.Nat8), + min_confirmations: IDL.Nat32 + }) + ), + address: bitcoin_address + }); + const bitcoin_block_hash = IDL.Vec(IDL.Nat8); + const outpoint = IDL.Record({ + txid: IDL.Vec(IDL.Nat8), + vout: IDL.Nat32 + }); + const utxo = IDL.Record({ + height: IDL.Nat32, + value: satoshi, + outpoint: outpoint + }); + const bitcoin_get_utxos_result = IDL.Record({ + next_page: IDL.Opt(IDL.Vec(IDL.Nat8)), + tip_height: bitcoin_block_height, + tip_block_hash: bitcoin_block_hash, + utxos: IDL.Vec(utxo) + }); + 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({ + canister_version: IDL.Opt(IDL.Nat64), + canister_id: IDL.Principal + }) + }); + const change_details = IDL.Variant({ + creation: IDL.Record({ controllers: IDL.Vec(IDL.Principal) }), + code_deployment: IDL.Record({ + mode: IDL.Variant({ + reinstall: IDL.Null, + upgrade: IDL.Null, + install: IDL.Null + }), + module_hash: IDL.Vec(IDL.Nat8) + }), + controllers_change: IDL.Record({ + controllers: IDL.Vec(IDL.Principal) + }), + code_uninstall: IDL.Null + }); + const change = IDL.Record({ + timestamp_nanos: IDL.Nat64, + canister_version: IDL.Nat64, + 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, + wasm_memory_limit: IDL.Nat, + 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), + wasm_memory_limit: IDL.Opt(IDL.Nat), + 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({ + status: IDL.Nat, + body: IDL.Vec(IDL.Nat8), + headers: IDL.Vec(http_header) + }); + const http_transform_args = IDL.Record({ + context: IDL.Vec(IDL.Nat8), + response: http_request_result + }); + const http_transform = IDL.Record({ + function: IDL.Func( + [http_transform_args], + [http_request_result], + ['query'] + ), + context: IDL.Vec(IDL.Nat8) + }); + 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(http_transform), + headers: IDL.Vec(http_header) + }); + const canister_install_mode = IDL.Variant({ + reinstall: IDL.Null, + upgrade: IDL.Opt( + IDL.Record({ + wasm_memory_persistence: IDL.Opt( + IDL.Variant({ keep: IDL.Null, replace: IDL.Null }) + ), + skip_pre_upgrade: IDL.Opt(IDL.Bool) + }) + ), + install: IDL.Null + }); + 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 schnorr_algorithm = IDL.Variant({ + ed25519: IDL.Null, + bip340secp256k1: IDL.Null + }); + const schnorr_public_key_args = IDL.Record({ + key_id: IDL.Record({ + algorithm: schnorr_algorithm, + name: IDL.Text + }), + canister_id: IDL.Opt(canister_id), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)) + }); + const schnorr_public_key_result = IDL.Record({ + public_key: IDL.Vec(IDL.Nat8), + chain_code: 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 sign_with_schnorr_args = IDL.Record({ + key_id: IDL.Record({ + algorithm: schnorr_algorithm, + name: IDL.Text + }), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), + message: IDL.Vec(IDL.Nat8) + }); + const sign_with_schnorr_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_block_headers: IDL.Func( + [bitcoin_get_block_headers_args], + [bitcoin_get_block_headers_result], + [] + ), + bitcoin_get_current_fee_percentiles: IDL.Func( + [bitcoin_get_current_fee_percentiles_args], + [bitcoin_get_current_fee_percentiles_result], + [] + ), + bitcoin_get_utxos: IDL.Func( + [bitcoin_get_utxos_args], + [bitcoin_get_utxos_result], + [] + ), + 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( + [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], []), + schnorr_public_key: IDL.Func( + [schnorr_public_key_args], + [schnorr_public_key_result], + [] + ), + sign_with_ecdsa: IDL.Func( + [sign_with_ecdsa_args], + [sign_with_ecdsa_result], + [] + ), + sign_with_schnorr: IDL.Func( + [sign_with_schnorr_args], + [sign_with_schnorr_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: init = () => { + return []; }; diff --git a/canisters/management/t_ecdsa.ts b/canisters/management/t_ecdsa.ts deleted file mode 100644 index 4a8bab97a6..0000000000 --- a/canisters/management/t_ecdsa.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { IDL } from '@dfinity/candid'; -import { Principal } from '@dfinity/principal'; - -export const EcdsaCurve = IDL.Variant({ - secp256k1: IDL.Null -}); -export type EcdsaCurve = { - secp256k1: null; -}; - -export const KeyId = IDL.Record({ - curve: EcdsaCurve, - name: IDL.Text -}); -export type KeyId = { - curve: EcdsaCurve; - name: string; -}; - -export const EcdsaPublicKeyArgs = IDL.Record({ - canister_id: IDL.Opt(IDL.Principal), - derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), - key_id: KeyId -}); -export type EcdsaPublicKeyArgs = { - canister_id: [Principal] | []; - derivation_path: Uint8Array[]; - key_id: KeyId; -}; - -export const EcdsaPublicKeyResult = IDL.Record({ - public_key: IDL.Vec(IDL.Nat8), - chain_code: IDL.Vec(IDL.Nat8) -}); -export type EcdsaPublicKeyResult = { - public_key: Uint8Array; - chain_code: Uint8Array; -}; - -export const SignWithEcdsaArgs = IDL.Record({ - message_hash: IDL.Vec(IDL.Nat8), - derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), - key_id: KeyId -}); -export type SignWithEcdsaArgs = { - message_hash: Uint8Array; - derivation_path: Uint8Array[]; - key_id: KeyId; -}; - -export const SignWithEcdsaResult = IDL.Record({ - signature: IDL.Vec(IDL.Nat8) -}); -export type SignWithEcdsaResult = { - signature: Uint8Array; -}; diff --git a/src/lib/experimental/fetch/http.ts b/src/lib/experimental/fetch/http.ts index 7dde7f7574..7284b311d3 100644 --- a/src/lib/experimental/fetch/http.ts +++ b/src/lib/experimental/fetch/http.ts @@ -2,7 +2,7 @@ import '../experimental'; import { inflate } from 'pako'; -import { HttpTransform } from '../../../../canisters/management'; +import { http_transform } from '../../../../canisters/management'; import { ic } from '../ic'; import { azleFetch, serialize } from '.'; import { AzleFetchResponse } from './response'; @@ -133,7 +133,7 @@ function getHttpMethod(init?: RequestInit | undefined) { }; } -function getHttpTransform(): [] | [HttpTransform] { +function getHttpTransform(): [] | [http_transform] { if (globalThis._azleOutgoingHttpOptionsTransformMethodName === undefined) { return []; } diff --git a/src/lib/stable/ic_apis/call.ts b/src/lib/stable/ic_apis/call.ts index a3a612bc91..4d7c0213bb 100644 --- a/src/lib/stable/ic_apis/call.ts +++ b/src/lib/stable/ic_apis/call.ts @@ -2,17 +2,17 @@ import { IDL } from '@dfinity/candid'; import { Principal } from '@dfinity/principal'; import { v4 } from 'uuid'; // TODO is uuid experimental? -export async function call( +export async function call( canisterId: Principal | string, method: string, options?: { paramIdlTypes?: IDL.Type[]; returnIdlType?: IDL.Type; - args?: any[]; - payment?: bigint; + args?: Args; + payment?: bigint; // TODO this should be called cycles: https://github.com/demergent-labs/azle/issues/2104 raw?: Uint8Array; } -): Promise { +): Promise { // TODO this should use a Result remember return new Promise((resolve, reject) => { if (globalThis._azleIc === undefined) { @@ -33,11 +33,11 @@ export async function call( result: ArrayBuffer ): void => { if (raw !== undefined) { - resolve(new Uint8Array(result)); + resolve(new Uint8Array(result) as Return); } else { const idlType = returnTypeIdl === undefined ? [] : [returnTypeIdl]; - resolve(IDL.decode(idlType, result)[0]); + resolve(IDL.decode(idlType, result)[0] as Return); } delete globalThis._azleResolveIds[globalResolveId]; diff --git a/tests/end_to_end/candid_rpc/class_syntax/bitcoin/package-lock.json b/tests/end_to_end/candid_rpc/class_syntax/bitcoin/package-lock.json index 89db30bd59..3287bd080b 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/bitcoin/package-lock.json +++ b/tests/end_to_end/candid_rpc/class_syntax/bitcoin/package-lock.json @@ -37,7 +37,7 @@ "dev": true, "hasInstallScript": true, "dependencies": { - "azle": "0.24.0" + "azle": "0.24.1" }, "devDependencies": { "@dfinity/agent": "0.11.1", @@ -8065,7 +8065,7 @@ "version": "file:../../functional_syntax/bitcoin", "requires": { "@dfinity/agent": "0.11.1", - "azle": "0.24.0", + "azle": "0.24.1", "jest": "^29.7.0", "ts-jest": "^29.1.4", "tsx": "^4.15.7", diff --git a/tests/end_to_end/candid_rpc/class_syntax/bitcoin/src/index.ts b/tests/end_to_end/candid_rpc/class_syntax/bitcoin/src/index.ts index bcf121a5eb..eb4c454d5d 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/bitcoin/src/index.ts +++ b/tests/end_to_end/candid_rpc/class_syntax/bitcoin/src/index.ts @@ -1,12 +1,12 @@ import { call, IDL, update } from 'azle'; import { - GetBalanceArgs, - GetCurrentFeePercentilesArgs, - GetUtxosArgs, - GetUtxosResult, - MillisatoshiPerByte, - Satoshi, - SendTransactionArgs + bitcoin_get_balance_args, + bitcoin_get_balance_result, + bitcoin_get_current_fee_percentiles_args, + bitcoin_get_current_fee_percentiles_result, + bitcoin_get_utxos_args, + bitcoin_get_utxos_result, + bitcoin_send_transaction_args } from 'azle/canisters/management'; const BITCOIN_API_CYCLE_COST = 100_000_000n; @@ -14,11 +14,14 @@ const BITCOIN_BASE_TRANSACTION_COST = 5_000_000_000n; const BITCOIN_CYCLE_COST_PER_TRANSACTION_BYTE = 20_000_000n; export default class { - @update([IDL.Text], Satoshi) - async getBalance(address: string): Promise { - return await call('aaaaa-aa', 'bitcoin_get_balance', { - paramIdlTypes: [GetBalanceArgs], - returnIdlType: Satoshi, + @update([IDL.Text], bitcoin_get_balance_result) + async getBalance(address: string): Promise { + return await call< + [bitcoin_get_balance_args], + bitcoin_get_balance_result + >('aaaaa-aa', 'bitcoin_get_balance', { + paramIdlTypes: [bitcoin_get_balance_args], + returnIdlType: bitcoin_get_balance_result, args: [ { address, @@ -30,11 +33,14 @@ export default class { }); } - @update([], IDL.Vec(MillisatoshiPerByte)) - async getCurrentFeePercentiles(): Promise { - return await call('aaaaa-aa', 'bitcoin_get_current_fee_percentiles', { - paramIdlTypes: [GetCurrentFeePercentilesArgs], - returnIdlType: IDL.Vec(MillisatoshiPerByte), + @update([], bitcoin_get_current_fee_percentiles_result) + async getCurrentFeePercentiles(): Promise { + return await call< + [bitcoin_get_current_fee_percentiles_args], + bitcoin_get_current_fee_percentiles_result + >('aaaaa-aa', 'bitcoin_get_current_fee_percentiles', { + paramIdlTypes: [bitcoin_get_current_fee_percentiles_args], + returnIdlType: bitcoin_get_current_fee_percentiles_result, args: [ { network: { regtest: null } @@ -44,20 +50,24 @@ export default class { }); } - @update([IDL.Text], GetUtxosResult) - async getUtxos(address: string): Promise { - return await call('aaaaa-aa', 'bitcoin_get_utxos', { - paramIdlTypes: [GetUtxosArgs], - returnIdlType: GetUtxosResult, - args: [ - { - address, - filter: [], - network: { regtest: null } - } - ], - payment: BITCOIN_API_CYCLE_COST - }); + @update([IDL.Text], bitcoin_get_utxos_result) + async getUtxos(address: string): Promise { + return await call<[bitcoin_get_utxos_args], bitcoin_get_utxos_result>( + 'aaaaa-aa', + 'bitcoin_get_utxos', + { + paramIdlTypes: [bitcoin_get_utxos_args], + returnIdlType: bitcoin_get_utxos_result, + args: [ + { + address, + filter: [], + network: { regtest: null } + } + ], + payment: BITCOIN_API_CYCLE_COST + } + ); } @update([IDL.Vec(IDL.Nat8)], IDL.Bool) @@ -67,16 +77,20 @@ export default class { BigInt(transaction.length) * BITCOIN_CYCLE_COST_PER_TRANSACTION_BYTE; - await call('aaaaa-aa', 'bitcoin_send_transaction', { - paramIdlTypes: [SendTransactionArgs], - args: [ - { - transaction, - network: { regtest: null } - } - ], - payment: transactionFee - }); + await call<[bitcoin_send_transaction_args], void>( + 'aaaaa-aa', + 'bitcoin_send_transaction', + { + paramIdlTypes: [bitcoin_send_transaction_args], + args: [ + { + transaction, + network: { regtest: null } + } + ], + payment: transactionFee + } + ); return true; } diff --git a/tests/end_to_end/candid_rpc/class_syntax/call_raw/package-lock.json b/tests/end_to_end/candid_rpc/class_syntax/call_raw/package-lock.json index 14237e5fd7..8e97d23adf 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/call_raw/package-lock.json +++ b/tests/end_to_end/candid_rpc/class_syntax/call_raw/package-lock.json @@ -17,6 +17,7 @@ } }, "../../functional_syntax/call_raw": { + "name": "call_raw_end_to_end_test_functional_syntax", "dev": true, "dependencies": { "azle": "0.24.1" diff --git a/tests/end_to_end/candid_rpc/class_syntax/call_raw/src/index.ts b/tests/end_to_end/candid_rpc/class_syntax/call_raw/src/index.ts index eaa0968425..275055b661 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/call_raw/src/index.ts +++ b/tests/end_to_end/candid_rpc/class_syntax/call_raw/src/index.ts @@ -8,7 +8,7 @@ export default class { candidArgs: string, payment: bigint ): Promise { - const result = await call(canisterId, method, { + const result = await call(canisterId, method, { raw: candidEncode(candidArgs), payment }); diff --git a/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/package-lock.json b/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/package-lock.json index 12f7d8bcf5..8cb0b8b6cd 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/package-lock.json +++ b/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/package-lock.json @@ -17,6 +17,7 @@ } }, "../../functional_syntax/ethereum_json_rpc": { + "name": "ethereum_json_rpc_end_to_end_test_functional_syntax", "dev": true, "dependencies": { "azle": "0.24.1" diff --git a/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/src/index.ts b/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/src/index.ts index 4e75c17f5a..e0e1cdddfa 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/src/index.ts +++ b/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/src/index.ts @@ -9,11 +9,9 @@ import { update } from 'azle'; import { - FUNCS as managementCanister, - HttpRequestArgs, - HttpResponse, - HttpTransformArgs, - PRINCIPAL + http_request_args, + http_request_result, + http_transform_args } from 'azle/canisters/management'; export default class { @@ -48,8 +46,8 @@ export default class { return await getBlockByNumber(url, number); } - @query([HttpTransformArgs], HttpResponse) - ethTransform(args: HttpTransformArgs): HttpResponse { + @query([http_transform_args], http_request_result) + ethTransform(args: http_transform_args): http_request_result { return { ...args.response, headers: [] @@ -61,12 +59,12 @@ async function getBalance( url: string, ethereumAddress: string ): Promise { - const httpResponse = await call( - PRINCIPAL, - managementCanister.http_request, + const httpResponse = await call<[http_request_args], http_request_result>( + Principal.fromText('aaaaa-aa'), + 'http_request', { - paramIdlTypes: [HttpRequestArgs], - returnIdlType: HttpResponse, + paramIdlTypes: [http_request_args], + returnIdlType: http_request_result, args: [ { url, @@ -100,15 +98,15 @@ async function getBalance( } ); - return new TextDecoder().decode(httpResponse.body.buffer); + return new TextDecoder().decode(Uint8Array.from(httpResponse.body)); } async function getBlockByNumber(url: string, number: number): Promise { - const httpResponse = await call( - PRINCIPAL, - managementCanister.http_request, + const httpResponse = await call( + Principal.fromText('aaaaa-aa'), + 'http_request', { - paramIdlTypes: [HttpRequestArgs], - returnIdlType: HttpResponse, + paramIdlTypes: [http_request_args], + returnIdlType: http_request_result, args: [ { url, @@ -142,5 +140,5 @@ async function getBlockByNumber(url: string, number: number): Promise { } ); - return new TextDecoder().decode(httpResponse.body.buffer); + return new TextDecoder().decode(Uint8Array.from(httpResponse.body)); } diff --git a/tests/end_to_end/candid_rpc/class_syntax/management_canister/package-lock.json b/tests/end_to_end/candid_rpc/class_syntax/management_canister/package-lock.json index d78946a005..a30bede5c4 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/management_canister/package-lock.json +++ b/tests/end_to_end/candid_rpc/class_syntax/management_canister/package-lock.json @@ -17,6 +17,7 @@ } }, "../../functional_syntax/management_canister": { + "name": "management_canister_end_to_end_test_functional_syntax", "dev": true, "dependencies": { "azle": "0.24.1" diff --git a/tests/end_to_end/candid_rpc/class_syntax/management_canister/src/index.ts b/tests/end_to_end/candid_rpc/class_syntax/management_canister/src/index.ts index 6551ec24ca..6d0ebb38cb 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/management_canister/src/index.ts +++ b/tests/end_to_end/candid_rpc/class_syntax/management_canister/src/index.ts @@ -1,28 +1,29 @@ -// TODO once the Bitcoin integration is live, add the methods and tests import { call, IDL, Principal, query, update } from 'azle'; import { - CanisterInfoArgs, - CanisterInfoResult, - CanisterStatusArgs, - CanisterStatusResult, - ChunkHash, - ClearChunkStoreArgs, - CreateCanisterArgs, - CreateCanisterResult, - DeleteCanisterArgs, - DepositCyclesArgs, - InstallChunkedCodeArgs, - InstallCodeArgs, - ProvisionalCreateCanisterWithCyclesArgs, - ProvisionalCreateCanisterWithCyclesResult, - ProvisionalTopUpCanisterArgs, - StartCanisterArgs, - StopCanisterArgs, - StoredChunksArgs, - StoredChunksResult, - UninstallCodeArgs, - UpdateSettingsArgs, - UploadChunkArgs + canister_info_args, + canister_info_result, + canister_status_args, + canister_status_result, + chunk_hash, + clear_chunk_store_args, + create_canister_args, + create_canister_result, + delete_canister_args, + deposit_cycles_args, + install_chunked_code_args, + install_code_args, + provisional_create_canister_with_cycles_args, + provisional_create_canister_with_cycles_result, + provisional_top_up_canister_args, + raw_rand_result, + start_canister_args, + stop_canister_args, + stored_chunks_args, + stored_chunks_result, + uninstall_code_args, + update_settings_args, + upload_chunk_args, + upload_chunk_result } from 'azle/canisters/management'; type State = { @@ -34,8 +35,8 @@ export default class { createdCanisterId: Principal.fromText('aaaaa-aa') }; - @update([], CreateCanisterResult) - async executeCreateCanister(): Promise { + @update([], create_canister_result) + async executeCreateCanister(): Promise { const createCanisterResult = await createCanister(); this.state.createdCanisterId = createCanisterResult.canister_id; @@ -45,68 +46,88 @@ export default class { @update([IDL.Principal], IDL.Bool) async executeUpdateSettings(canisterId: Principal): Promise { - await call('aaaaa-aa', 'update_settings', { - paramIdlTypes: [UpdateSettingsArgs], - args: [ - { - canister_id: canisterId, - settings: { - controllers: [], - compute_allocation: [1n], - memory_allocation: [3_000_000n], - freezing_threshold: [2_000_000n], - reserved_cycles_limit: [] - }, - sender_canister_version: [] - } - ] - }); + await call<[update_settings_args], void>( + 'aaaaa-aa', + 'update_settings', + { + paramIdlTypes: [update_settings_args], + args: [ + { + canister_id: canisterId, + settings: { + controllers: [], + compute_allocation: [1n], + log_visibility: [], + memory_allocation: [3_000_000n], + freezing_threshold: [2_000_000n], + reserved_cycles_limit: [], + wasm_memory_limit: [] + }, + sender_canister_version: [] + } + ] + } + ); return true; } - @update([IDL.Principal, IDL.Vec(IDL.Nat8)], ChunkHash) + @update([IDL.Principal, IDL.Vec(IDL.Nat8)], upload_chunk_result) async executeUploadChunk( canisterId: Principal, chunk: Uint8Array - ): Promise { - return await call('aaaaa-aa', 'upload_chunk', { - paramIdlTypes: [UploadChunkArgs], - returnIdlType: ChunkHash, - args: [ - { - canister_id: canisterId, - chunk - } - ] - }); + ): Promise { + return await call<[upload_chunk_args], upload_chunk_result>( + 'aaaaa-aa', + 'upload_chunk', + { + paramIdlTypes: [upload_chunk_args], + returnIdlType: chunk_hash, + args: [ + { + canister_id: canisterId, + chunk + } + ] + } + ); } @update([IDL.Principal], IDL.Bool) async executeClearChunkStore(canisterId: Principal): Promise { - await call('aaaaa-aa', 'clear_chunk_store', { - paramIdlTypes: [ClearChunkStoreArgs], - args: [ - { - canister_id: canisterId - } - ] - }); + await call<[clear_chunk_store_args], void>( + 'aaaaa-aa', + 'clear_chunk_store', + { + paramIdlTypes: [clear_chunk_store_args], + args: [ + { + canister_id: canisterId + } + ] + } + ); return true; } - @update([IDL.Principal], StoredChunksResult) - async getStoredChunks(canisterId: Principal): Promise { - return await call('aaaaa-aa', 'stored_chunks', { - paramIdlTypes: [StoredChunksArgs], - returnIdlType: StoredChunksResult, - args: [ - { - canister_id: canisterId - } - ] - }); + @update([IDL.Principal], stored_chunks_result) + async getStoredChunks( + canisterId: Principal + ): Promise { + return await call<[stored_chunks_args], stored_chunks_result>( + 'aaaaa-aa', + 'stored_chunks', + { + paramIdlTypes: [stored_chunks_args], + returnIdlType: stored_chunks_result, + args: [ + { + canister_id: canisterId + } + ] + } + ); } @update([IDL.Principal, IDL.Vec(IDL.Nat8)], IDL.Bool) @@ -114,8 +135,8 @@ export default class { canisterId: Principal, wasmModule: Uint8Array ): Promise { - await call('aaaaa-aa', 'install_code', { - paramIdlTypes: [InstallCodeArgs], + await call<[install_code_args], void>('aaaaa-aa', 'install_code', { + paramIdlTypes: [install_code_args], args: [ { mode: { @@ -133,37 +154,41 @@ export default class { return true; } - @update([IDL.Principal, IDL.Vec(ChunkHash), IDL.Vec(IDL.Nat8)], IDL.Bool) + @update([IDL.Principal, IDL.Vec(chunk_hash), IDL.Vec(IDL.Nat8)], IDL.Bool) async executeInstallChunkedCode( canisterId: Principal, - chunkHashes: ChunkHash[], + chunkHashes: chunk_hash[], wasmModuleHash: Uint8Array ): Promise { - await call('aaaaa-aa', 'install_chunked_code', { - paramIdlTypes: [InstallChunkedCodeArgs], - args: [ - { - mode: { - install: null - }, - target_canister: canisterId, - store_canister: [], - chunk_hashes_list: chunkHashes, - wasm_module_hash: wasmModuleHash, - arg: Uint8Array.from([]), - sender_canister_version: [] - } - ], - payment: 100_000_000_000n - }); + await call<[install_chunked_code_args], void>( + 'aaaaa-aa', + 'install_chunked_code', + { + paramIdlTypes: [install_chunked_code_args], + args: [ + { + mode: { + install: null + }, + target_canister: canisterId, + store_canister: [], + chunk_hashes_list: chunkHashes, + wasm_module_hash: wasmModuleHash, + arg: Uint8Array.from([]), + sender_canister_version: [] + } + ], + payment: 100_000_000_000n + } + ); return true; } @update([IDL.Principal], IDL.Bool) async executeUninstallCode(canisterId: Principal): Promise { - await call('aaaaa-aa', 'uninstall_code', { - paramIdlTypes: [UninstallCodeArgs], + await call<[uninstall_code_args], void>('aaaaa-aa', 'uninstall_code', { + paramIdlTypes: [uninstall_code_args], args: [ { canister_id: canisterId, @@ -177,21 +202,22 @@ export default class { @update([IDL.Principal], IDL.Bool) async executeStartCanister(canisterId: Principal): Promise { - await call('aaaaa-aa', 'start_canister', { - paramIdlTypes: [StartCanisterArgs], + await call<[start_canister_args], void>('aaaaa-aa', 'start_canister', { + paramIdlTypes: [start_canister_args], args: [ { canister_id: canisterId } ] }); + return true; } @update([IDL.Principal], IDL.Bool) async executeStopCanister(canisterId: Principal): Promise { - await call('aaaaa-aa', 'stop_canister', { - paramIdlTypes: [StopCanisterArgs], + await call<[stop_canister_args], void>('aaaaa-aa', 'stop_canister', { + paramIdlTypes: [stop_canister_args], args: [ { canister_id: canisterId @@ -202,44 +228,58 @@ export default class { return true; } - @update([CanisterInfoArgs], CanisterInfoResult) - async getCanisterInfo(args: CanisterInfoArgs): Promise { - return await call('aaaaa-aa', 'canister_info', { - paramIdlTypes: [CanisterInfoArgs], - returnIdlType: CanisterInfoResult, - args: [args] - }); + @update([canister_info_args], canister_info_result) + async getCanisterInfo( + args: canister_info_args + ): Promise { + return await call<[canister_info_args], canister_info_result>( + 'aaaaa-aa', + 'canister_info', + { + paramIdlTypes: [canister_info_args], + returnIdlType: canister_info_result, + args: [args] + } + ); } - @update([CanisterStatusArgs], CanisterStatusResult) + @update([canister_status_args], canister_status_result) async getCanisterStatus( - args: CanisterStatusArgs - ): Promise { - return await call('aaaaa-aa', 'canister_status', { - paramIdlTypes: [CanisterStatusArgs], - returnIdlType: CanisterStatusResult, - args: [args] - }); + args: canister_status_args + ): Promise { + return await call<[canister_status_args], canister_status_result>( + 'aaaaa-aa', + 'canister_status', + { + paramIdlTypes: [canister_status_args], + returnIdlType: canister_status_result, + args: [args] + } + ); } @update([IDL.Principal], IDL.Bool) async executeDeleteCanister(canisterId: Principal): Promise { - await call('aaaaa-aa', 'delete_canister', { - paramIdlTypes: [DeleteCanisterArgs], - args: [ - { - canister_id: canisterId - } - ] - }); + await call<[delete_canister_args], void>( + 'aaaaa-aa', + 'delete_canister', + { + paramIdlTypes: [delete_canister_args], + args: [ + { + canister_id: canisterId + } + ] + } + ); return true; } @update([IDL.Principal], IDL.Bool) async executeDepositCycles(canisterId: Principal): Promise { - await call('aaaaa-aa', 'deposit_cycles', { - paramIdlTypes: [DepositCyclesArgs], + await call<[deposit_cycles_args], void>('aaaaa-aa', 'deposit_cycles', { + paramIdlTypes: [deposit_cycles_args], args: [ { canister_id: canisterId @@ -251,47 +291,52 @@ export default class { return true; } - @update([], IDL.Vec(IDL.Nat8)) + @update([], raw_rand_result) async getRawRand(): Promise { - return await call('aaaaa-aa', 'raw_rand', { - returnIdlType: IDL.Vec(IDL.Nat8) + return await call<[], Uint8Array>('aaaaa-aa', 'raw_rand', { + returnIdlType: raw_rand_result + }); + } + + // TODO we should test this like we test depositCycles + @update([], provisional_create_canister_with_cycles_result) + async provisionalCreateCanisterWithCycles(): Promise { + return await call< + [provisional_create_canister_with_cycles_args], + provisional_create_canister_with_cycles_result + >('aaaaa-aa', 'provisional_create_canister_with_cycles', { + paramIdlTypes: [provisional_create_canister_with_cycles_args], + returnIdlType: provisional_create_canister_with_cycles_result, + args: [ + { + amount: [], + settings: [], + sender_canister_version: [], + specified_id: [] + } + ] }); } + // TODO we should test this like we test depositCycles - @update([], ProvisionalCreateCanisterWithCyclesResult) - async provisionalCreateCanisterWithCycles(): Promise { - return await call( + @update([IDL.Principal, IDL.Nat], IDL.Bool) + async provisionalTopUpCanister( + canisterId: Principal, + amount: bigint + ): Promise { + await call<[provisional_top_up_canister_args], void>( 'aaaaa-aa', - 'provisional_create_canister_with_cycles', + 'provisional_top_up_canister', { - paramIdlTypes: [ProvisionalCreateCanisterWithCyclesArgs], - returnIdlType: ProvisionalCreateCanisterWithCyclesResult, + paramIdlTypes: [provisional_top_up_canister_args], args: [ { - amount: [], - settings: [], - sender_canister_version: [], - specified_id: [] + canister_id: canisterId, + amount } ] } ); - } - // TODO we should test this like we test depositCycles - @update([IDL.Principal, IDL.Nat], IDL.Bool) - async provisionalTopUpCanister( - canisterId: Principal, - amount: bigint - ): Promise { - await call('aaaaa-aa', 'provisional_top_up_canister', { - paramIdlTypes: [ProvisionalTopUpCanisterArgs], - args: [ - { - canister_id: canisterId, - amount - } - ] - }); return true; } @@ -302,11 +347,15 @@ export default class { } } -async function createCanister(): Promise { - return await call('aaaaa-aa', 'create_canister', { - paramIdlTypes: [CreateCanisterArgs], - returnIdlType: CreateCanisterResult, - args: [{ settings: [], sender_canister_version: [] }], - payment: 50_000_000_000_000n - }); +async function createCanister(): Promise { + return await call<[create_canister_args], create_canister_result>( + 'aaaaa-aa', + 'create_canister', + { + paramIdlTypes: [create_canister_args], + returnIdlType: create_canister_result, + args: [{ settings: [], sender_canister_version: [] }], + payment: 50_000_000_000_000n + } + ); } diff --git a/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/package-lock.json b/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/package-lock.json index a1a8c2c14f..efb6ea0836 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/package-lock.json +++ b/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/package-lock.json @@ -18,6 +18,7 @@ } }, "../../../functional_syntax/motoko_examples/threshold_ecdsa": { + "name": "threshold_ecdsa_end_to_end_test_functional_syntax", "dev": true, "dependencies": { "azle": "0.24.1", diff --git a/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/src/index.ts b/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/src/index.ts index e6446bcf1c..a7a69f142a 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/src/index.ts +++ b/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/src/index.ts @@ -1,9 +1,9 @@ import { call, caller, IDL, trap, update } from 'azle'; import { - EcdsaPublicKeyArgs, - EcdsaPublicKeyResult, - SignWithEcdsaArgs, - SignWithEcdsaResult + ecdsa_public_key_args, + ecdsa_public_key_result, + sign_with_ecdsa_args, + sign_with_ecdsa_result } from 'azle/canisters/management'; const PublicKey = IDL.Record({ @@ -24,8 +24,9 @@ export default class { @update([], PublicKey) async publicKey(): Promise { const publicKeyResult = await getPublicKeyResult(); + return { - publicKey: publicKeyResult.public_key + publicKey: Uint8Array.from(publicKeyResult.public_key) }; } @@ -38,44 +39,52 @@ export default class { const signatureResult = await getSignatureResult(messageHash); return { - signature: signatureResult.signature + signature: Uint8Array.from(signatureResult.signature) }; } } -async function getPublicKeyResult(): Promise { - return await call('aaaaa-aa', 'ecdsa_public_key', { - paramIdlTypes: [EcdsaPublicKeyArgs], - returnIdlType: EcdsaPublicKeyResult, - args: [ - { - canister_id: [], - derivation_path: [caller().toUint8Array()], - key_id: { - curve: { secp256k1: null }, - name: 'dfx_test_key' +async function getPublicKeyResult(): Promise { + return await call<[ecdsa_public_key_args], ecdsa_public_key_result>( + 'aaaaa-aa', + 'ecdsa_public_key', + { + paramIdlTypes: [ecdsa_public_key_args], + returnIdlType: ecdsa_public_key_result, + args: [ + { + canister_id: [], + derivation_path: [caller().toUint8Array()], + key_id: { + curve: { secp256k1: null }, + name: 'dfx_test_key' + } } - } - ] - }); + ] + } + ); } async function getSignatureResult( messageHash: Uint8Array -): Promise { - return await call('aaaaa-aa', 'sign_with_ecdsa', { - paramIdlTypes: [SignWithEcdsaArgs], - returnIdlType: SignWithEcdsaResult, - args: [ - { - message_hash: messageHash, - derivation_path: [caller().toUint8Array()], - key_id: { - curve: { secp256k1: null }, - name: 'dfx_test_key' +): Promise { + return await call<[sign_with_ecdsa_args], sign_with_ecdsa_result>( + 'aaaaa-aa', + 'sign_with_ecdsa', + { + paramIdlTypes: [sign_with_ecdsa_args], + returnIdlType: sign_with_ecdsa_result, + args: [ + { + message_hash: messageHash, + derivation_path: [caller().toUint8Array()], + key_id: { + curve: { secp256k1: null }, + name: 'dfx_test_key' + } } - } - ], - payment: 10_000_000_000n - }); + ], + payment: 10_000_000_000n + } + ); } diff --git a/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/package-lock.json b/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/package-lock.json index 81e08a2a28..38e13154ac 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/package-lock.json +++ b/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/package-lock.json @@ -38,7 +38,7 @@ "name": "outgoing_http_requests_end_to_end_test_functional_syntax", "dev": true, "dependencies": { - "azle": "0.24.0" + "azle": "0.24.1" }, "devDependencies": { "@dfinity/agent": "0.11.1", @@ -9882,7 +9882,7 @@ "version": "file:../../functional_syntax/outgoing_http_requests", "requires": { "@dfinity/agent": "0.11.1", - "azle": "0.24.0", + "azle": "0.24.1", "decode-utf8": "1.0.1", "jest": "^29.7.0", "ts-jest": "^29.1.5", diff --git a/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/src/index.ts b/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/src/index.ts index 41f7bb1072..a0fe0c44f6 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/src/index.ts +++ b/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/src/index.ts @@ -9,17 +9,20 @@ import { update } from 'azle'; import { - HttpRequestArgs, - HttpResponse, - HttpTransformArgs + http_request_args, + http_request_result, + http_transform_args } from 'azle/canisters/management'; export default class { @update([], IDL.Text) async xkcd(): Promise { - const httpResponse = await call('aaaaa-aa', 'http_request', { - paramIdlTypes: [HttpRequestArgs], - returnIdlType: HttpResponse, + const httpResponse = await call< + [http_request_args], + http_request_result + >('aaaaa-aa', 'http_request', { + paramIdlTypes: [http_request_args], + returnIdlType: http_request_result, args: [ { url: `https://xkcd.com/642/info.0.json`, @@ -43,12 +46,12 @@ export default class { payment: 50_000_000n }); - return new TextDecoder().decode(httpResponse.body); + return new TextDecoder().decode(Uint8Array.from(httpResponse.body)); } - @update([], HttpResponse, { manual: true }) + @update([], http_request_result, { manual: true }) async xkcdRaw(): Promise { - const httpResponse = await call( + const httpResponse = await call( Principal.fromText('aaaaa-aa'), 'http_request', { @@ -71,8 +74,8 @@ export default class { reply({ raw: httpResponse }); } - @query([HttpTransformArgs], HttpResponse) - xkcdTransform(args: HttpTransformArgs): HttpResponse { + @query([http_transform_args], http_request_result) + xkcdTransform(args: http_transform_args): http_request_result { return { ...args.response, headers: [] diff --git a/tests/end_to_end/candid_rpc/functional_syntax/management_canister/src/index.ts b/tests/end_to_end/candid_rpc/functional_syntax/management_canister/src/index.ts index 2ba98da279..04d2e0bd8a 100644 --- a/tests/end_to_end/candid_rpc/functional_syntax/management_canister/src/index.ts +++ b/tests/end_to_end/candid_rpc/functional_syntax/management_canister/src/index.ts @@ -53,9 +53,11 @@ export default Canister({ settings: { controllers: [], compute_allocation: [1n], + log_visibility: [], memory_allocation: [3_000_000n], freezing_threshold: [2_000_000n], - reserved_cycles_limit: [] + reserved_cycles_limit: [], + wasm_memory_limit: [] }, sender_canister_version: [] }