Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dfinity/cmc

Package Overview
Dependencies
Maintainers
0
Versions
818
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dfinity/cmc - npm Package Compare versions

Comparing version 3.2.2 to 4.0.0-next-2024-11-01

dist/esm/chunk-5XIQBCLB.js

2

dist/cjs/index.cjs.js

@@ -1,2 +0,2 @@

"use strict";var y=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var J=(t,e)=>{for(var r in e)y(t,r,{get:e[r],enumerable:!0})},X=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $(e))!z.call(t,n)&&n!==r&&y(t,n,{get:()=>e[n],enumerable:!(i=q(e,n))||i.enumerable});return t};var B=t=>X(y({},"__esModule",{value:!0}),t);var j={};J(j,{CMCCanister:()=>_,CMCError:()=>a,InvalidaTransactionError:()=>s,ProcessingError:()=>p,RefundedError:()=>c,TransactionTooOldError:()=>l,throwNotifyError:()=>d});module.exports=B(j);var C=require("@dfinity/agent");var O=({IDL:t})=>{let e=t.Variant({Set:t.Principal,Unset:t.Null}),r=t.Text,i=t.Record({exchange_rate_canister:t.Opt(e),cycles_ledger_canister_id:t.Opt(t.Principal),last_purged_notification:t.Opt(t.Nat64),governance_canister_id:t.Opt(t.Principal),minting_account_id:t.Opt(r),ledger_canister_id:t.Opt(t.Principal)}),n=t.Record({subnet_type:t.Opt(t.Text)}),f=t.Variant({Filter:n,Subnet:t.Record({subnet:t.Principal})}),N=t.Variant({controllers:t.Null,public:t.Null}),m=t.Record({freezing_threshold:t.Opt(t.Nat),wasm_memory_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(N),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),g=t.Record({subnet_selection:t.Opt(f),settings:t.Opt(m),subnet_type:t.Opt(t.Text)}),x=t.Variant({Refunded:t.Record({create_error:t.Text,refund_amount:t.Nat})}),R=t.Variant({Ok:t.Principal,Err:x}),b=t.Record({xdr_permyriad_per_icp:t.Nat64,timestamp_seconds:t.Nat64}),h=t.Record({certificate:t.Vec(t.Nat8),data:b,hash_tree:t.Vec(t.Nat8)}),T=t.Record({data:t.Vec(t.Tuple(t.Principal,t.Vec(t.Principal)))}),P=t.Record({data:t.Vec(t.Tuple(t.Text,t.Vec(t.Principal)))}),o=t.Nat64,E=t.Record({controller:t.Principal,block_index:o,subnet_selection:t.Opt(f),settings:t.Opt(m),subnet_type:t.Opt(t.Text)}),u=t.Variant({Refunded:t.Record({block_index:t.Opt(o),reason:t.Text}),InvalidTransaction:t.Text,Other:t.Record({error_message:t.Text,error_code:t.Nat64}),Processing:t.Null,TransactionTooOld:o}),w=t.Variant({Ok:t.Principal,Err:u}),v=t.Opt(t.Vec(t.Nat8)),V=t.Opt(t.Vec(t.Nat8)),S=t.Record({block_index:o,deposit_memo:v,to_subaccount:V}),A=t.Record({balance:t.Nat,block_index:t.Nat,minted:t.Nat}),k=t.Variant({Ok:A,Err:u}),F=t.Record({block_index:o,canister_id:t.Principal}),U=t.Nat,M=t.Variant({Ok:U,Err:u});return t.Service({create_canister:t.Func([g],[R],[]),get_build_metadata:t.Func([],[t.Text],["query"]),get_default_subnets:t.Func([],[t.Vec(t.Principal)],["query"]),get_icp_xdr_conversion_rate:t.Func([],[h],["query"]),get_principals_authorized_to_create_canisters_to_subnets:t.Func([],[T],["query"]),get_subnet_types_to_subnets:t.Func([],[P],["query"]),notify_create_canister:t.Func([E],[w],[]),notify_mint_cycles:t.Func([S],[k],[]),notify_top_up:t.Func([F],[M],[])})};var c=class extends Error{},s=class extends Error{},a=class extends Error{},p=class extends Error{},l=class extends Error{},d=({Err:t})=>{throw"Refunded"in t?new c(t.Refunded.reason):"InvalidTransaction"in t?new s(t.InvalidTransaction):"Processing"in t?new p:"TransactionTooOld"in t?new l:"Other"in t?new a(`Error in CMC with code ${t.Other.error_code}: ${t.Other.error_message}`):new Error(`Unsupported error type ${JSON.stringify(t)}`)};var _=class t{constructor(e){this.service=e;this.getIcpToCyclesConversionRate=async()=>{let{data:e}=await this.service.get_icp_xdr_conversion_rate();return e.xdr_permyriad_per_icp};this.notifyCreateCanister=async e=>{let r=await this.service.notify_create_canister(e);if("Err"in r&&d(r),"Ok"in r)return r.Ok;throw new Error(`Unsupported response type in notifyCreateCanister ${JSON.stringify(r)}`)};this.notifyTopUp=async e=>{let r=await this.service.notify_top_up(e);if("Err"in r&&d(r),"Ok"in r)return r.Ok;throw new Error(`Unsupported response type in notifyTopUp ${JSON.stringify(r)}`)};this.service=e}static create(e){let r=e.agent,i=e.canisterId,n=e.serviceOverride??C.Actor.createActor(O,{agent:r,canisterId:i});return new t(n)}};0&&(module.exports={CMCCanister,CMCError,InvalidaTransactionError,ProcessingError,RefundedError,TransactionTooOldError,throwNotifyError});
"use strict";var U=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var J=(t,n)=>{for(var r in n)U(t,r,{get:n[r],enumerable:!0})},B=(t,n,r,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of $(n))!X.call(t,i)&&i!==r&&U(t,i,{get:()=>n[i],enumerable:!(e=q(n,i))||e.enumerable});return t};var Q=t=>B(U({},"__esModule",{value:!0}),t);var j={};J(j,{CMCCanister:()=>f,CMCError:()=>_,InvalidaTransactionError:()=>l,ProcessingError:()=>d,RefundedError:()=>p,TransactionTooOldError:()=>u,throwNotifyError:()=>y});module.exports=Q(j);var O=require("@dfinity/utils");var M=({IDL:t})=>{let n=t.Variant({Set:t.Principal,Unset:t.Null}),r=t.Text,e=t.Record({exchange_rate_canister:t.Opt(n),cycles_ledger_canister_id:t.Opt(t.Principal),last_purged_notification:t.Opt(t.Nat64),governance_canister_id:t.Opt(t.Principal),minting_account_id:t.Opt(r),ledger_canister_id:t.Opt(t.Principal)}),i=t.Record({subnet_type:t.Opt(t.Text)}),o=t.Variant({Filter:i,Subnet:t.Record({subnet:t.Principal})}),C=t.Variant({controllers:t.Null,public:t.Null}),s=t.Record({freezing_threshold:t.Opt(t.Nat),wasm_memory_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(C),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),N=t.Record({subnet_selection:t.Opt(o),settings:t.Opt(s),subnet_type:t.Opt(t.Text)}),m=t.Variant({Refunded:t.Record({create_error:t.Text,refund_amount:t.Nat})}),g=t.Variant({Ok:t.Principal,Err:m}),x=t.Record({xdr_permyriad_per_icp:t.Nat64,timestamp_seconds:t.Nat64}),b=t.Record({certificate:t.Vec(t.Nat8),data:x,hash_tree:t.Vec(t.Nat8)}),R=t.Record({data:t.Vec(t.Tuple(t.Principal,t.Vec(t.Principal)))}),P=t.Record({data:t.Vec(t.Tuple(t.Text,t.Vec(t.Principal)))}),c=t.Nat64,T=t.Record({controller:t.Principal,block_index:c,subnet_selection:t.Opt(o),settings:t.Opt(s),subnet_type:t.Opt(t.Text)}),a=t.Variant({Refunded:t.Record({block_index:t.Opt(c),reason:t.Text}),InvalidTransaction:t.Text,Other:t.Record({error_message:t.Text,error_code:t.Nat64}),Processing:t.Null,TransactionTooOld:c}),h=t.Variant({Ok:t.Principal,Err:a}),V=t.Opt(t.Vec(t.Nat8)),S=t.Opt(t.Vec(t.Nat8)),v=t.Record({block_index:c,deposit_memo:V,to_subaccount:S}),E=t.Record({balance:t.Nat,block_index:t.Nat,minted:t.Nat}),w=t.Variant({Ok:E,Err:a}),F=t.Record({block_index:c,canister_id:t.Principal}),k=t.Nat,A=t.Variant({Ok:k,Err:a});return t.Service({create_canister:t.Func([N],[g],[]),get_build_metadata:t.Func([],[t.Text],[]),get_default_subnets:t.Func([],[t.Vec(t.Principal)],[]),get_icp_xdr_conversion_rate:t.Func([],[b],[]),get_principals_authorized_to_create_canisters_to_subnets:t.Func([],[R],[]),get_subnet_types_to_subnets:t.Func([],[P],[]),notify_create_canister:t.Func([T],[h],[]),notify_mint_cycles:t.Func([v],[w],[]),notify_top_up:t.Func([F],[A],[])})};var z=({IDL:t})=>{let n=t.Variant({Set:t.Principal,Unset:t.Null}),r=t.Text,e=t.Record({exchange_rate_canister:t.Opt(n),cycles_ledger_canister_id:t.Opt(t.Principal),last_purged_notification:t.Opt(t.Nat64),governance_canister_id:t.Opt(t.Principal),minting_account_id:t.Opt(r),ledger_canister_id:t.Opt(t.Principal)}),i=t.Record({subnet_type:t.Opt(t.Text)}),o=t.Variant({Filter:i,Subnet:t.Record({subnet:t.Principal})}),C=t.Variant({controllers:t.Null,public:t.Null}),s=t.Record({freezing_threshold:t.Opt(t.Nat),wasm_memory_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(C),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),N=t.Record({subnet_selection:t.Opt(o),settings:t.Opt(s),subnet_type:t.Opt(t.Text)}),m=t.Variant({Refunded:t.Record({create_error:t.Text,refund_amount:t.Nat})}),g=t.Variant({Ok:t.Principal,Err:m}),x=t.Record({xdr_permyriad_per_icp:t.Nat64,timestamp_seconds:t.Nat64}),b=t.Record({certificate:t.Vec(t.Nat8),data:x,hash_tree:t.Vec(t.Nat8)}),R=t.Record({data:t.Vec(t.Tuple(t.Principal,t.Vec(t.Principal)))}),P=t.Record({data:t.Vec(t.Tuple(t.Text,t.Vec(t.Principal)))}),c=t.Nat64,T=t.Record({controller:t.Principal,block_index:c,subnet_selection:t.Opt(o),settings:t.Opt(s),subnet_type:t.Opt(t.Text)}),a=t.Variant({Refunded:t.Record({block_index:t.Opt(c),reason:t.Text}),InvalidTransaction:t.Text,Other:t.Record({error_message:t.Text,error_code:t.Nat64}),Processing:t.Null,TransactionTooOld:c}),h=t.Variant({Ok:t.Principal,Err:a}),V=t.Opt(t.Vec(t.Nat8)),S=t.Opt(t.Vec(t.Nat8)),v=t.Record({block_index:c,deposit_memo:V,to_subaccount:S}),E=t.Record({balance:t.Nat,block_index:t.Nat,minted:t.Nat}),w=t.Variant({Ok:E,Err:a}),F=t.Record({block_index:c,canister_id:t.Principal}),k=t.Nat,A=t.Variant({Ok:k,Err:a});return t.Service({create_canister:t.Func([N],[g],[]),get_build_metadata:t.Func([],[t.Text],["query"]),get_default_subnets:t.Func([],[t.Vec(t.Principal)],["query"]),get_icp_xdr_conversion_rate:t.Func([],[b],["query"]),get_principals_authorized_to_create_canisters_to_subnets:t.Func([],[R],["query"]),get_subnet_types_to_subnets:t.Func([],[P],["query"]),notify_create_canister:t.Func([T],[h],[]),notify_mint_cycles:t.Func([v],[w],[]),notify_top_up:t.Func([F],[A],[])})};var p=class extends Error{},l=class extends Error{},_=class extends Error{},d=class extends Error{},u=class extends Error{},y=({Err:t})=>{throw"Refunded"in t?new p(t.Refunded.reason):"InvalidTransaction"in t?new l(t.InvalidTransaction):"Processing"in t?new d:"TransactionTooOld"in t?new u:"Other"in t?new _(`Error in CMC with code ${t.Other.error_code}: ${t.Other.error_message}`):new Error(`Unsupported error type ${JSON.stringify(t)}`)};var f=class t extends O.Canister{constructor(){super(...arguments);this.getIcpToCyclesConversionRate=async()=>{let{data:r}=await this.service.get_icp_xdr_conversion_rate();return r.xdr_permyriad_per_icp};this.notifyCreateCanister=async r=>{let e=await this.service.notify_create_canister(r);if("Err"in e&&y(e),"Ok"in e)return e.Ok;throw new Error(`Unsupported response type in notifyCreateCanister ${JSON.stringify(e)}`)};this.notifyTopUp=async r=>{let e=await this.service.notify_top_up(r);if("Err"in e&&y(e),"Ok"in e)return e.Ok;throw new Error(`Unsupported response type in notifyTopUp ${JSON.stringify(e)}`)};this.getDefaultSubnets=async({certified:r}={})=>{let{get_default_subnets:e}=this.caller({certified:r});return e()}}static create(r){let{service:e,certifiedService:i,canisterId:o}=(0,O.createServices)({options:r,idlFactory:z,certifiedIdlFactory:M});return new t(o,e,i)}};0&&(module.exports={CMCCanister,CMCError,InvalidaTransactionError,ProcessingError,RefundedError,TransactionTooOldError,throwNotifyError});
//# sourceMappingURL=index.cjs.js.map

@@ -1,2 +0,2 @@

import{a}from"./chunk-MKLB3JOX.js";import"./chunk-XRC5EOJ2.js";export{a as CMCCanister};
import{a}from"./chunk-5XIQBCLB.js";import"./chunk-XRC5EOJ2.js";export{a as CMCCanister};
//# sourceMappingURL=cmc.canister.js.map

@@ -1,2 +0,2 @@

import{a as r}from"./chunk-MKLB3JOX.js";import{a as e,b as o,c as t,d as p,e as C,f}from"./chunk-XRC5EOJ2.js";export{r as CMCCanister,t as CMCError,o as InvalidaTransactionError,p as ProcessingError,e as RefundedError,C as TransactionTooOldError,f as throwNotifyError};
import{a as r}from"./chunk-5XIQBCLB.js";import{a as e,b as o,c as t,d as p,e as C,f}from"./chunk-XRC5EOJ2.js";export{r as CMCCanister,t as CMCError,o as InvalidaTransactionError,p as ProcessingError,e as RefundedError,C as TransactionTooOldError,f as throwNotifyError};
//# sourceMappingURL=index.js.map
import type { Principal } from "@dfinity/principal";
import type { Cycles, NotifyCreateCanisterArg, NotifyTopUpArg } from "../candid/cmc";
import { Canister, type QueryParams } from "@dfinity/utils";
import type { _SERVICE as CMCCanisterService, Cycles, NotifyCreateCanisterArg, NotifyTopUpArg } from "../candid/cmc";
import type { CMCCanisterOptions } from "./cmc.options";
export declare class CMCCanister {
private readonly service;
private constructor();
export declare class CMCCanister extends Canister<CMCCanisterService> {
static create(options: CMCCanisterOptions): CMCCanister;

@@ -36,2 +35,14 @@ /**

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[]>;
}

@@ -5,3 +5,3 @@ import type { Principal } from "@dfinity/principal";

export interface CMCCanisterOptions extends Omit<CanisterOptions<CanisterService>, "canisterId"> {
canisterId: string | Principal;
canisterId: Principal;
}
{
"name": "@dfinity/cmc",
"version": "3.2.2",
"version": "4.0.0-next-2024-11-01",
"description": "A library for interfacing with the cycle minting canister.",

@@ -39,7 +39,7 @@ "license": "Apache-2.0",

"peerDependencies": {
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.5.2"
"@dfinity/agent": "*",
"@dfinity/candid": "*",
"@dfinity/principal": "*",
"@dfinity/utils": "*"
}
}
}

@@ -58,3 +58,3 @@ # cmc-js

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L13)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L14)

@@ -67,2 +67,3 @@ #### Methods

- [notifyTopUp](#gear-notifytopup)
- [getDefaultSubnets](#gear-getdefaultsubnets)

@@ -75,3 +76,3 @@ ##### :gear: create

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L18)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L15)

@@ -86,3 +87,3 @@ ##### :gear: getIcpToCyclesConversionRate

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L37)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L31)

@@ -98,3 +99,3 @@ ##### :gear: notifyCreateCanister

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L54)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L48)

@@ -110,4 +111,21 @@ ##### :gear: notifyTopUp

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L82)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L76)
##### :gear: getDefaultSubnets
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.
| Method | Type |
| ------------------- | ------------------------------------------------------- |
| `getDefaultSubnets` | `({ certified }?: QueryParams) => Promise<Principal[]>` |
Parameters:
- `params`: - The query parameters for the call.
- `params.certified`: - Determines whether the response should be certified
(default: non-certified if not specified).
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/cmc/src/cmc.canister.ts#L101)
<!-- TSDOC_END -->

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc