UNPKG

@dfinity/cmc

Version:

A library for interfacing with the cycle minting canister.

64 lines (63 loc) 3.43 kB
import type { Principal } from "@dfinity/principal"; import { Canister, type QueryParams } from "@dfinity/utils"; import type { _SERVICE as CMCCanisterService, Cycles, NotifyCreateCanisterArg, NotifyTopUpArg, SubnetTypesToSubnetsResponse } from "../candid/cmc"; import type { CMCCanisterOptions } from "./cmc.options"; export declare class CMCCanister extends Canister<CMCCanisterService> { static create(options: CMCCanisterOptions): CMCCanister; /** * Returns conversion rate of ICP to Cycles. It can be called as query or update. * * @param {Object} [params] - The parameters for the call. * @param {boolean} [params.certified] - Determines whether the response should be certified (default: non-certified) * * @returns Promise<BigInt> */ getIcpToCyclesConversionRate: ({ certified, }?: QueryParams) => Promise<bigint>; /** * Notifies Cycles Minting Canister of the creation of a new canister. * It returns the new canister principal. * * @param {Object} request * @param {Principal} request.controller * @param {BlockIndex} request.block_index * @returns Promise<Principal> * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError */ notifyCreateCanister: (request: NotifyCreateCanisterArg) => Promise<Principal>; /** * Notifies Cycles Minting Canister of new cycles being added to canister. * It returns the new Cycles of the canister. * * @param {Object} request * @param {Principal} request.canister_id * @param {BlockIndex} request.block_index * @returns Promise<Cycles> * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError */ notifyTopUp: (request: NotifyTopUpArg) => Promise<Cycles>; /** * This function calls the `get_default_subnets` method of the CMC canister, which returns a list of * default subnets as `Principal` objects. It can be called as query or update. * * @param {Object} [params] - The query parameters for the call. * @param {boolean} [params.certified] - Determines whether the response should be certified * (default: non-certified if not specified). * * @returns {Promise<Principal[]>} - A promise that resolves to an array of `Principal` objects * representing the default subnets. */ getDefaultSubnets: ({ certified }?: QueryParams) => Promise<Principal[]>; /** * This function calls the `get_subnet_types_to_subnets` method of the CMC canister, which returns a list of subnets where canisters can be created. * These subnets are excluded from the random subnet selection process used by the CMC when no explicit subnet ID is provided * during canister creation and therefore, not provided in the results of the similar function `get_default_subnets`. * * @param {Object} [params] - The optional query parameters for the call. * @param {boolean} [params.certified=false] - Specifies whether the response should be certified. * If not provided, the response defaults to non-certified. * * @returns {Promise<SubnetTypesToSubnetsResponse>} - A promise that resolves to an object representing * the mapping of subnet types to subnets. */ getSubnetTypesToSubnets: ({ certified, }?: QueryParams) => Promise<SubnetTypesToSubnetsResponse>; }