@dfinity/cmc 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,8 +23,8 @@ export const idlFactory = ({ IDL }) => {
23
23
  'public' : IDL.Null,
24
24
  });
25
25
  const CanisterSettings = IDL.Record({
26
- 'controller' : IDL.Opt(IDL.Principal),
27
26
  'freezing_threshold' : IDL.Opt(IDL.Nat),
27
+ 'wasm_memory_threshold' : IDL.Opt(IDL.Nat),
28
28
  'controllers' : IDL.Opt(IDL.Vec(IDL.Principal)),
29
29
  'reserved_cycles_limit' : IDL.Opt(IDL.Nat),
30
30
  'log_visibility' : IDL.Opt(log_visibility),
@@ -5,8 +5,8 @@ import type { Principal } from "@dfinity/principal";
5
5
  export type AccountIdentifier = string;
6
6
  export type BlockIndex = bigint;
7
7
  export interface CanisterSettings {
8
- controller: [] | [Principal];
9
8
  freezing_threshold: [] | [bigint];
9
+ wasm_memory_threshold: [] | [bigint];
10
10
  controllers: [] | [Array<Principal>];
11
11
  reserved_cycles_limit: [] | [bigint];
12
12
  log_visibility: [] | [log_visibility];
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit a3831c8 (2024-07-11 tags: release-2024-07-10_23-01-base) 'rs/nns/cmc/cmc.did' by import-candid
1
+ // Generated from IC repo commit 3d6a76e (2024-08-14 tags: release-2024-08-21_15-36-canister-snapshots) 'rs/nns/cmc/cmc.did' by import-candid
2
2
  type Cycles = nat;
3
3
  type BlockIndex = nat64;
4
4
  type log_visibility = variant {
@@ -6,14 +6,14 @@ type log_visibility = variant {
6
6
  public;
7
7
  };
8
8
  type CanisterSettings = record {
9
- controller : opt principal;
10
9
  controllers : opt vec principal;
11
10
  compute_allocation : opt nat;
12
11
  memory_allocation : opt nat;
13
12
  freezing_threshold : opt nat;
14
- reserved_cycles_limit: opt nat;
13
+ reserved_cycles_limit : opt nat;
15
14
  log_visibility : opt log_visibility;
16
- wasm_memory_limit: opt nat;
15
+ wasm_memory_limit : opt nat;
16
+ wasm_memory_threshold : opt nat;
17
17
  };
18
18
  type Subaccount = opt blob;
19
19
  type Memo = opt blob;
@@ -27,18 +27,17 @@ type NotifyTopUpArg = record {
27
27
  canister_id : principal;
28
28
  };
29
29
 
30
-
31
30
  type SubnetSelection = variant {
32
- /// Choose a specific subnet
33
- Subnet : record {
34
- subnet: principal;
35
- };
36
- /// Choose a random subnet that fulfills the specified properties
37
- Filter : SubnetFilter;
31
+ /// Choose a specific subnet
32
+ Subnet : record {
33
+ subnet : principal;
34
+ };
35
+ /// Choose a random subnet that fulfills the specified properties
36
+ Filter : SubnetFilter;
38
37
  };
39
38
 
40
39
  type SubnetFilter = record {
41
- subnet_type: opt text;
40
+ subnet_type : opt text;
42
41
  };
43
42
 
44
43
  // The argument of the [create_canister] method.
@@ -50,10 +49,10 @@ type CreateCanisterArg = record {
50
49
  // An optional subnet type that, if set, determines what type of subnet
51
50
  // the new canister will be created on.
52
51
  // Deprecated. Use subnet_selection instead.
53
- subnet_type: opt text;
52
+ subnet_type : opt text;
54
53
 
55
54
  // Optional instructions to select on which subnet the new canister will be created on.
56
- subnet_selection: opt SubnetSelection;
55
+ subnet_selection : opt SubnetSelection;
57
56
  };
58
57
 
59
58
  // The argument of the [notify_create_canister] method.
@@ -67,11 +66,11 @@ type NotifyCreateCanisterArg = record {
67
66
  // An optional subnet type that, if set, determines what type of subnet
68
67
  // the new canister will be created on.
69
68
  // Deprecated. Use subnet_selection instead.
70
- subnet_type: opt text;
69
+ subnet_type : opt text;
71
70
 
72
71
  // Optional instructions to select on which subnet the new canister will be created on.
73
72
  // vec may contain no more than one element.
74
- subnet_selection: opt SubnetSelection;
73
+ subnet_selection : opt SubnetSelection;
75
74
 
76
75
  // Optional canister settings that, if set, are applied to the newly created canister.
77
76
  // If not specified, the caller is the controller of the canister and the other settings are set to default values.
@@ -83,17 +82,17 @@ type NotifyCreateCanisterArg = record {
83
82
  type CreateCanisterError = variant {
84
83
  Refunded : record {
85
84
  // The amount of cycles returned to the calling canister
86
- refund_amount: nat;
85
+ refund_amount : nat;
87
86
 
88
87
  // The reason why creating a canister failed.
89
- create_error: text;
88
+ create_error : text;
90
89
  };
91
90
  RefundFailed : record {
92
91
  // The reason why creating a canister failed.
93
- create_error: text;
92
+ create_error : text;
94
93
 
95
94
  // The reason why refunding cycles failed.
96
- refund_error: text;
95
+ refund_error : text;
97
96
  };
98
97
  };
99
98
 
@@ -153,7 +152,6 @@ type IcpXdrConversionRate = record {
153
152
  xdr_permyriad_per_icp : nat64;
154
153
  };
155
154
 
156
-
157
155
  type IcpXdrConversionRateResponse = record {
158
156
  // The latest ICP/XDR conversion rate.
159
157
  data : IcpXdrConversionRate;
@@ -176,49 +174,49 @@ type IcpXdrConversionRateResponse = record {
176
174
  };
177
175
 
178
176
  type SubnetTypesToSubnetsResponse = record {
179
- data: vec record { text; vec principal };
177
+ data : vec record { text; vec principal };
180
178
  };
181
179
 
182
180
  type PrincipalsAuthorizedToCreateCanistersToSubnetsResponse = record {
183
- data: vec record { principal; vec principal };
181
+ data : vec record { principal; vec principal };
184
182
  };
185
183
 
186
184
  type AccountIdentifier = text;
187
185
 
188
186
  type ExchangeRateCanister = variant {
189
- /// Enables the exchange rate canister with the given canister ID.
190
- Set: principal;
191
- /// Disable the exchange rate canister.
192
- Unset;
187
+ /// Enables the exchange rate canister with the given canister ID.
188
+ Set : principal;
189
+ /// Disable the exchange rate canister.
190
+ Unset;
193
191
  };
194
192
 
195
193
  type CyclesCanisterInitPayload = record {
196
- ledger_canister_id: opt principal;
197
- governance_canister_id: opt principal;
198
- minting_account_id: opt AccountIdentifier;
199
- last_purged_notification: opt nat64;
200
- exchange_rate_canister: opt ExchangeRateCanister;
201
- cycles_ledger_canister_id: opt principal;
194
+ ledger_canister_id : opt principal;
195
+ governance_canister_id : opt principal;
196
+ minting_account_id : opt AccountIdentifier;
197
+ last_purged_notification : opt nat64;
198
+ exchange_rate_canister : opt ExchangeRateCanister;
199
+ cycles_ledger_canister_id : opt principal;
202
200
  };
203
201
 
204
202
  type NotifyMintCyclesArg = record {
205
- block_index: BlockIndex;
206
- to_subaccount: Subaccount;
207
- deposit_memo: Memo;
203
+ block_index : BlockIndex;
204
+ to_subaccount : Subaccount;
205
+ deposit_memo : Memo;
208
206
  };
209
207
 
210
208
  type NotifyMintCyclesResult = variant {
211
- Ok: NotifyMintCyclesSuccess;
212
- Err: NotifyError;
209
+ Ok : NotifyMintCyclesSuccess;
210
+ Err : NotifyError;
213
211
  };
214
212
 
215
213
  type NotifyMintCyclesSuccess = record {
216
- // Cycles ledger block index of deposit
217
- block_index: nat;
218
- // Amount of cycles that were minted and deposited to the cycles ledger
219
- minted: nat;
220
- // New balance of the cycles ledger account
221
- balance: nat;
214
+ // Cycles ledger block index of deposit
215
+ block_index : nat;
216
+ // Amount of cycles that were minted and deposited to the cycles ledger
217
+ minted : nat;
218
+ // New balance of the cycles ledger account
219
+ balance : nat;
222
220
  };
223
221
 
224
222
  service : (opt CyclesCanisterInitPayload) -> {
@@ -246,4 +244,4 @@ service : (opt CyclesCanisterInitPayload) -> {
246
244
  get_principals_authorized_to_create_canisters_to_subnets : () -> (PrincipalsAuthorizedToCreateCanistersToSubnetsResponse) query;
247
245
 
248
246
  get_build_metadata : () -> (text) query;
249
- }
247
+ };
@@ -23,8 +23,8 @@ export const idlFactory = ({ IDL }) => {
23
23
  'public' : IDL.Null,
24
24
  });
25
25
  const CanisterSettings = IDL.Record({
26
- 'controller' : IDL.Opt(IDL.Principal),
27
26
  'freezing_threshold' : IDL.Opt(IDL.Nat),
27
+ 'wasm_memory_threshold' : IDL.Opt(IDL.Nat),
28
28
  'controllers' : IDL.Opt(IDL.Vec(IDL.Principal)),
29
29
  'reserved_cycles_limit' : IDL.Opt(IDL.Nat),
30
30
  'log_visibility' : IDL.Opt(log_visibility),
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var q=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 q(e))!z.call(t,n)&&n!==r&&y(t,n,{get:()=>e[n],enumerable:!(i=$(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 m=require("@dfinity/agent");var C=({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}),O=t.Record({controller:t.Opt(t.Principal),freezing_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(O),subnet_type:t.Opt(t.Text)}),x=t.Variant({Refunded:t.Record({create_error:t.Text,refund_amount:t.Nat}),RefundFailed:t.Record({create_error:t.Text,refund_error:t.Text})}),R=t.Variant({Ok:t.Principal,Err:x}),b=t.Record({xdr_permyriad_per_icp:t.Nat64,timestamp_seconds:t.Nat64}),T=t.Record({certificate:t.Vec(t.Nat8),data:b,hash_tree:t.Vec(t.Nat8)}),h=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(O),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_icp_xdr_conversion_rate:t.Func([],[T],["query"]),get_principals_authorized_to_create_canisters_to_subnets:t.Func([],[h],["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??m.Actor.createActor(C,{agent:r,canisterId:i});return new t(n)}};0&&(module.exports={CMCCanister,CMCError,InvalidaTransactionError,ProcessingError,RefundedError,TransactionTooOldError,throwNotifyError});
1
+ "use strict";var y=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var q=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 q(e))!z.call(t,n)&&n!==r&&y(t,n,{get:()=>e[n],enumerable:!(i=$(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}),RefundFailed:t.Record({create_error:t.Text,refund_error:t.Text})}),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)))}),E=t.Record({data:t.Vec(t.Tuple(t.Text,t.Vec(t.Principal)))}),o=t.Nat64,P=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_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([],[E],["query"]),notify_create_canister:t.Func([P],[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});
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts", "../../src/cmc.canister.ts", "../../candid/cmc.idl.js", "../../src/cmc.errors.ts"],
4
- "sourcesContent": ["export type {\n Cycles,\n NotifyCreateCanisterArg,\n NotifyTopUpArg,\n} from \"../candid/cmc\";\nexport { CMCCanister } from \"./cmc.canister\";\nexport * from \"./cmc.errors\";\n", "import { Actor } from \"@dfinity/agent\";\nimport type { Principal } from \"@dfinity/principal\";\nimport type {\n Cycles,\n NotifyCreateCanisterArg,\n NotifyTopUpArg,\n _SERVICE,\n} from \"../candid/cmc\";\nimport { idlFactory } from \"../candid/cmc.idl\";\nimport { throwNotifyError } from \"./cmc.errors\";\nimport type { CMCCanisterOptions } from \"./cmc.options\";\n\nexport class CMCCanister {\n private constructor(private readonly service: _SERVICE) {\n this.service = service;\n }\n\n public static create(options: CMCCanisterOptions) {\n const agent = options.agent;\n const canisterId = options.canisterId;\n\n const service =\n options.serviceOverride ??\n Actor.createActor<_SERVICE>(idlFactory, {\n agent,\n canisterId,\n });\n\n return new CMCCanister(service);\n }\n\n /**\n * Returns conversion rate of ICP to Cycles\n *\n * @returns Promise<BigInt>\n */\n public getIcpToCyclesConversionRate = async (): Promise<bigint> => {\n const { data } = await this.service.get_icp_xdr_conversion_rate();\n\n // TODO: validate the certificate in the response - https://dfinity.atlassian.net/browse/FOLLOW-223\n return data.xdr_permyriad_per_icp;\n };\n\n /**\n * Notifies Cycles Minting Canister of the creation of a new canister.\n * It returns the new canister principal.\n *\n * @param {Object} request\n * @param {Principal} request.controller\n * @param {BlockIndex} request.block_index\n * @returns Promise<Principal>\n * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError\n */\n public notifyCreateCanister = async (\n request: NotifyCreateCanisterArg,\n ): Promise<Principal> => {\n const response = await this.service.notify_create_canister(request);\n if (\"Err\" in response) {\n throwNotifyError(response);\n }\n if (\"Ok\" in response) {\n return response.Ok;\n }\n // Edge case\n throw new Error(\n `Unsupported response type in notifyCreateCanister ${JSON.stringify(\n response,\n )}`,\n );\n };\n\n /**\n * Notifies Cycles Minting Canister of new cycles being added to canister.\n * It returns the new Cycles of the canister.\n *\n * @param {Object} request\n * @param {Principal} request.canister_id\n * @param {BlockIndex} request.block_index\n * @returns Promise<Cycles>\n * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError\n */\n public notifyTopUp = async (request: NotifyTopUpArg): Promise<Cycles> => {\n const response = await this.service.notify_top_up(request);\n if (\"Err\" in response) {\n throwNotifyError(response);\n }\n if (\"Ok\" in response) {\n return response.Ok;\n }\n // Edge case\n throw new Error(\n `Unsupported response type in notifyTopUp ${JSON.stringify(response)}`,\n );\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/cmc/candid/cmc.did */\nexport const idlFactory = ({ IDL }) => {\n const ExchangeRateCanister = IDL.Variant({\n 'Set' : IDL.Principal,\n 'Unset' : IDL.Null,\n });\n const AccountIdentifier = IDL.Text;\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\n 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),\n 'last_purged_notification' : IDL.Opt(IDL.Nat64),\n 'governance_canister_id' : IDL.Opt(IDL.Principal),\n 'minting_account_id' : IDL.Opt(AccountIdentifier),\n 'ledger_canister_id' : IDL.Opt(IDL.Principal),\n });\n const SubnetFilter = IDL.Record({ 'subnet_type' : IDL.Opt(IDL.Text) });\n const SubnetSelection = IDL.Variant({\n 'Filter' : SubnetFilter,\n 'Subnet' : IDL.Record({ 'subnet' : IDL.Principal }),\n });\n const log_visibility = IDL.Variant({\n 'controllers' : IDL.Null,\n 'public' : IDL.Null,\n });\n const CanisterSettings = IDL.Record({\n 'controller' : IDL.Opt(IDL.Principal),\n 'freezing_threshold' : IDL.Opt(IDL.Nat),\n 'controllers' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'reserved_cycles_limit' : IDL.Opt(IDL.Nat),\n 'log_visibility' : IDL.Opt(log_visibility),\n 'wasm_memory_limit' : IDL.Opt(IDL.Nat),\n 'memory_allocation' : IDL.Opt(IDL.Nat),\n 'compute_allocation' : IDL.Opt(IDL.Nat),\n });\n const CreateCanisterArg = IDL.Record({\n 'subnet_selection' : IDL.Opt(SubnetSelection),\n 'settings' : IDL.Opt(CanisterSettings),\n 'subnet_type' : IDL.Opt(IDL.Text),\n });\n const CreateCanisterError = IDL.Variant({\n 'Refunded' : IDL.Record({\n 'create_error' : IDL.Text,\n 'refund_amount' : IDL.Nat,\n }),\n 'RefundFailed' : IDL.Record({\n 'create_error' : IDL.Text,\n 'refund_error' : IDL.Text,\n }),\n });\n const CreateCanisterResult = IDL.Variant({\n 'Ok' : IDL.Principal,\n 'Err' : CreateCanisterError,\n });\n const IcpXdrConversionRate = IDL.Record({\n 'xdr_permyriad_per_icp' : IDL.Nat64,\n 'timestamp_seconds' : IDL.Nat64,\n });\n const IcpXdrConversionRateResponse = IDL.Record({\n 'certificate' : IDL.Vec(IDL.Nat8),\n 'data' : IcpXdrConversionRate,\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n const PrincipalsAuthorizedToCreateCanistersToSubnetsResponse = IDL.Record({\n 'data' : IDL.Vec(IDL.Tuple(IDL.Principal, IDL.Vec(IDL.Principal))),\n });\n const SubnetTypesToSubnetsResponse = IDL.Record({\n 'data' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Principal))),\n });\n const BlockIndex = IDL.Nat64;\n const NotifyCreateCanisterArg = IDL.Record({\n 'controller' : IDL.Principal,\n 'block_index' : BlockIndex,\n 'subnet_selection' : IDL.Opt(SubnetSelection),\n 'settings' : IDL.Opt(CanisterSettings),\n 'subnet_type' : IDL.Opt(IDL.Text),\n });\n const NotifyError = IDL.Variant({\n 'Refunded' : IDL.Record({\n 'block_index' : IDL.Opt(BlockIndex),\n 'reason' : IDL.Text,\n }),\n 'InvalidTransaction' : IDL.Text,\n 'Other' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'Processing' : IDL.Null,\n 'TransactionTooOld' : BlockIndex,\n });\n const NotifyCreateCanisterResult = IDL.Variant({\n 'Ok' : IDL.Principal,\n 'Err' : NotifyError,\n });\n const Memo = IDL.Opt(IDL.Vec(IDL.Nat8));\n const Subaccount = IDL.Opt(IDL.Vec(IDL.Nat8));\n const NotifyMintCyclesArg = IDL.Record({\n 'block_index' : BlockIndex,\n 'deposit_memo' : Memo,\n 'to_subaccount' : Subaccount,\n });\n const NotifyMintCyclesSuccess = IDL.Record({\n 'balance' : IDL.Nat,\n 'block_index' : IDL.Nat,\n 'minted' : IDL.Nat,\n });\n const NotifyMintCyclesResult = IDL.Variant({\n 'Ok' : NotifyMintCyclesSuccess,\n 'Err' : NotifyError,\n });\n const NotifyTopUpArg = IDL.Record({\n 'block_index' : BlockIndex,\n 'canister_id' : IDL.Principal,\n });\n const Cycles = IDL.Nat;\n const NotifyTopUpResult = IDL.Variant({ 'Ok' : Cycles, 'Err' : NotifyError });\n return IDL.Service({\n 'create_canister' : IDL.Func(\n [CreateCanisterArg],\n [CreateCanisterResult],\n [],\n ),\n 'get_build_metadata' : IDL.Func([], [IDL.Text], ['query']),\n 'get_icp_xdr_conversion_rate' : IDL.Func(\n [],\n [IcpXdrConversionRateResponse],\n ['query'],\n ),\n 'get_principals_authorized_to_create_canisters_to_subnets' : IDL.Func(\n [],\n [PrincipalsAuthorizedToCreateCanistersToSubnetsResponse],\n ['query'],\n ),\n 'get_subnet_types_to_subnets' : IDL.Func(\n [],\n [SubnetTypesToSubnetsResponse],\n ['query'],\n ),\n 'notify_create_canister' : IDL.Func(\n [NotifyCreateCanisterArg],\n [NotifyCreateCanisterResult],\n [],\n ),\n 'notify_mint_cycles' : IDL.Func(\n [NotifyMintCyclesArg],\n [NotifyMintCyclesResult],\n [],\n ),\n 'notify_top_up' : IDL.Func([NotifyTopUpArg], [NotifyTopUpResult], []),\n });\n};\nexport const init = ({ IDL }) => {\n const ExchangeRateCanister = IDL.Variant({\n 'Set' : IDL.Principal,\n 'Unset' : IDL.Null,\n });\n const AccountIdentifier = IDL.Text;\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\n 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),\n 'last_purged_notification' : IDL.Opt(IDL.Nat64),\n 'governance_canister_id' : IDL.Opt(IDL.Principal),\n 'minting_account_id' : IDL.Opt(AccountIdentifier),\n 'ledger_canister_id' : IDL.Opt(IDL.Principal),\n });\n return [IDL.Opt(CyclesCanisterInitPayload)];\n};\n", "import type { NotifyError } from \"../candid/cmc\";\n\nexport class RefundedError extends Error {}\nexport class InvalidaTransactionError extends Error {}\nexport class CMCError extends Error {}\nexport class ProcessingError extends Error {}\nexport class TransactionTooOldError extends Error {}\n\n// Throws one of the errors above\nexport const throwNotifyError = ({\n Err: error,\n}: {\n Err: NotifyError;\n}): void => {\n if (\"Refunded\" in error) {\n throw new RefundedError(error.Refunded.reason);\n }\n if (\"InvalidTransaction\" in error) {\n throw new InvalidaTransactionError(error.InvalidTransaction);\n }\n if (\"Processing\" in error) {\n throw new ProcessingError();\n }\n if (\"TransactionTooOld\" in error) {\n throw new TransactionTooOldError();\n }\n if (\"Other\" in error) {\n throw new CMCError(\n `Error in CMC with code ${error.Other.error_code}: ${error.Other.error_message}`,\n );\n }\n // Edge case\n throw new Error(`Unsupported error type ${JSON.stringify(error)}`);\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,aAAAC,EAAA,6BAAAC,EAAA,oBAAAC,EAAA,kBAAAC,EAAA,2BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAT,GCAA,IAAAU,EAAsB,0BCCf,IAAMC,EAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAuBD,EAAI,QAAQ,CACvC,IAAQA,EAAI,UACZ,MAAUA,EAAI,IAChB,CAAC,EACKE,EAAoBF,EAAI,KACxBG,EAA4BH,EAAI,OAAO,CAC3C,uBAA2BA,EAAI,IAAIC,CAAoB,EACvD,0BAA8BD,EAAI,IAAIA,EAAI,SAAS,EACnD,yBAA6BA,EAAI,IAAIA,EAAI,KAAK,EAC9C,uBAA2BA,EAAI,IAAIA,EAAI,SAAS,EAChD,mBAAuBA,EAAI,IAAIE,CAAiB,EAChD,mBAAuBF,EAAI,IAAIA,EAAI,SAAS,CAC9C,CAAC,EACKI,EAAeJ,EAAI,OAAO,CAAE,YAAgBA,EAAI,IAAIA,EAAI,IAAI,CAAE,CAAC,EAC/DK,EAAkBL,EAAI,QAAQ,CAClC,OAAWI,EACX,OAAWJ,EAAI,OAAO,CAAE,OAAWA,EAAI,SAAU,CAAC,CACpD,CAAC,EACK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C,KAAO,6BAA+B,SAA6B,CACjE,GAAM,CAAE,KAAAC,CAAK,EAAI,MAAM,KAAK,QAAQ,4BAA4B,EAGhE,OAAOA,EAAK,qBACd,EAYA,KAAO,qBAAuB,MAC5BC,GACuB,CACvB,IAAMC,EAAW,MAAM,KAAK,QAAQ,uBAAuBD,CAAO,EAIlE,GAHI,QAASC,GACXC,EAAiBD,CAAQ,EAEvB,OAAQA,EACV,OAAOA,EAAS,GAGlB,MAAM,IAAI,MACR,qDAAqD,KAAK,UACxDA,CACF,CAAC,EACH,CACF,EAYA,KAAO,YAAc,MAAOD,GAA6C,CACvE,IAAMC,EAAW,MAAM,KAAK,QAAQ,cAAcD,CAAO,EAIzD,GAHI,QAASC,GACXC,EAAiBD,CAAQ,EAEvB,OAAQA,EACV,OAAOA,EAAS,GAGlB,MAAM,IAAI,MACR,4CAA4C,KAAK,UAAUA,CAAQ,CAAC,EACtE,CACF,EA/EE,KAAK,QAAUH,CACjB,CAEA,OAAc,OAAOK,EAA6B,CAChD,IAAMC,EAAQD,EAAQ,MAChBE,EAAaF,EAAQ,WAErBL,EACJK,EAAQ,iBACR,QAAM,YAAsBG,EAAY,CACtC,MAAAF,EACA,WAAAC,CACF,CAAC,EAEH,OAAO,IAAIR,EAAYC,CAAO,CAChC,CAiEF",
4
+ "sourcesContent": ["export type {\n Cycles,\n NotifyCreateCanisterArg,\n NotifyTopUpArg,\n} from \"../candid/cmc\";\nexport { CMCCanister } from \"./cmc.canister\";\nexport * from \"./cmc.errors\";\n", "import { Actor } from \"@dfinity/agent\";\nimport type { Principal } from \"@dfinity/principal\";\nimport type {\n Cycles,\n NotifyCreateCanisterArg,\n NotifyTopUpArg,\n _SERVICE,\n} from \"../candid/cmc\";\nimport { idlFactory } from \"../candid/cmc.idl\";\nimport { throwNotifyError } from \"./cmc.errors\";\nimport type { CMCCanisterOptions } from \"./cmc.options\";\n\nexport class CMCCanister {\n private constructor(private readonly service: _SERVICE) {\n this.service = service;\n }\n\n public static create(options: CMCCanisterOptions) {\n const agent = options.agent;\n const canisterId = options.canisterId;\n\n const service =\n options.serviceOverride ??\n Actor.createActor<_SERVICE>(idlFactory, {\n agent,\n canisterId,\n });\n\n return new CMCCanister(service);\n }\n\n /**\n * Returns conversion rate of ICP to Cycles\n *\n * @returns Promise<BigInt>\n */\n public getIcpToCyclesConversionRate = async (): Promise<bigint> => {\n const { data } = await this.service.get_icp_xdr_conversion_rate();\n\n // TODO: validate the certificate in the response - https://dfinity.atlassian.net/browse/FOLLOW-223\n return data.xdr_permyriad_per_icp;\n };\n\n /**\n * Notifies Cycles Minting Canister of the creation of a new canister.\n * It returns the new canister principal.\n *\n * @param {Object} request\n * @param {Principal} request.controller\n * @param {BlockIndex} request.block_index\n * @returns Promise<Principal>\n * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError\n */\n public notifyCreateCanister = async (\n request: NotifyCreateCanisterArg,\n ): Promise<Principal> => {\n const response = await this.service.notify_create_canister(request);\n if (\"Err\" in response) {\n throwNotifyError(response);\n }\n if (\"Ok\" in response) {\n return response.Ok;\n }\n // Edge case\n throw new Error(\n `Unsupported response type in notifyCreateCanister ${JSON.stringify(\n response,\n )}`,\n );\n };\n\n /**\n * Notifies Cycles Minting Canister of new cycles being added to canister.\n * It returns the new Cycles of the canister.\n *\n * @param {Object} request\n * @param {Principal} request.canister_id\n * @param {BlockIndex} request.block_index\n * @returns Promise<Cycles>\n * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError\n */\n public notifyTopUp = async (request: NotifyTopUpArg): Promise<Cycles> => {\n const response = await this.service.notify_top_up(request);\n if (\"Err\" in response) {\n throwNotifyError(response);\n }\n if (\"Ok\" in response) {\n return response.Ok;\n }\n // Edge case\n throw new Error(\n `Unsupported response type in notifyTopUp ${JSON.stringify(response)}`,\n );\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/cmc/candid/cmc.did */\nexport const idlFactory = ({ IDL }) => {\n const ExchangeRateCanister = IDL.Variant({\n 'Set' : IDL.Principal,\n 'Unset' : IDL.Null,\n });\n const AccountIdentifier = IDL.Text;\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\n 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),\n 'last_purged_notification' : IDL.Opt(IDL.Nat64),\n 'governance_canister_id' : IDL.Opt(IDL.Principal),\n 'minting_account_id' : IDL.Opt(AccountIdentifier),\n 'ledger_canister_id' : IDL.Opt(IDL.Principal),\n });\n const SubnetFilter = IDL.Record({ 'subnet_type' : IDL.Opt(IDL.Text) });\n const SubnetSelection = IDL.Variant({\n 'Filter' : SubnetFilter,\n 'Subnet' : IDL.Record({ 'subnet' : IDL.Principal }),\n });\n const log_visibility = IDL.Variant({\n 'controllers' : IDL.Null,\n 'public' : IDL.Null,\n });\n const CanisterSettings = IDL.Record({\n 'freezing_threshold' : IDL.Opt(IDL.Nat),\n 'wasm_memory_threshold' : IDL.Opt(IDL.Nat),\n 'controllers' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'reserved_cycles_limit' : IDL.Opt(IDL.Nat),\n 'log_visibility' : IDL.Opt(log_visibility),\n 'wasm_memory_limit' : IDL.Opt(IDL.Nat),\n 'memory_allocation' : IDL.Opt(IDL.Nat),\n 'compute_allocation' : IDL.Opt(IDL.Nat),\n });\n const CreateCanisterArg = IDL.Record({\n 'subnet_selection' : IDL.Opt(SubnetSelection),\n 'settings' : IDL.Opt(CanisterSettings),\n 'subnet_type' : IDL.Opt(IDL.Text),\n });\n const CreateCanisterError = IDL.Variant({\n 'Refunded' : IDL.Record({\n 'create_error' : IDL.Text,\n 'refund_amount' : IDL.Nat,\n }),\n 'RefundFailed' : IDL.Record({\n 'create_error' : IDL.Text,\n 'refund_error' : IDL.Text,\n }),\n });\n const CreateCanisterResult = IDL.Variant({\n 'Ok' : IDL.Principal,\n 'Err' : CreateCanisterError,\n });\n const IcpXdrConversionRate = IDL.Record({\n 'xdr_permyriad_per_icp' : IDL.Nat64,\n 'timestamp_seconds' : IDL.Nat64,\n });\n const IcpXdrConversionRateResponse = IDL.Record({\n 'certificate' : IDL.Vec(IDL.Nat8),\n 'data' : IcpXdrConversionRate,\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n const PrincipalsAuthorizedToCreateCanistersToSubnetsResponse = IDL.Record({\n 'data' : IDL.Vec(IDL.Tuple(IDL.Principal, IDL.Vec(IDL.Principal))),\n });\n const SubnetTypesToSubnetsResponse = IDL.Record({\n 'data' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Principal))),\n });\n const BlockIndex = IDL.Nat64;\n const NotifyCreateCanisterArg = IDL.Record({\n 'controller' : IDL.Principal,\n 'block_index' : BlockIndex,\n 'subnet_selection' : IDL.Opt(SubnetSelection),\n 'settings' : IDL.Opt(CanisterSettings),\n 'subnet_type' : IDL.Opt(IDL.Text),\n });\n const NotifyError = IDL.Variant({\n 'Refunded' : IDL.Record({\n 'block_index' : IDL.Opt(BlockIndex),\n 'reason' : IDL.Text,\n }),\n 'InvalidTransaction' : IDL.Text,\n 'Other' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'Processing' : IDL.Null,\n 'TransactionTooOld' : BlockIndex,\n });\n const NotifyCreateCanisterResult = IDL.Variant({\n 'Ok' : IDL.Principal,\n 'Err' : NotifyError,\n });\n const Memo = IDL.Opt(IDL.Vec(IDL.Nat8));\n const Subaccount = IDL.Opt(IDL.Vec(IDL.Nat8));\n const NotifyMintCyclesArg = IDL.Record({\n 'block_index' : BlockIndex,\n 'deposit_memo' : Memo,\n 'to_subaccount' : Subaccount,\n });\n const NotifyMintCyclesSuccess = IDL.Record({\n 'balance' : IDL.Nat,\n 'block_index' : IDL.Nat,\n 'minted' : IDL.Nat,\n });\n const NotifyMintCyclesResult = IDL.Variant({\n 'Ok' : NotifyMintCyclesSuccess,\n 'Err' : NotifyError,\n });\n const NotifyTopUpArg = IDL.Record({\n 'block_index' : BlockIndex,\n 'canister_id' : IDL.Principal,\n });\n const Cycles = IDL.Nat;\n const NotifyTopUpResult = IDL.Variant({ 'Ok' : Cycles, 'Err' : NotifyError });\n return IDL.Service({\n 'create_canister' : IDL.Func(\n [CreateCanisterArg],\n [CreateCanisterResult],\n [],\n ),\n 'get_build_metadata' : IDL.Func([], [IDL.Text], ['query']),\n 'get_icp_xdr_conversion_rate' : IDL.Func(\n [],\n [IcpXdrConversionRateResponse],\n ['query'],\n ),\n 'get_principals_authorized_to_create_canisters_to_subnets' : IDL.Func(\n [],\n [PrincipalsAuthorizedToCreateCanistersToSubnetsResponse],\n ['query'],\n ),\n 'get_subnet_types_to_subnets' : IDL.Func(\n [],\n [SubnetTypesToSubnetsResponse],\n ['query'],\n ),\n 'notify_create_canister' : IDL.Func(\n [NotifyCreateCanisterArg],\n [NotifyCreateCanisterResult],\n [],\n ),\n 'notify_mint_cycles' : IDL.Func(\n [NotifyMintCyclesArg],\n [NotifyMintCyclesResult],\n [],\n ),\n 'notify_top_up' : IDL.Func([NotifyTopUpArg], [NotifyTopUpResult], []),\n });\n};\nexport const init = ({ IDL }) => {\n const ExchangeRateCanister = IDL.Variant({\n 'Set' : IDL.Principal,\n 'Unset' : IDL.Null,\n });\n const AccountIdentifier = IDL.Text;\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\n 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),\n 'last_purged_notification' : IDL.Opt(IDL.Nat64),\n 'governance_canister_id' : IDL.Opt(IDL.Principal),\n 'minting_account_id' : IDL.Opt(AccountIdentifier),\n 'ledger_canister_id' : IDL.Opt(IDL.Principal),\n });\n return [IDL.Opt(CyclesCanisterInitPayload)];\n};\n", "import type { NotifyError } from \"../candid/cmc\";\n\nexport class RefundedError extends Error {}\nexport class InvalidaTransactionError extends Error {}\nexport class CMCError extends Error {}\nexport class ProcessingError extends Error {}\nexport class TransactionTooOldError extends Error {}\n\n// Throws one of the errors above\nexport const throwNotifyError = ({\n Err: error,\n}: {\n Err: NotifyError;\n}): void => {\n if (\"Refunded\" in error) {\n throw new RefundedError(error.Refunded.reason);\n }\n if (\"InvalidTransaction\" in error) {\n throw new InvalidaTransactionError(error.InvalidTransaction);\n }\n if (\"Processing\" in error) {\n throw new ProcessingError();\n }\n if (\"TransactionTooOld\" in error) {\n throw new TransactionTooOldError();\n }\n if (\"Other\" in error) {\n throw new CMCError(\n `Error in CMC with code ${error.Other.error_code}: ${error.Other.error_message}`,\n );\n }\n // Edge case\n throw new Error(`Unsupported error type ${JSON.stringify(error)}`);\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,aAAAC,EAAA,6BAAAC,EAAA,oBAAAC,EAAA,kBAAAC,EAAA,2BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAT,GCAA,IAAAU,EAAsB,0BCCf,IAAMC,EAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAuBD,EAAI,QAAQ,CACvC,IAAQA,EAAI,UACZ,MAAUA,EAAI,IAChB,CAAC,EACKE,EAAoBF,EAAI,KACxBG,EAA4BH,EAAI,OAAO,CAC3C,uBAA2BA,EAAI,IAAIC,CAAoB,EACvD,0BAA8BD,EAAI,IAAIA,EAAI,SAAS,EACnD,yBAA6BA,EAAI,IAAIA,EAAI,KAAK,EAC9C,uBAA2BA,EAAI,IAAIA,EAAI,SAAS,EAChD,mBAAuBA,EAAI,IAAIE,CAAiB,EAChD,mBAAuBF,EAAI,IAAIA,EAAI,SAAS,CAC9C,CAAC,EACKI,EAAeJ,EAAI,OAAO,CAAE,YAAgBA,EAAI,IAAIA,EAAI,IAAI,CAAE,CAAC,EAC/DK,EAAkBL,EAAI,QAAQ,CAClC,OAAWI,EACX,OAAWJ,EAAI,OAAO,CAAE,OAAWA,EAAI,SAAU,CAAC,CACpD,CAAC,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EAuBrC,KAAO,6BAA+B,SAA6B,CACjE,GAAM,CAAE,KAAAC,CAAK,EAAI,MAAM,KAAK,QAAQ,4BAA4B,EAGhE,OAAOA,EAAK,qBACd,EAYA,KAAO,qBAAuB,MAC5BC,GACuB,CACvB,IAAMC,EAAW,MAAM,KAAK,QAAQ,uBAAuBD,CAAO,EAIlE,GAHI,QAASC,GACXC,EAAiBD,CAAQ,EAEvB,OAAQA,EACV,OAAOA,EAAS,GAGlB,MAAM,IAAI,MACR,qDAAqD,KAAK,UACxDA,CACF,CAAC,EACH,CACF,EAYA,KAAO,YAAc,MAAOD,GAA6C,CACvE,IAAMC,EAAW,MAAM,KAAK,QAAQ,cAAcD,CAAO,EAIzD,GAHI,QAASC,GACXC,EAAiBD,CAAQ,EAEvB,OAAQA,EACV,OAAOA,EAAS,GAGlB,MAAM,IAAI,MACR,4CAA4C,KAAK,UAAUA,CAAQ,CAAC,EACtE,CACF,EA/EE,KAAK,QAAUH,CACjB,CAEA,OAAc,OAAOK,EAA6B,CAChD,IAAMC,EAAQD,EAAQ,MAChBE,EAAaF,EAAQ,WAErBL,EACJK,EAAQ,iBACR,QAAM,YAAsBG,EAAY,CACtC,MAAAF,EACA,WAAAC,CACF,CAAC,EAEH,OAAO,IAAIR,EAAYC,CAAO,CAChC,CAiEF",
6
6
  "names": ["src_exports", "__export", "CMCCanister", "CMCError", "InvalidaTransactionError", "ProcessingError", "RefundedError", "TransactionTooOldError", "throwNotifyError", "__toCommonJS", "import_agent", "idlFactory", "IDL", "ExchangeRateCanister", "AccountIdentifier", "CyclesCanisterInitPayload", "SubnetFilter", "SubnetSelection", "log_visibility", "CanisterSettings", "CreateCanisterArg", "CreateCanisterError", "CreateCanisterResult", "IcpXdrConversionRate", "IcpXdrConversionRateResponse", "PrincipalsAuthorizedToCreateCanistersToSubnetsResponse", "SubnetTypesToSubnetsResponse", "BlockIndex", "NotifyCreateCanisterArg", "NotifyError", "NotifyCreateCanisterResult", "Memo", "Subaccount", "NotifyMintCyclesArg", "NotifyMintCyclesSuccess", "NotifyMintCyclesResult", "NotifyTopUpArg", "Cycles", "NotifyTopUpResult", "RefundedError", "InvalidaTransactionError", "CMCError", "ProcessingError", "TransactionTooOldError", "throwNotifyError", "error", "CMCCanister", "_CMCCanister", "service", "data", "request", "response", "throwNotifyError", "options", "agent", "canisterId", "idlFactory"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{f as o}from"./chunk-XRC5EOJ2.js";import{Actor as S}from"@dfinity/agent";var l=({IDL:t})=>{let r=t.Variant({Set:t.Principal,Unset:t.Null}),e=t.Text,a=t.Record({exchange_rate_canister:t.Opt(r),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(e),ledger_canister_id:t.Opt(t.Principal)}),i=t.Record({subnet_type:t.Opt(t.Text)}),s=t.Variant({Filter:i,Subnet:t.Record({subnet:t.Principal})}),d=t.Variant({controllers:t.Null,public:t.Null}),p=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(d),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),u=t.Record({subnet_selection:t.Opt(s),settings:t.Opt(p),subnet_type:t.Opt(t.Text)}),y=t.Variant({Refunded:t.Record({create_error:t.Text,refund_amount:t.Nat}),RefundFailed:t.Record({create_error:t.Text,refund_error:t.Text})}),f=t.Variant({Ok:t.Principal,Err:y}),O=t.Record({xdr_permyriad_per_icp:t.Nat64,timestamp_seconds:t.Nat64}),C=t.Record({certificate:t.Vec(t.Nat8),data:O,hash_tree:t.Vec(t.Nat8)}),m=t.Record({data:t.Vec(t.Tuple(t.Principal,t.Vec(t.Principal)))}),g=t.Record({data:t.Vec(t.Tuple(t.Text,t.Vec(t.Principal)))}),n=t.Nat64,N=t.Record({controller:t.Principal,block_index:n,subnet_selection:t.Opt(s),settings:t.Opt(p),subnet_type:t.Opt(t.Text)}),c=t.Variant({Refunded:t.Record({block_index:t.Opt(n),reason:t.Text}),InvalidTransaction:t.Text,Other:t.Record({error_message:t.Text,error_code:t.Nat64}),Processing:t.Null,TransactionTooOld:n}),R=t.Variant({Ok:t.Principal,Err:c}),b=t.Opt(t.Vec(t.Nat8)),x=t.Opt(t.Vec(t.Nat8)),T=t.Record({block_index:n,deposit_memo:b,to_subaccount:x}),P=t.Record({balance:t.Nat,block_index:t.Nat,minted:t.Nat}),V=t.Variant({Ok:P,Err:c}),v=t.Record({block_index:n,canister_id:t.Principal}),h=t.Nat,E=t.Variant({Ok:h,Err:c});return t.Service({create_canister:t.Func([u],[f],[]),get_build_metadata:t.Func([],[t.Text],["query"]),get_icp_xdr_conversion_rate:t.Func([],[C],["query"]),get_principals_authorized_to_create_canisters_to_subnets:t.Func([],[m],["query"]),get_subnet_types_to_subnets:t.Func([],[g],["query"]),notify_create_canister:t.Func([N],[R],[]),notify_mint_cycles:t.Func([T],[V],[]),notify_top_up:t.Func([v],[E],[])})};var _=class t{constructor(r){this.service=r;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&&o(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&&o(e),"Ok"in e)return e.Ok;throw new Error(`Unsupported response type in notifyTopUp ${JSON.stringify(e)}`)};this.service=r}static create(r){let e=r.agent,a=r.canisterId,i=r.serviceOverride??S.createActor(l,{agent:e,canisterId:a});return new t(i)}};export{_ as a};
2
+ //# sourceMappingURL=chunk-VL2WH3AX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cmc.canister.ts", "../../candid/cmc.idl.js"],
4
+ "sourcesContent": ["import { Actor } from \"@dfinity/agent\";\nimport type { Principal } from \"@dfinity/principal\";\nimport type {\n Cycles,\n NotifyCreateCanisterArg,\n NotifyTopUpArg,\n _SERVICE,\n} from \"../candid/cmc\";\nimport { idlFactory } from \"../candid/cmc.idl\";\nimport { throwNotifyError } from \"./cmc.errors\";\nimport type { CMCCanisterOptions } from \"./cmc.options\";\n\nexport class CMCCanister {\n private constructor(private readonly service: _SERVICE) {\n this.service = service;\n }\n\n public static create(options: CMCCanisterOptions) {\n const agent = options.agent;\n const canisterId = options.canisterId;\n\n const service =\n options.serviceOverride ??\n Actor.createActor<_SERVICE>(idlFactory, {\n agent,\n canisterId,\n });\n\n return new CMCCanister(service);\n }\n\n /**\n * Returns conversion rate of ICP to Cycles\n *\n * @returns Promise<BigInt>\n */\n public getIcpToCyclesConversionRate = async (): Promise<bigint> => {\n const { data } = await this.service.get_icp_xdr_conversion_rate();\n\n // TODO: validate the certificate in the response - https://dfinity.atlassian.net/browse/FOLLOW-223\n return data.xdr_permyriad_per_icp;\n };\n\n /**\n * Notifies Cycles Minting Canister of the creation of a new canister.\n * It returns the new canister principal.\n *\n * @param {Object} request\n * @param {Principal} request.controller\n * @param {BlockIndex} request.block_index\n * @returns Promise<Principal>\n * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError\n */\n public notifyCreateCanister = async (\n request: NotifyCreateCanisterArg,\n ): Promise<Principal> => {\n const response = await this.service.notify_create_canister(request);\n if (\"Err\" in response) {\n throwNotifyError(response);\n }\n if (\"Ok\" in response) {\n return response.Ok;\n }\n // Edge case\n throw new Error(\n `Unsupported response type in notifyCreateCanister ${JSON.stringify(\n response,\n )}`,\n );\n };\n\n /**\n * Notifies Cycles Minting Canister of new cycles being added to canister.\n * It returns the new Cycles of the canister.\n *\n * @param {Object} request\n * @param {Principal} request.canister_id\n * @param {BlockIndex} request.block_index\n * @returns Promise<Cycles>\n * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError\n */\n public notifyTopUp = async (request: NotifyTopUpArg): Promise<Cycles> => {\n const response = await this.service.notify_top_up(request);\n if (\"Err\" in response) {\n throwNotifyError(response);\n }\n if (\"Ok\" in response) {\n return response.Ok;\n }\n // Edge case\n throw new Error(\n `Unsupported response type in notifyTopUp ${JSON.stringify(response)}`,\n );\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/cmc/candid/cmc.did */\nexport const idlFactory = ({ IDL }) => {\n const ExchangeRateCanister = IDL.Variant({\n 'Set' : IDL.Principal,\n 'Unset' : IDL.Null,\n });\n const AccountIdentifier = IDL.Text;\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\n 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),\n 'last_purged_notification' : IDL.Opt(IDL.Nat64),\n 'governance_canister_id' : IDL.Opt(IDL.Principal),\n 'minting_account_id' : IDL.Opt(AccountIdentifier),\n 'ledger_canister_id' : IDL.Opt(IDL.Principal),\n });\n const SubnetFilter = IDL.Record({ 'subnet_type' : IDL.Opt(IDL.Text) });\n const SubnetSelection = IDL.Variant({\n 'Filter' : SubnetFilter,\n 'Subnet' : IDL.Record({ 'subnet' : IDL.Principal }),\n });\n const log_visibility = IDL.Variant({\n 'controllers' : IDL.Null,\n 'public' : IDL.Null,\n });\n const CanisterSettings = IDL.Record({\n 'freezing_threshold' : IDL.Opt(IDL.Nat),\n 'wasm_memory_threshold' : IDL.Opt(IDL.Nat),\n 'controllers' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'reserved_cycles_limit' : IDL.Opt(IDL.Nat),\n 'log_visibility' : IDL.Opt(log_visibility),\n 'wasm_memory_limit' : IDL.Opt(IDL.Nat),\n 'memory_allocation' : IDL.Opt(IDL.Nat),\n 'compute_allocation' : IDL.Opt(IDL.Nat),\n });\n const CreateCanisterArg = IDL.Record({\n 'subnet_selection' : IDL.Opt(SubnetSelection),\n 'settings' : IDL.Opt(CanisterSettings),\n 'subnet_type' : IDL.Opt(IDL.Text),\n });\n const CreateCanisterError = IDL.Variant({\n 'Refunded' : IDL.Record({\n 'create_error' : IDL.Text,\n 'refund_amount' : IDL.Nat,\n }),\n 'RefundFailed' : IDL.Record({\n 'create_error' : IDL.Text,\n 'refund_error' : IDL.Text,\n }),\n });\n const CreateCanisterResult = IDL.Variant({\n 'Ok' : IDL.Principal,\n 'Err' : CreateCanisterError,\n });\n const IcpXdrConversionRate = IDL.Record({\n 'xdr_permyriad_per_icp' : IDL.Nat64,\n 'timestamp_seconds' : IDL.Nat64,\n });\n const IcpXdrConversionRateResponse = IDL.Record({\n 'certificate' : IDL.Vec(IDL.Nat8),\n 'data' : IcpXdrConversionRate,\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n const PrincipalsAuthorizedToCreateCanistersToSubnetsResponse = IDL.Record({\n 'data' : IDL.Vec(IDL.Tuple(IDL.Principal, IDL.Vec(IDL.Principal))),\n });\n const SubnetTypesToSubnetsResponse = IDL.Record({\n 'data' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Principal))),\n });\n const BlockIndex = IDL.Nat64;\n const NotifyCreateCanisterArg = IDL.Record({\n 'controller' : IDL.Principal,\n 'block_index' : BlockIndex,\n 'subnet_selection' : IDL.Opt(SubnetSelection),\n 'settings' : IDL.Opt(CanisterSettings),\n 'subnet_type' : IDL.Opt(IDL.Text),\n });\n const NotifyError = IDL.Variant({\n 'Refunded' : IDL.Record({\n 'block_index' : IDL.Opt(BlockIndex),\n 'reason' : IDL.Text,\n }),\n 'InvalidTransaction' : IDL.Text,\n 'Other' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'Processing' : IDL.Null,\n 'TransactionTooOld' : BlockIndex,\n });\n const NotifyCreateCanisterResult = IDL.Variant({\n 'Ok' : IDL.Principal,\n 'Err' : NotifyError,\n });\n const Memo = IDL.Opt(IDL.Vec(IDL.Nat8));\n const Subaccount = IDL.Opt(IDL.Vec(IDL.Nat8));\n const NotifyMintCyclesArg = IDL.Record({\n 'block_index' : BlockIndex,\n 'deposit_memo' : Memo,\n 'to_subaccount' : Subaccount,\n });\n const NotifyMintCyclesSuccess = IDL.Record({\n 'balance' : IDL.Nat,\n 'block_index' : IDL.Nat,\n 'minted' : IDL.Nat,\n });\n const NotifyMintCyclesResult = IDL.Variant({\n 'Ok' : NotifyMintCyclesSuccess,\n 'Err' : NotifyError,\n });\n const NotifyTopUpArg = IDL.Record({\n 'block_index' : BlockIndex,\n 'canister_id' : IDL.Principal,\n });\n const Cycles = IDL.Nat;\n const NotifyTopUpResult = IDL.Variant({ 'Ok' : Cycles, 'Err' : NotifyError });\n return IDL.Service({\n 'create_canister' : IDL.Func(\n [CreateCanisterArg],\n [CreateCanisterResult],\n [],\n ),\n 'get_build_metadata' : IDL.Func([], [IDL.Text], ['query']),\n 'get_icp_xdr_conversion_rate' : IDL.Func(\n [],\n [IcpXdrConversionRateResponse],\n ['query'],\n ),\n 'get_principals_authorized_to_create_canisters_to_subnets' : IDL.Func(\n [],\n [PrincipalsAuthorizedToCreateCanistersToSubnetsResponse],\n ['query'],\n ),\n 'get_subnet_types_to_subnets' : IDL.Func(\n [],\n [SubnetTypesToSubnetsResponse],\n ['query'],\n ),\n 'notify_create_canister' : IDL.Func(\n [NotifyCreateCanisterArg],\n [NotifyCreateCanisterResult],\n [],\n ),\n 'notify_mint_cycles' : IDL.Func(\n [NotifyMintCyclesArg],\n [NotifyMintCyclesResult],\n [],\n ),\n 'notify_top_up' : IDL.Func([NotifyTopUpArg], [NotifyTopUpResult], []),\n });\n};\nexport const init = ({ IDL }) => {\n const ExchangeRateCanister = IDL.Variant({\n 'Set' : IDL.Principal,\n 'Unset' : IDL.Null,\n });\n const AccountIdentifier = IDL.Text;\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\n 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),\n 'last_purged_notification' : IDL.Opt(IDL.Nat64),\n 'governance_canister_id' : IDL.Opt(IDL.Principal),\n 'minting_account_id' : IDL.Opt(AccountIdentifier),\n 'ledger_canister_id' : IDL.Opt(IDL.Principal),\n });\n return [IDL.Opt(CyclesCanisterInitPayload)];\n};\n"],
5
+ "mappings": "wCAAA,OAAS,SAAAA,MAAa,iBCCf,IAAMC,EAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAuBD,EAAI,QAAQ,CACvC,IAAQA,EAAI,UACZ,MAAUA,EAAI,IAChB,CAAC,EACKE,EAAoBF,EAAI,KACxBG,EAA4BH,EAAI,OAAO,CAC3C,uBAA2BA,EAAI,IAAIC,CAAoB,EACvD,0BAA8BD,EAAI,IAAIA,EAAI,SAAS,EACnD,yBAA6BA,EAAI,IAAIA,EAAI,KAAK,EAC9C,uBAA2BA,EAAI,IAAIA,EAAI,SAAS,EAChD,mBAAuBA,EAAI,IAAIE,CAAiB,EAChD,mBAAuBF,EAAI,IAAIA,EAAI,SAAS,CAC9C,CAAC,EACKI,EAAeJ,EAAI,OAAO,CAAE,YAAgBA,EAAI,IAAIA,EAAI,IAAI,CAAE,CAAC,EAC/DK,EAAkBL,EAAI,QAAQ,CAClC,OAAWI,EACX,OAAWJ,EAAI,OAAO,CAAE,OAAWA,EAAI,SAAU,CAAC,CACpD,CAAC,EACKM,EAAiBN,EAAI,QAAQ,CACjC,YAAgBA,EAAI,KACpB,OAAWA,EAAI,IACjB,CAAC,EACKO,EAAmBP,EAAI,OAAO,CAClC,mBAAuBA,EAAI,IAAIA,EAAI,GAAG,EACtC,sBAA0BA,EAAI,IAAIA,EAAI,GAAG,EACzC,YAAgBA,EAAI,IAAIA,EAAI,IAAIA,EAAI,SAAS,CAAC,EAC9C,sBAA0BA,EAAI,IAAIA,EAAI,GAAG,EACzC,eAAmBA,EAAI,IAAIM,CAAc,EACzC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ifier", "CyclesCanisterInitPayload", "SubnetFilter", "SubnetSelection", "log_visibility", "CanisterSettings", "CreateCanisterArg", "CreateCanisterError", "CreateCanisterResult", "IcpXdrConversionRate", "IcpXdrConversionRateResponse", "PrincipalsAuthorizedToCreateCanistersToSubnetsResponse", "SubnetTypesToSubnetsResponse", "BlockIndex", "NotifyCreateCanisterArg", "NotifyError", "NotifyCreateCanisterResult", "Memo", "Subaccount", "NotifyMintCyclesArg", "NotifyMintCyclesSuccess", "NotifyMintCyclesResult", "NotifyTopUpArg", "Cycles", "NotifyTopUpResult", "CMCCanister", "_CMCCanister", "service", "data", "request", "response", "throwNotifyError", "options", "agent", "canisterId", "Actor", "idlFactory"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-DUAUNPLR.js";import"./chunk-XRC5EOJ2.js";export{a as CMCCanister};
1
+ import{a}from"./chunk-VL2WH3AX.js";import"./chunk-XRC5EOJ2.js";export{a as CMCCanister};
2
2
  //# sourceMappingURL=cmc.canister.js.map
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as r}from"./chunk-DUAUNPLR.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};
1
+ import{a as r}from"./chunk-VL2WH3AX.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};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/cmc",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "A library for interfacing with the cycle minting canister.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/cjs/index.cjs.js",
@@ -36,9 +36,9 @@
36
36
  ],
37
37
  "homepage": "https://github.com/dfinity/ic-js#readme",
38
38
  "peerDependencies": {
39
- "@dfinity/agent": "^1.4.0",
40
- "@dfinity/candid": "^1.4.0",
41
- "@dfinity/principal": "^1.4.0",
42
- "@dfinity/utils": "^2.4.0"
39
+ "@dfinity/agent": "^2.0.0",
40
+ "@dfinity/candid": "^2.0.0",
41
+ "@dfinity/principal": "^2.0.0",
42
+ "@dfinity/utils": "^2.5.0"
43
43
  }
44
44
  }
@@ -1,2 +0,0 @@
1
- import{f as o}from"./chunk-XRC5EOJ2.js";import{Actor as S}from"@dfinity/agent";var l=({IDL:t})=>{let r=t.Variant({Set:t.Principal,Unset:t.Null}),e=t.Text,a=t.Record({exchange_rate_canister:t.Opt(r),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(e),ledger_canister_id:t.Opt(t.Principal)}),i=t.Record({subnet_type:t.Opt(t.Text)}),s=t.Variant({Filter:i,Subnet:t.Record({subnet:t.Principal})}),d=t.Variant({controllers:t.Null,public:t.Null}),p=t.Record({controller:t.Opt(t.Principal),freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(d),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),u=t.Record({subnet_selection:t.Opt(s),settings:t.Opt(p),subnet_type:t.Opt(t.Text)}),y=t.Variant({Refunded:t.Record({create_error:t.Text,refund_amount:t.Nat}),RefundFailed:t.Record({create_error:t.Text,refund_error:t.Text})}),f=t.Variant({Ok:t.Principal,Err:y}),O=t.Record({xdr_permyriad_per_icp:t.Nat64,timestamp_seconds:t.Nat64}),C=t.Record({certificate:t.Vec(t.Nat8),data:O,hash_tree:t.Vec(t.Nat8)}),g=t.Record({data:t.Vec(t.Tuple(t.Principal,t.Vec(t.Principal)))}),N=t.Record({data:t.Vec(t.Tuple(t.Text,t.Vec(t.Principal)))}),n=t.Nat64,m=t.Record({controller:t.Principal,block_index:n,subnet_selection:t.Opt(s),settings:t.Opt(p),subnet_type:t.Opt(t.Text)}),c=t.Variant({Refunded:t.Record({block_index:t.Opt(n),reason:t.Text}),InvalidTransaction:t.Text,Other:t.Record({error_message:t.Text,error_code:t.Nat64}),Processing:t.Null,TransactionTooOld:n}),R=t.Variant({Ok:t.Principal,Err:c}),b=t.Opt(t.Vec(t.Nat8)),x=t.Opt(t.Vec(t.Nat8)),T=t.Record({block_index:n,deposit_memo:b,to_subaccount:x}),P=t.Record({balance:t.Nat,block_index:t.Nat,minted:t.Nat}),V=t.Variant({Ok:P,Err:c}),v=t.Record({block_index:n,canister_id:t.Principal}),E=t.Nat,h=t.Variant({Ok:E,Err:c});return t.Service({create_canister:t.Func([u],[f],[]),get_build_metadata:t.Func([],[t.Text],["query"]),get_icp_xdr_conversion_rate:t.Func([],[C],["query"]),get_principals_authorized_to_create_canisters_to_subnets:t.Func([],[g],["query"]),get_subnet_types_to_subnets:t.Func([],[N],["query"]),notify_create_canister:t.Func([m],[R],[]),notify_mint_cycles:t.Func([T],[V],[]),notify_top_up:t.Func([v],[h],[])})};var _=class t{constructor(r){this.service=r;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&&o(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&&o(e),"Ok"in e)return e.Ok;throw new Error(`Unsupported response type in notifyTopUp ${JSON.stringify(e)}`)};this.service=r}static create(r){let e=r.agent,a=r.canisterId,i=r.serviceOverride??S.createActor(l,{agent:e,canisterId:a});return new t(i)}};export{_ as a};
2
- //# sourceMappingURL=chunk-DUAUNPLR.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/cmc.canister.ts", "../../candid/cmc.idl.js"],
4
- "sourcesContent": ["import { Actor } from \"@dfinity/agent\";\nimport type { Principal } from \"@dfinity/principal\";\nimport type {\n Cycles,\n NotifyCreateCanisterArg,\n NotifyTopUpArg,\n _SERVICE,\n} from \"../candid/cmc\";\nimport { idlFactory } from \"../candid/cmc.idl\";\nimport { throwNotifyError } from \"./cmc.errors\";\nimport type { CMCCanisterOptions } from \"./cmc.options\";\n\nexport class CMCCanister {\n private constructor(private readonly service: _SERVICE) {\n this.service = service;\n }\n\n public static create(options: CMCCanisterOptions) {\n const agent = options.agent;\n const canisterId = options.canisterId;\n\n const service =\n options.serviceOverride ??\n Actor.createActor<_SERVICE>(idlFactory, {\n agent,\n canisterId,\n });\n\n return new CMCCanister(service);\n }\n\n /**\n * Returns conversion rate of ICP to Cycles\n *\n * @returns Promise<BigInt>\n */\n public getIcpToCyclesConversionRate = async (): Promise<bigint> => {\n const { data } = await this.service.get_icp_xdr_conversion_rate();\n\n // TODO: validate the certificate in the response - https://dfinity.atlassian.net/browse/FOLLOW-223\n return data.xdr_permyriad_per_icp;\n };\n\n /**\n * Notifies Cycles Minting Canister of the creation of a new canister.\n * It returns the new canister principal.\n *\n * @param {Object} request\n * @param {Principal} request.controller\n * @param {BlockIndex} request.block_index\n * @returns Promise<Principal>\n * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError\n */\n public notifyCreateCanister = async (\n request: NotifyCreateCanisterArg,\n ): Promise<Principal> => {\n const response = await this.service.notify_create_canister(request);\n if (\"Err\" in response) {\n throwNotifyError(response);\n }\n if (\"Ok\" in response) {\n return response.Ok;\n }\n // Edge case\n throw new Error(\n `Unsupported response type in notifyCreateCanister ${JSON.stringify(\n response,\n )}`,\n );\n };\n\n /**\n * Notifies Cycles Minting Canister of new cycles being added to canister.\n * It returns the new Cycles of the canister.\n *\n * @param {Object} request\n * @param {Principal} request.canister_id\n * @param {BlockIndex} request.block_index\n * @returns Promise<Cycles>\n * @throws RefundedError, InvalidaTransactionError, ProcessingError, TransactionTooOldError, CMCError\n */\n public notifyTopUp = async (request: NotifyTopUpArg): Promise<Cycles> => {\n const response = await this.service.notify_top_up(request);\n if (\"Err\" in response) {\n throwNotifyError(response);\n }\n if (\"Ok\" in response) {\n return response.Ok;\n }\n // Edge case\n throw new Error(\n `Unsupported response type in notifyTopUp ${JSON.stringify(response)}`,\n );\n };\n}\n", "/* Do not edit. Compiled with ./scripts/compile-idl-js from packages/cmc/candid/cmc.did */\nexport const idlFactory = ({ IDL }) => {\n const ExchangeRateCanister = IDL.Variant({\n 'Set' : IDL.Principal,\n 'Unset' : IDL.Null,\n });\n const AccountIdentifier = IDL.Text;\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\n 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),\n 'last_purged_notification' : IDL.Opt(IDL.Nat64),\n 'governance_canister_id' : IDL.Opt(IDL.Principal),\n 'minting_account_id' : IDL.Opt(AccountIdentifier),\n 'ledger_canister_id' : IDL.Opt(IDL.Principal),\n });\n const SubnetFilter = IDL.Record({ 'subnet_type' : IDL.Opt(IDL.Text) });\n const SubnetSelection = IDL.Variant({\n 'Filter' : SubnetFilter,\n 'Subnet' : IDL.Record({ 'subnet' : IDL.Principal }),\n });\n const log_visibility = IDL.Variant({\n 'controllers' : IDL.Null,\n 'public' : IDL.Null,\n });\n const CanisterSettings = IDL.Record({\n 'controller' : IDL.Opt(IDL.Principal),\n 'freezing_threshold' : IDL.Opt(IDL.Nat),\n 'controllers' : IDL.Opt(IDL.Vec(IDL.Principal)),\n 'reserved_cycles_limit' : IDL.Opt(IDL.Nat),\n 'log_visibility' : IDL.Opt(log_visibility),\n 'wasm_memory_limit' : IDL.Opt(IDL.Nat),\n 'memory_allocation' : IDL.Opt(IDL.Nat),\n 'compute_allocation' : IDL.Opt(IDL.Nat),\n });\n const CreateCanisterArg = IDL.Record({\n 'subnet_selection' : IDL.Opt(SubnetSelection),\n 'settings' : IDL.Opt(CanisterSettings),\n 'subnet_type' : IDL.Opt(IDL.Text),\n });\n const CreateCanisterError = IDL.Variant({\n 'Refunded' : IDL.Record({\n 'create_error' : IDL.Text,\n 'refund_amount' : IDL.Nat,\n }),\n 'RefundFailed' : IDL.Record({\n 'create_error' : IDL.Text,\n 'refund_error' : IDL.Text,\n }),\n });\n const CreateCanisterResult = IDL.Variant({\n 'Ok' : IDL.Principal,\n 'Err' : CreateCanisterError,\n });\n const IcpXdrConversionRate = IDL.Record({\n 'xdr_permyriad_per_icp' : IDL.Nat64,\n 'timestamp_seconds' : IDL.Nat64,\n });\n const IcpXdrConversionRateResponse = IDL.Record({\n 'certificate' : IDL.Vec(IDL.Nat8),\n 'data' : IcpXdrConversionRate,\n 'hash_tree' : IDL.Vec(IDL.Nat8),\n });\n const PrincipalsAuthorizedToCreateCanistersToSubnetsResponse = IDL.Record({\n 'data' : IDL.Vec(IDL.Tuple(IDL.Principal, IDL.Vec(IDL.Principal))),\n });\n const SubnetTypesToSubnetsResponse = IDL.Record({\n 'data' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Principal))),\n });\n const BlockIndex = IDL.Nat64;\n const NotifyCreateCanisterArg = IDL.Record({\n 'controller' : IDL.Principal,\n 'block_index' : BlockIndex,\n 'subnet_selection' : IDL.Opt(SubnetSelection),\n 'settings' : IDL.Opt(CanisterSettings),\n 'subnet_type' : IDL.Opt(IDL.Text),\n });\n const NotifyError = IDL.Variant({\n 'Refunded' : IDL.Record({\n 'block_index' : IDL.Opt(BlockIndex),\n 'reason' : IDL.Text,\n }),\n 'InvalidTransaction' : IDL.Text,\n 'Other' : IDL.Record({\n 'error_message' : IDL.Text,\n 'error_code' : IDL.Nat64,\n }),\n 'Processing' : IDL.Null,\n 'TransactionTooOld' : BlockIndex,\n });\n const NotifyCreateCanisterResult = IDL.Variant({\n 'Ok' : IDL.Principal,\n 'Err' : NotifyError,\n });\n const Memo = IDL.Opt(IDL.Vec(IDL.Nat8));\n const Subaccount = IDL.Opt(IDL.Vec(IDL.Nat8));\n const NotifyMintCyclesArg = IDL.Record({\n 'block_index' : BlockIndex,\n 'deposit_memo' : Memo,\n 'to_subaccount' : Subaccount,\n });\n const NotifyMintCyclesSuccess = IDL.Record({\n 'balance' : IDL.Nat,\n 'block_index' : IDL.Nat,\n 'minted' : IDL.Nat,\n });\n const NotifyMintCyclesResult = IDL.Variant({\n 'Ok' : NotifyMintCyclesSuccess,\n 'Err' : NotifyError,\n });\n const NotifyTopUpArg = IDL.Record({\n 'block_index' : BlockIndex,\n 'canister_id' : IDL.Principal,\n });\n const Cycles = IDL.Nat;\n const NotifyTopUpResult = IDL.Variant({ 'Ok' : Cycles, 'Err' : NotifyError });\n return IDL.Service({\n 'create_canister' : IDL.Func(\n [CreateCanisterArg],\n [CreateCanisterResult],\n [],\n ),\n 'get_build_metadata' : IDL.Func([], [IDL.Text], ['query']),\n 'get_icp_xdr_conversion_rate' : IDL.Func(\n [],\n [IcpXdrConversionRateResponse],\n ['query'],\n ),\n 'get_principals_authorized_to_create_canisters_to_subnets' : IDL.Func(\n [],\n [PrincipalsAuthorizedToCreateCanistersToSubnetsResponse],\n ['query'],\n ),\n 'get_subnet_types_to_subnets' : IDL.Func(\n [],\n [SubnetTypesToSubnetsResponse],\n ['query'],\n ),\n 'notify_create_canister' : IDL.Func(\n [NotifyCreateCanisterArg],\n [NotifyCreateCanisterResult],\n [],\n ),\n 'notify_mint_cycles' : IDL.Func(\n [NotifyMintCyclesArg],\n [NotifyMintCyclesResult],\n [],\n ),\n 'notify_top_up' : IDL.Func([NotifyTopUpArg], [NotifyTopUpResult], []),\n });\n};\nexport const init = ({ IDL }) => {\n const ExchangeRateCanister = IDL.Variant({\n 'Set' : IDL.Principal,\n 'Unset' : IDL.Null,\n });\n const AccountIdentifier = IDL.Text;\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\n 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),\n 'last_purged_notification' : IDL.Opt(IDL.Nat64),\n 'governance_canister_id' : IDL.Opt(IDL.Principal),\n 'minting_account_id' : IDL.Opt(AccountIdentifier),\n 'ledger_canister_id' : IDL.Opt(IDL.Principal),\n });\n return [IDL.Opt(CyclesCanisterInitPayload)];\n};\n"],
5
- "mappings": "wCAAA,OAAS,SAAAA,MAAa,iBCCf,IAAMC,EAAa,CAAC,CAAE,IAAAC,CAAI,IAAM,CACrC,IAAMC,EAAuBD,EAAI,QAAQ,CACvC,IAAQA,EAAI,UACZ,MAAUA,EAAI,IAChB,CAAC,EACKE,EAAoBF,EAAI,KACxBG,EAA4BH,EAAI,OAAO,CAC3C,uBAA2BA,EAAI,IAAIC,CAAoB,EACvD,0BAA8BD,EAAI,IAAIA,EAAI,SAAS,EACnD,yBAA6BA,EAAI,IAAIA,EAAI,KAAK,EAC9C,uBAA2BA,EAAI,IAAIA,EAAI,SAAS,EAChD,mBAAuBA,EAAI,IAAIE,CAAiB,EAChD,mBAAuBF,EAAI,IAAIA,EAAI,SAAS,CAC9C,CAAC,EACKI,EAAeJ,EAAI,OAAO,CAAE,YAAgBA,EAAI,IAAIA,EAAI,IAAI,CAAE,CAAC,EAC/DK,EAAkBL,EAAI,QAAQ,CAClC,OAAWI,EACX,OAAWJ,EAAI,OAAO,CAAE,OAAWA,EAAI,SAAU,CAAC,CACpD,CAAC,EACKM,EAAiBN,EAAI,QAAQ,CACjC,YAAgBA,EAAI,KACpB,OAAWA,EAAI,IACjB,CAAC,EACKO,EAAmBP,EAAI,OAAO,CAClC,WAAeA,EAAI,IAAIA,EAAI,SAAS,EACpC,mBAAuBA,EAAI,IAAIA,EAAI,GAAG,EACtC,YAAgBA,EAAI,IAAIA,EAAI,IAAIA,EAAI,SAAS,CAAC,EAC9C,sBAA0BA,EAAI,IAAIA,EAAI,G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Actor", "idlFactory", "IDL", "ExchangeRateCanister", "AccountIdentifier", "CyclesCanisterInitPayload", "SubnetFilter", "SubnetSelection", "log_visibility", "CanisterSettings", "CreateCanisterArg", "CreateCanisterError", "CreateCanisterResult", "IcpXdrConversionRate", "IcpXdrConversionRateResponse", "PrincipalsAuthorizedToCreateCanistersToSubnetsResponse", "SubnetTypesToSubnetsResponse", "BlockIndex", "NotifyCreateCanisterArg", "NotifyError", "NotifyCreateCanisterResult", "Memo", "Subaccount", "NotifyMintCyclesArg", "NotifyMintCyclesSuccess", "NotifyMintCyclesResult", "NotifyTopUpArg", "Cycles", "NotifyTopUpResult", "CMCCanister", "_CMCCanister", "service", "data", "request", "response", "throwNotifyError", "options", "agent", "canisterId", "Actor", "idlFactory"]
7
- }