@dfinity/cmc 2.1.0 → 3.0.0-next-2024-01-30

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.
@@ -4,14 +4,52 @@ export const idlFactory = ({ IDL }) => {
4
4
  'Set' : IDL.Principal,
5
5
  'Unset' : IDL.Null,
6
6
  });
7
- const AccountIdentifier = IDL.Record({ 'bytes' : IDL.Vec(IDL.Nat8) });
7
+ const AccountIdentifier = IDL.Text;
8
8
  const CyclesCanisterInitPayload = IDL.Record({
9
9
  'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),
10
+ 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),
10
11
  'last_purged_notification' : IDL.Opt(IDL.Nat64),
11
12
  'governance_canister_id' : IDL.Opt(IDL.Principal),
12
13
  'minting_account_id' : IDL.Opt(AccountIdentifier),
13
14
  'ledger_canister_id' : IDL.Opt(IDL.Principal),
14
15
  });
16
+ const SubnetFilter = IDL.Record({ 'subnet_type' : IDL.Opt(IDL.Text) });
17
+ const SubnetSelection = IDL.Variant({
18
+ 'Filter' : SubnetFilter,
19
+ 'Subnet' : IDL.Record({ 'subnet' : IDL.Principal }),
20
+ });
21
+ const log_visibility = IDL.Variant({
22
+ 'controllers' : IDL.Null,
23
+ 'public' : IDL.Null,
24
+ });
25
+ const CanisterSettings = IDL.Record({
26
+ 'controller' : IDL.Opt(IDL.Principal),
27
+ 'freezing_threshold' : IDL.Opt(IDL.Nat),
28
+ 'controllers' : IDL.Opt(IDL.Vec(IDL.Principal)),
29
+ 'reserved_cycles_limit' : IDL.Opt(IDL.Nat),
30
+ 'log_visibility' : IDL.Opt(log_visibility),
31
+ 'memory_allocation' : IDL.Opt(IDL.Nat),
32
+ 'compute_allocation' : IDL.Opt(IDL.Nat),
33
+ });
34
+ const CreateCanisterArg = IDL.Record({
35
+ 'subnet_selection' : IDL.Opt(SubnetSelection),
36
+ 'settings' : IDL.Opt(CanisterSettings),
37
+ 'subnet_type' : IDL.Opt(IDL.Text),
38
+ });
39
+ const CreateCanisterError = IDL.Variant({
40
+ 'Refunded' : IDL.Record({
41
+ 'create_error' : IDL.Text,
42
+ 'refund_amount' : IDL.Nat,
43
+ }),
44
+ 'RefundFailed' : IDL.Record({
45
+ 'create_error' : IDL.Text,
46
+ 'refund_error' : IDL.Text,
47
+ }),
48
+ });
49
+ const CreateCanisterResult = IDL.Variant({
50
+ 'Ok' : IDL.Principal,
51
+ 'Err' : CreateCanisterError,
52
+ });
15
53
  const IcpXdrConversionRate = IDL.Record({
16
54
  'xdr_permyriad_per_icp' : IDL.Nat64,
17
55
  'timestamp_seconds' : IDL.Nat64,
@@ -31,6 +69,8 @@ export const idlFactory = ({ IDL }) => {
31
69
  const NotifyCreateCanisterArg = IDL.Record({
32
70
  'controller' : IDL.Principal,
33
71
  'block_index' : BlockIndex,
72
+ 'subnet_selection' : IDL.Opt(SubnetSelection),
73
+ 'settings' : IDL.Opt(CanisterSettings),
34
74
  'subnet_type' : IDL.Opt(IDL.Text),
35
75
  });
36
76
  const NotifyError = IDL.Variant({
@@ -50,6 +90,22 @@ export const idlFactory = ({ IDL }) => {
50
90
  'Ok' : IDL.Principal,
51
91
  'Err' : NotifyError,
52
92
  });
93
+ const Memo = IDL.Opt(IDL.Vec(IDL.Nat8));
94
+ const Subaccount = IDL.Opt(IDL.Vec(IDL.Nat8));
95
+ const NotifyMintCyclesArg = IDL.Record({
96
+ 'block_index' : BlockIndex,
97
+ 'deposit_memo' : Memo,
98
+ 'to_subaccount' : Subaccount,
99
+ });
100
+ const NotifyMintCyclesSuccess = IDL.Record({
101
+ 'balance' : IDL.Nat,
102
+ 'block_index' : IDL.Nat,
103
+ 'minted' : IDL.Nat,
104
+ });
105
+ const NotifyMintCyclesResult = IDL.Variant({
106
+ 'Ok' : NotifyMintCyclesSuccess,
107
+ 'Err' : NotifyError,
108
+ });
53
109
  const NotifyTopUpArg = IDL.Record({
54
110
  'block_index' : BlockIndex,
55
111
  'canister_id' : IDL.Principal,
@@ -57,6 +113,12 @@ export const idlFactory = ({ IDL }) => {
57
113
  const Cycles = IDL.Nat;
58
114
  const NotifyTopUpResult = IDL.Variant({ 'Ok' : Cycles, 'Err' : NotifyError });
59
115
  return IDL.Service({
116
+ 'create_canister' : IDL.Func(
117
+ [CreateCanisterArg],
118
+ [CreateCanisterResult],
119
+ [],
120
+ ),
121
+ 'get_build_metadata' : IDL.Func([], [IDL.Text], []),
60
122
  'get_icp_xdr_conversion_rate' : IDL.Func(
61
123
  [],
62
124
  [IcpXdrConversionRateResponse],
@@ -77,6 +139,11 @@ export const idlFactory = ({ IDL }) => {
77
139
  [NotifyCreateCanisterResult],
78
140
  [],
79
141
  ),
142
+ 'notify_mint_cycles' : IDL.Func(
143
+ [NotifyMintCyclesArg],
144
+ [NotifyMintCyclesResult],
145
+ [],
146
+ ),
80
147
  'notify_top_up' : IDL.Func([NotifyTopUpArg], [NotifyTopUpResult], []),
81
148
  });
82
149
  };
@@ -85,9 +152,10 @@ export const init = ({ IDL }) => {
85
152
  'Set' : IDL.Principal,
86
153
  'Unset' : IDL.Null,
87
154
  });
88
- const AccountIdentifier = IDL.Record({ 'bytes' : IDL.Vec(IDL.Nat8) });
155
+ const AccountIdentifier = IDL.Text;
89
156
  const CyclesCanisterInitPayload = IDL.Record({
90
157
  'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),
158
+ 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),
91
159
  'last_purged_notification' : IDL.Opt(IDL.Nat64),
92
160
  'governance_canister_id' : IDL.Opt(IDL.Principal),
93
161
  'minting_account_id' : IDL.Opt(AccountIdentifier),
@@ -1,13 +1,34 @@
1
1
  import type { ActorMethod } from "@dfinity/agent";
2
2
  import type { Principal } from "@dfinity/principal";
3
3
 
4
- export interface AccountIdentifier {
5
- bytes: Uint8Array | number[];
6
- }
4
+ export type AccountIdentifier = string;
7
5
  export type BlockIndex = bigint;
6
+ export interface CanisterSettings {
7
+ controller: [] | [Principal];
8
+ freezing_threshold: [] | [bigint];
9
+ controllers: [] | [Array<Principal>];
10
+ reserved_cycles_limit: [] | [bigint];
11
+ log_visibility: [] | [log_visibility];
12
+ memory_allocation: [] | [bigint];
13
+ compute_allocation: [] | [bigint];
14
+ }
15
+ export interface CreateCanisterArg {
16
+ subnet_selection: [] | [SubnetSelection];
17
+ settings: [] | [CanisterSettings];
18
+ subnet_type: [] | [string];
19
+ }
20
+ export type CreateCanisterError =
21
+ | {
22
+ Refunded: { create_error: string; refund_amount: bigint };
23
+ }
24
+ | { RefundFailed: { create_error: string; refund_error: string } };
25
+ export type CreateCanisterResult =
26
+ | { Ok: Principal }
27
+ | { Err: CreateCanisterError };
8
28
  export type Cycles = bigint;
9
29
  export interface CyclesCanisterInitPayload {
10
30
  exchange_rate_canister: [] | [ExchangeRateCanister];
31
+ cycles_ledger_canister_id: [] | [Principal];
11
32
  last_purged_notification: [] | [bigint];
12
33
  governance_canister_id: [] | [Principal];
13
34
  minting_account_id: [] | [AccountIdentifier];
@@ -23,9 +44,12 @@ export interface IcpXdrConversionRateResponse {
23
44
  data: IcpXdrConversionRate;
24
45
  hash_tree: Uint8Array | number[];
25
46
  }
47
+ export type Memo = [] | [Uint8Array | number[]];
26
48
  export interface NotifyCreateCanisterArg {
27
49
  controller: Principal;
28
50
  block_index: BlockIndex;
51
+ subnet_selection: [] | [SubnetSelection];
52
+ settings: [] | [CanisterSettings];
29
53
  subnet_type: [] | [string];
30
54
  }
31
55
  export type NotifyCreateCanisterResult =
@@ -39,6 +63,19 @@ export type NotifyError =
39
63
  | { Other: { error_message: string; error_code: bigint } }
40
64
  | { Processing: null }
41
65
  | { TransactionTooOld: BlockIndex };
66
+ export interface NotifyMintCyclesArg {
67
+ block_index: BlockIndex;
68
+ deposit_memo: Memo;
69
+ to_subaccount: Subaccount;
70
+ }
71
+ export type NotifyMintCyclesResult =
72
+ | { Ok: NotifyMintCyclesSuccess }
73
+ | { Err: NotifyError };
74
+ export interface NotifyMintCyclesSuccess {
75
+ balance: bigint;
76
+ block_index: bigint;
77
+ minted: bigint;
78
+ }
42
79
  export interface NotifyTopUpArg {
43
80
  block_index: BlockIndex;
44
81
  canister_id: Principal;
@@ -47,10 +84,20 @@ export type NotifyTopUpResult = { Ok: Cycles } | { Err: NotifyError };
47
84
  export interface PrincipalsAuthorizedToCreateCanistersToSubnetsResponse {
48
85
  data: Array<[Principal, Array<Principal>]>;
49
86
  }
87
+ export type Subaccount = [] | [Uint8Array | number[]];
88
+ export interface SubnetFilter {
89
+ subnet_type: [] | [string];
90
+ }
91
+ export type SubnetSelection =
92
+ | { Filter: SubnetFilter }
93
+ | { Subnet: { subnet: Principal } };
50
94
  export interface SubnetTypesToSubnetsResponse {
51
95
  data: Array<[string, Array<Principal>]>;
52
96
  }
97
+ export type log_visibility = { controllers: null } | { public: null };
53
98
  export interface _SERVICE {
99
+ create_canister: ActorMethod<[CreateCanisterArg], CreateCanisterResult>;
100
+ get_build_metadata: ActorMethod<[], string>;
54
101
  get_icp_xdr_conversion_rate: ActorMethod<[], IcpXdrConversionRateResponse>;
55
102
  get_principals_authorized_to_create_canisters_to_subnets: ActorMethod<
56
103
  [],
@@ -61,5 +108,9 @@ export interface _SERVICE {
61
108
  [NotifyCreateCanisterArg],
62
109
  NotifyCreateCanisterResult
63
110
  >;
111
+ notify_mint_cycles: ActorMethod<
112
+ [NotifyMintCyclesArg],
113
+ NotifyMintCyclesResult
114
+ >;
64
115
  notify_top_up: ActorMethod<[NotifyTopUpArg], NotifyTopUpResult>;
65
116
  }
@@ -1,6 +1,21 @@
1
- // Generated from IC repo commit d2331ec4b3c60f408b876427d7238ec15fb16ad5 'rs/nns/cmc/cmc.did' by import-candid
1
+ // Generated from IC repo commit 044cfd5 (2024-01-25 tags: release-2024-01-25_14-09+p2p-con) 'rs/nns/cmc/cmc.did' by import-candid
2
2
  type Cycles = nat;
3
3
  type BlockIndex = nat64;
4
+ type log_visibility = variant {
5
+ controllers;
6
+ public;
7
+ };
8
+ type CanisterSettings = record {
9
+ controller : opt principal;
10
+ controllers : opt vec principal;
11
+ compute_allocation : opt nat;
12
+ memory_allocation : opt nat;
13
+ freezing_threshold : opt nat;
14
+ reserved_cycles_limit: opt nat;
15
+ log_visibility : opt log_visibility;
16
+ };
17
+ type Subaccount = opt blob;
18
+ type Memo = opt blob;
4
19
 
5
20
  // The argument of the [notify_top_up] method.
6
21
  type NotifyTopUpArg = record {
@@ -11,6 +26,35 @@ type NotifyTopUpArg = record {
11
26
  canister_id : principal;
12
27
  };
13
28
 
29
+
30
+ type SubnetSelection = variant {
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;
37
+ };
38
+
39
+ type SubnetFilter = record {
40
+ subnet_type: opt text;
41
+ };
42
+
43
+ // The argument of the [create_canister] method.
44
+ type CreateCanisterArg = record {
45
+ // Optional canister settings that, if set, are applied to the newly created canister.
46
+ // If not specified, the caller is the controller of the canister and the other settings are set to default values.
47
+ settings : opt CanisterSettings;
48
+
49
+ // An optional subnet type that, if set, determines what type of subnet
50
+ // the new canister will be created on.
51
+ // Deprecated. Use subnet_selection instead.
52
+ subnet_type: opt text;
53
+
54
+ // Optional instructions to select on which subnet the new canister will be created on.
55
+ subnet_selection: opt SubnetSelection;
56
+ };
57
+
14
58
  // The argument of the [notify_create_canister] method.
15
59
  type NotifyCreateCanisterArg = record {
16
60
  // Index of the block on the ICP ledger that contains the payment.
@@ -21,7 +65,35 @@ type NotifyCreateCanisterArg = record {
21
65
 
22
66
  // An optional subnet type that, if set, determines what type of subnet
23
67
  // the new canister will be created on.
68
+ // Deprecated. Use subnet_selection instead.
24
69
  subnet_type: opt text;
70
+
71
+ // Optional instructions to select on which subnet the new canister will be created on.
72
+ // vec may contain no more than one element.
73
+ subnet_selection: opt SubnetSelection;
74
+
75
+ // Optional canister settings that, if set, are applied to the newly created canister.
76
+ // If not specified, the caller is the controller of the canister and the other settings are set to default values.
77
+ settings : opt CanisterSettings;
78
+ };
79
+
80
+ // Canister creation failed and the cycles attached to the call were returned to the calling canister.
81
+ // A small fee may be charged.
82
+ type CreateCanisterError = variant {
83
+ Refunded : record {
84
+ // The amount of cycles returned to the calling canister
85
+ refund_amount: nat;
86
+
87
+ // The reason why creating a canister failed.
88
+ create_error: text;
89
+ };
90
+ RefundFailed : record {
91
+ // The reason why creating a canister failed.
92
+ create_error: text;
93
+
94
+ // The reason why refunding cycles failed.
95
+ refund_error: text;
96
+ };
25
97
  };
26
98
 
27
99
  type NotifyError = variant {
@@ -58,6 +130,12 @@ type NotifyTopUpResult = variant {
58
130
  Err : NotifyError;
59
131
  };
60
132
 
133
+ type CreateCanisterResult = variant {
134
+ // The principal of the newly created canister.
135
+ Ok : principal;
136
+ Err : CreateCanisterError;
137
+ };
138
+
61
139
  type NotifyCreateCanisterResult = variant {
62
140
  // The principal of the newly created canister.
63
141
  Ok : principal;
@@ -104,9 +182,7 @@ type PrincipalsAuthorizedToCreateCanistersToSubnetsResponse = record {
104
182
  data: vec record { principal; vec principal };
105
183
  };
106
184
 
107
- type AccountIdentifier = record {
108
- bytes: blob;
109
- };
185
+ type AccountIdentifier = text;
110
186
 
111
187
  type ExchangeRateCanister = variant {
112
188
  /// Enables the exchange rate canister with the given canister ID.
@@ -121,16 +197,43 @@ type CyclesCanisterInitPayload = record {
121
197
  minting_account_id: opt AccountIdentifier;
122
198
  last_purged_notification: opt nat64;
123
199
  exchange_rate_canister: opt ExchangeRateCanister;
200
+ cycles_ledger_canister_id: opt principal;
201
+ };
202
+
203
+ type NotifyMintCyclesArg = record {
204
+ block_index: BlockIndex;
205
+ to_subaccount: Subaccount;
206
+ deposit_memo: Memo;
207
+ };
208
+
209
+ type NotifyMintCyclesResult = variant {
210
+ Ok: NotifyMintCyclesSuccess;
211
+ Err: NotifyError;
212
+ };
213
+
214
+ type NotifyMintCyclesSuccess = record {
215
+ // Cycles ledger block index of deposit
216
+ block_index: nat;
217
+ // Amount of cycles that were minted and deposited to the cycles ledger
218
+ minted: nat;
219
+ // New balance of the cycles ledger account
220
+ balance: nat;
124
221
  };
125
222
 
126
223
  service : (opt CyclesCanisterInitPayload) -> {
127
- // Propmts the cycles minting canister to process a payment by converting ICP
224
+ // Prompts the cycles minting canister to process a payment by converting ICP
128
225
  // into cycles and sending the cycles the specified canister.
129
226
  notify_top_up : (NotifyTopUpArg) -> (NotifyTopUpResult);
130
227
 
228
+ // Creates a canister using the cycles attached to the function call.
229
+ create_canister : (CreateCanisterArg) -> (CreateCanisterResult);
230
+
131
231
  // Prompts the cycles minting canister to process a payment for canister creation.
132
232
  notify_create_canister : (NotifyCreateCanisterArg) -> (NotifyCreateCanisterResult);
133
233
 
234
+ // Mints cycles and deposits them to the cycles ledger
235
+ notify_mint_cycles : (NotifyMintCyclesArg) -> (NotifyMintCyclesResult);
236
+
134
237
  // Returns the ICP/XDR conversion rate.
135
238
  get_icp_xdr_conversion_rate : () -> (IcpXdrConversionRateResponse) query;
136
239
 
@@ -140,4 +243,6 @@ service : (opt CyclesCanisterInitPayload) -> {
140
243
  // Returns the mapping from principals to subnets in which they are authorized
141
244
  // to create canisters.
142
245
  get_principals_authorized_to_create_canisters_to_subnets : () -> (PrincipalsAuthorizedToCreateCanistersToSubnetsResponse) query;
246
+
247
+ get_build_metadata : () -> (text) query;
143
248
  }
@@ -4,14 +4,52 @@ export const idlFactory = ({ IDL }) => {
4
4
  'Set' : IDL.Principal,
5
5
  'Unset' : IDL.Null,
6
6
  });
7
- const AccountIdentifier = IDL.Record({ 'bytes' : IDL.Vec(IDL.Nat8) });
7
+ const AccountIdentifier = IDL.Text;
8
8
  const CyclesCanisterInitPayload = IDL.Record({
9
9
  'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),
10
+ 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),
10
11
  'last_purged_notification' : IDL.Opt(IDL.Nat64),
11
12
  'governance_canister_id' : IDL.Opt(IDL.Principal),
12
13
  'minting_account_id' : IDL.Opt(AccountIdentifier),
13
14
  'ledger_canister_id' : IDL.Opt(IDL.Principal),
14
15
  });
16
+ const SubnetFilter = IDL.Record({ 'subnet_type' : IDL.Opt(IDL.Text) });
17
+ const SubnetSelection = IDL.Variant({
18
+ 'Filter' : SubnetFilter,
19
+ 'Subnet' : IDL.Record({ 'subnet' : IDL.Principal }),
20
+ });
21
+ const log_visibility = IDL.Variant({
22
+ 'controllers' : IDL.Null,
23
+ 'public' : IDL.Null,
24
+ });
25
+ const CanisterSettings = IDL.Record({
26
+ 'controller' : IDL.Opt(IDL.Principal),
27
+ 'freezing_threshold' : IDL.Opt(IDL.Nat),
28
+ 'controllers' : IDL.Opt(IDL.Vec(IDL.Principal)),
29
+ 'reserved_cycles_limit' : IDL.Opt(IDL.Nat),
30
+ 'log_visibility' : IDL.Opt(log_visibility),
31
+ 'memory_allocation' : IDL.Opt(IDL.Nat),
32
+ 'compute_allocation' : IDL.Opt(IDL.Nat),
33
+ });
34
+ const CreateCanisterArg = IDL.Record({
35
+ 'subnet_selection' : IDL.Opt(SubnetSelection),
36
+ 'settings' : IDL.Opt(CanisterSettings),
37
+ 'subnet_type' : IDL.Opt(IDL.Text),
38
+ });
39
+ const CreateCanisterError = IDL.Variant({
40
+ 'Refunded' : IDL.Record({
41
+ 'create_error' : IDL.Text,
42
+ 'refund_amount' : IDL.Nat,
43
+ }),
44
+ 'RefundFailed' : IDL.Record({
45
+ 'create_error' : IDL.Text,
46
+ 'refund_error' : IDL.Text,
47
+ }),
48
+ });
49
+ const CreateCanisterResult = IDL.Variant({
50
+ 'Ok' : IDL.Principal,
51
+ 'Err' : CreateCanisterError,
52
+ });
15
53
  const IcpXdrConversionRate = IDL.Record({
16
54
  'xdr_permyriad_per_icp' : IDL.Nat64,
17
55
  'timestamp_seconds' : IDL.Nat64,
@@ -31,6 +69,8 @@ export const idlFactory = ({ IDL }) => {
31
69
  const NotifyCreateCanisterArg = IDL.Record({
32
70
  'controller' : IDL.Principal,
33
71
  'block_index' : BlockIndex,
72
+ 'subnet_selection' : IDL.Opt(SubnetSelection),
73
+ 'settings' : IDL.Opt(CanisterSettings),
34
74
  'subnet_type' : IDL.Opt(IDL.Text),
35
75
  });
36
76
  const NotifyError = IDL.Variant({
@@ -50,6 +90,22 @@ export const idlFactory = ({ IDL }) => {
50
90
  'Ok' : IDL.Principal,
51
91
  'Err' : NotifyError,
52
92
  });
93
+ const Memo = IDL.Opt(IDL.Vec(IDL.Nat8));
94
+ const Subaccount = IDL.Opt(IDL.Vec(IDL.Nat8));
95
+ const NotifyMintCyclesArg = IDL.Record({
96
+ 'block_index' : BlockIndex,
97
+ 'deposit_memo' : Memo,
98
+ 'to_subaccount' : Subaccount,
99
+ });
100
+ const NotifyMintCyclesSuccess = IDL.Record({
101
+ 'balance' : IDL.Nat,
102
+ 'block_index' : IDL.Nat,
103
+ 'minted' : IDL.Nat,
104
+ });
105
+ const NotifyMintCyclesResult = IDL.Variant({
106
+ 'Ok' : NotifyMintCyclesSuccess,
107
+ 'Err' : NotifyError,
108
+ });
53
109
  const NotifyTopUpArg = IDL.Record({
54
110
  'block_index' : BlockIndex,
55
111
  'canister_id' : IDL.Principal,
@@ -57,6 +113,12 @@ export const idlFactory = ({ IDL }) => {
57
113
  const Cycles = IDL.Nat;
58
114
  const NotifyTopUpResult = IDL.Variant({ 'Ok' : Cycles, 'Err' : NotifyError });
59
115
  return IDL.Service({
116
+ 'create_canister' : IDL.Func(
117
+ [CreateCanisterArg],
118
+ [CreateCanisterResult],
119
+ [],
120
+ ),
121
+ 'get_build_metadata' : IDL.Func([], [IDL.Text], ['query']),
60
122
  'get_icp_xdr_conversion_rate' : IDL.Func(
61
123
  [],
62
124
  [IcpXdrConversionRateResponse],
@@ -77,6 +139,11 @@ export const idlFactory = ({ IDL }) => {
77
139
  [NotifyCreateCanisterResult],
78
140
  [],
79
141
  ),
142
+ 'notify_mint_cycles' : IDL.Func(
143
+ [NotifyMintCyclesArg],
144
+ [NotifyMintCyclesResult],
145
+ [],
146
+ ),
80
147
  'notify_top_up' : IDL.Func([NotifyTopUpArg], [NotifyTopUpResult], []),
81
148
  });
82
149
  };
@@ -85,9 +152,10 @@ export const init = ({ IDL }) => {
85
152
  'Set' : IDL.Principal,
86
153
  'Unset' : IDL.Null,
87
154
  });
88
- const AccountIdentifier = IDL.Record({ 'bytes' : IDL.Vec(IDL.Nat8) });
155
+ const AccountIdentifier = IDL.Text;
89
156
  const CyclesCanisterInitPayload = IDL.Record({
90
157
  'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),
158
+ 'cycles_ledger_canister_id' : IDL.Opt(IDL.Principal),
91
159
  'last_purged_notification' : IDL.Opt(IDL.Nat64),
92
160
  'governance_canister_id' : IDL.Opt(IDL.Principal),
93
161
  'minting_account_id' : IDL.Opt(AccountIdentifier),
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var r in e)y(t,r,{get:e[r],enumerable:!0})},b=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of T(e))!P.call(t,i)&&i!==r&&y(t,i,{get:()=>e[i],enumerable:!(n=E(e,i))||n.enumerable});return t};var V=t=>b(y({},"__esModule",{value:!0}),t);var A={};v(A,{CMCCanister:()=>l,CMCError:()=>a,InvalidaTransactionError:()=>s,ProcessingError:()=>p,RefundedError:()=>c,TransactionTooOldError:()=>d,throwNotifyError:()=>_});module.exports=V(A);var C=require("@dfinity/agent");var u=({IDL:t})=>{let e=t.Variant({Set:t.Principal,Unset:t.Null}),r=t.Record({bytes:t.Vec(t.Nat8)}),n=t.Record({exchange_rate_canister:t.Opt(e),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({xdr_permyriad_per_icp:t.Nat64,timestamp_seconds:t.Nat64}),g=t.Record({certificate:t.Vec(t.Nat8),data:i,hash_tree:t.Vec(t.Nat8)}),x=t.Record({data:t.Vec(t.Tuple(t.Principal,t.Vec(t.Principal)))}),m=t.Record({data:t.Vec(t.Tuple(t.Text,t.Vec(t.Principal)))}),o=t.Nat64,N=t.Record({controller:t.Principal,block_index:o,subnet_type:t.Opt(t.Text)}),f=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}),O=t.Variant({Ok:t.Principal,Err:f}),h=t.Record({block_index:o,canister_id:t.Principal}),R=t.Nat,w=t.Variant({Ok:R,Err:f});return t.Service({get_icp_xdr_conversion_rate:t.Func([],[g],["query"]),get_principals_authorized_to_create_canisters_to_subnets:t.Func([],[x],["query"]),get_subnet_types_to_subnets:t.Func([],[m],["query"]),notify_create_canister:t.Func([N],[O],[]),notify_top_up:t.Func([h],[w],[])})};var c=class extends Error{},s=class extends Error{},a=class extends Error{},p=class extends Error{},d=class extends Error{},_=({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 d:"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 l=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&&_(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&&_(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,n=e.canisterId,i=e.serviceOverride??C.Actor.createActor(u,{agent:r,canisterId:n});return new t(i)}};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 g=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}),C=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),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),x=t.Record({subnet_selection:t.Opt(f),settings:t.Opt(C),subnet_type:t.Opt(t.Text)}),m=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:m}),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(C),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}),v=t.Variant({Ok:t.Principal,Err:u}),w=t.Opt(t.Vec(t.Nat8)),V=t.Opt(t.Vec(t.Nat8)),S=t.Record({block_index:o,deposit_memo:w,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([x],[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],[v],[]),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??g.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.Record({ 'bytes' : IDL.Vec(IDL.Nat8) });\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\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 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_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 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 '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_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.Record({ 'bytes' : IDL.Vec(IDL.Nat8) });\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\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
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AIL,EAAyBK,EAAM,kBAAkB,EAEzD,eAAgBA,EACZ,IAAIH,EAER,sBAAuBG,EACnB,IAAIF,EAER,UAAWE,EACP,IAAIJ,EACR,0BAA0BI,EAAM,MAAM,UAAU,KAAKA,EAAM,MAAM,aAAa,EAChF,EAGI,IAAI,MAAM,0BAA0B,KAAK,UAAUA,CAAK,CAAC,EAAE,CACnE,EFrBO,IAAMC,EAAN,MAAMC,CAAY,CACf,YAA6BC,EAAmB,CAAnB,aAAAA,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
- "names": ["src_exports", "__export", "CMCCanister", "CMCError", "InvalidaTransactionError", "ProcessingError", "RefundedError", "TransactionTooOldError", "throwNotifyError", "__toCommonJS", "import_agent", "idlFactory", "IDL", "ExchangeRateCanister", "AccountIdentifier", "CyclesCanisterInitPayload", "IcpXdrConversionRate", "IcpXdrConversionRateResponse", "PrincipalsAuthorizedToCreateCanistersToSubnetsResponse", "SubnetTypesToSubnetsResponse", "BlockIndex", "NotifyCreateCanisterArg", "NotifyError", "NotifyCreateCanisterResult", "NotifyTopUpArg", "Cycles", "NotifyTopUpResult", "RefundedError", "InvalidaTransactionError", "CMCError", "ProcessingError", "TransactionTooOldError", "throwNotifyError", "error", "CMCCanister", "_CMCCanister", "service", "data", "request", "response", "throwNotifyError", "options", "agent", "canisterId", "idlFactory"]
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 '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,iB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AM,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
+ "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({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),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,R=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}),m=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([R],[m],[]),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-XEME6PKB.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 '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 '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,EAA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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,iBACRG,EAAM,YAAsBC,EAAY,CACtC,MAAAH,EACA,WAAAC,CACF,CAAC,EAEH,OAAO,IAAIR,EAAYC,CAAO,CAChC,CAiEF",
6
+ "names": ["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
+ }
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-CUXVWVIA.js";import"./chunk-XRC5EOJ2.js";export{a as CMCCanister};
1
+ import{a}from"./chunk-XEME6PKB.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-CUXVWVIA.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-XEME6PKB.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": "2.1.0",
3
+ "version": "3.0.0-next-2024-01-30",
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": "^0.20.2",
40
- "@dfinity/candid": "^0.20.2",
41
- "@dfinity/principal": "^0.20.2",
42
- "@dfinity/utils": "^2.0.0"
39
+ "@dfinity/agent": "*",
40
+ "@dfinity/candid": "*",
41
+ "@dfinity/principal": "*",
42
+ "@dfinity/utils": "*"
43
43
  }
44
- }
44
+ }
@@ -1,2 +0,0 @@
1
- import{f as c}from"./chunk-XRC5EOJ2.js";import{Actor as N}from"@dfinity/agent";var s=({IDL:t})=>{let r=t.Variant({Set:t.Principal,Unset:t.Null}),e=t.Record({bytes:t.Vec(t.Nat8)}),o=t.Record({exchange_rate_canister:t.Opt(r),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)}),n=t.Record({xdr_permyriad_per_icp:t.Nat64,timestamp_seconds:t.Nat64}),_=t.Record({certificate:t.Vec(t.Nat8),data:n,hash_tree:t.Vec(t.Nat8)}),d=t.Record({data:t.Vec(t.Tuple(t.Principal,t.Vec(t.Principal)))}),l=t.Record({data:t.Vec(t.Tuple(t.Text,t.Vec(t.Principal)))}),i=t.Nat64,y=t.Record({controller:t.Principal,block_index:i,subnet_type:t.Opt(t.Text)}),a=t.Variant({Refunded:t.Record({block_index:t.Opt(i),reason:t.Text}),InvalidTransaction:t.Text,Other:t.Record({error_message:t.Text,error_code:t.Nat64}),Processing:t.Null,TransactionTooOld:i}),u=t.Variant({Ok:t.Principal,Err:a}),f=t.Record({block_index:i,canister_id:t.Principal}),C=t.Nat,g=t.Variant({Ok:C,Err:a});return t.Service({get_icp_xdr_conversion_rate:t.Func([],[_],["query"]),get_principals_authorized_to_create_canisters_to_subnets:t.Func([],[d],["query"]),get_subnet_types_to_subnets:t.Func([],[l],["query"]),notify_create_canister:t.Func([y],[u],[]),notify_top_up:t.Func([f],[g],[])})};var p=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&&c(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&&c(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,o=r.canisterId,n=r.serviceOverride??N.createActor(s,{agent:e,canisterId:o});return new t(n)}};export{p as a};
2
- //# sourceMappingURL=chunk-CUXVWVIA.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.Record({ 'bytes' : IDL.Vec(IDL.Nat8) });\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\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 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_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 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 '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_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.Record({ 'bytes' : IDL.Vec(IDL.Nat8) });\n const CyclesCanisterInitPayload = IDL.Record({\n 'exchange_rate_canister' : IDL.Opt(ExchangeRateCanister),\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,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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,iBACRG,EAAM,YAAsBC,EAAY,CACtC,MAAAH,EACA,WAAAC,CACF,CAAC,EAEH,OAAO,IAAIR,EAAYC,CAAO,CAChC,CAiEF",
6
- "names": ["Actor", "idlFactory", "IDL", "ExchangeRateCanister", "AccountIdentifier", "CyclesCanisterInitPayload", "IcpXdrConversionRate", "IcpXdrConversionRateResponse", "PrincipalsAuthorizedToCreateCanistersToSubnetsResponse", "SubnetTypesToSubnetsResponse", "BlockIndex", "NotifyCreateCanisterArg", "NotifyError", "NotifyCreateCanisterResult", "NotifyTopUpArg", "Cycles", "NotifyTopUpResult", "CMCCanister", "_CMCCanister", "service", "data", "request", "response", "throwNotifyError", "options", "agent", "canisterId", "Actor", "idlFactory"]
7
- }