@dfinity/cmc 8.0.0 → 8.0.1
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.
- package/README.md +5 -124
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@ A library for interfacing with the cycle minting canister.
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@dfinity/cmc) [](https://opensource.org/licenses/Apache-2.0)
|
|
6
6
|
|
|
7
|
+
> [!TIP]
|
|
8
|
+
> Still using `@dfinity/cmc`? Upgrade to [`@icp-sdk/canisters/cmc`](https://js.icp.build/canisters/latest/upgrading/v1/)!
|
|
9
|
+
|
|
7
10
|
## Table of contents
|
|
8
11
|
|
|
9
12
|
- [Installation](#installation)
|
|
@@ -47,128 +50,6 @@ const { getIcpToCyclesConversionRate } = CMCCanister.create({
|
|
|
47
50
|
const rate = await getIcpToCyclesConversionRate();
|
|
48
51
|
```
|
|
49
52
|
|
|
50
|
-
##
|
|
51
|
-
|
|
52
|
-
`cmc-js` implements following features:
|
|
53
|
-
|
|
54
|
-
<!-- TSDOC_START -->
|
|
55
|
-
|
|
56
|
-
### :factory: CMCCanister
|
|
57
|
-
|
|
58
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/cmc/src/cmc.canister.ts#L15)
|
|
59
|
-
|
|
60
|
-
#### Static Methods
|
|
61
|
-
|
|
62
|
-
- [create](#gear-create)
|
|
63
|
-
|
|
64
|
-
##### :gear: create
|
|
65
|
-
|
|
66
|
-
| Method | Type |
|
|
67
|
-
| -------- | ---------------------------------------------- |
|
|
68
|
-
| `create` | `(options: CMCCanisterOptions) => CMCCanister` |
|
|
69
|
-
|
|
70
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/cmc/src/cmc.canister.ts#L16)
|
|
71
|
-
|
|
72
|
-
#### Methods
|
|
73
|
-
|
|
74
|
-
- [getIcpToCyclesConversionRate](#gear-geticptocyclesconversionrate)
|
|
75
|
-
- [notifyCreateCanister](#gear-notifycreatecanister)
|
|
76
|
-
- [notifyTopUp](#gear-notifytopup)
|
|
77
|
-
- [getDefaultSubnets](#gear-getdefaultsubnets)
|
|
78
|
-
- [getSubnetTypesToSubnets](#gear-getsubnettypestosubnets)
|
|
79
|
-
|
|
80
|
-
##### :gear: getIcpToCyclesConversionRate
|
|
81
|
-
|
|
82
|
-
Returns conversion rate of ICP to Cycles. It can be called as query or update.
|
|
83
|
-
|
|
84
|
-
| Method | Type |
|
|
85
|
-
| ------------------------------ | --------------------------------------------------- |
|
|
86
|
-
| `getIcpToCyclesConversionRate` | `({ certified, }?: QueryParams) => Promise<bigint>` |
|
|
87
|
-
|
|
88
|
-
Parameters:
|
|
89
|
-
|
|
90
|
-
- `params`: - The parameters for the call.
|
|
91
|
-
- `params.certified`: - Determines whether the response should be certified (default: non-certified)
|
|
92
|
-
|
|
93
|
-
Returns:
|
|
94
|
-
|
|
95
|
-
Promise<BigInt>
|
|
96
|
-
|
|
97
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/cmc/src/cmc.canister.ts#L35)
|
|
98
|
-
|
|
99
|
-
##### :gear: notifyCreateCanister
|
|
100
|
-
|
|
101
|
-
Notifies Cycles Minting Canister of the creation of a new canister.
|
|
102
|
-
It returns the new canister principal.
|
|
103
|
-
|
|
104
|
-
| Method | Type |
|
|
105
|
-
| ---------------------- | ---------------------------------------------------------- |
|
|
106
|
-
| `notifyCreateCanister` | `(request: NotifyCreateCanisterArg) => Promise<Principal>` |
|
|
107
|
-
|
|
108
|
-
Returns:
|
|
109
|
-
|
|
110
|
-
Promise<Principal>
|
|
111
|
-
|
|
112
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/cmc/src/cmc.canister.ts#L57)
|
|
113
|
-
|
|
114
|
-
##### :gear: notifyTopUp
|
|
115
|
-
|
|
116
|
-
Notifies Cycles Minting Canister of new cycles being added to canister.
|
|
117
|
-
It returns the new Cycles of the canister.
|
|
118
|
-
|
|
119
|
-
| Method | Type |
|
|
120
|
-
| ------------- | ---------------------------------------------- |
|
|
121
|
-
| `notifyTopUp` | `(request: NotifyTopUpArg) => Promise<bigint>` |
|
|
122
|
-
|
|
123
|
-
Returns:
|
|
124
|
-
|
|
125
|
-
Promise<Cycles>
|
|
126
|
-
|
|
127
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/cmc/src/cmc.canister.ts#L85)
|
|
128
|
-
|
|
129
|
-
##### :gear: getDefaultSubnets
|
|
130
|
-
|
|
131
|
-
This function calls the `get_default_subnets` method of the CMC canister, which returns a list of
|
|
132
|
-
default subnets as `Principal` objects. It can be called as query or update.
|
|
133
|
-
|
|
134
|
-
| Method | Type |
|
|
135
|
-
| ------------------- | ------------------------------------------------------- |
|
|
136
|
-
| `getDefaultSubnets` | `({ certified }?: QueryParams) => Promise<Principal[]>` |
|
|
137
|
-
|
|
138
|
-
Parameters:
|
|
139
|
-
|
|
140
|
-
- `params`: - The query parameters for the call.
|
|
141
|
-
- `params.certified`: - Determines whether the response should be certified
|
|
142
|
-
(default: non-certified if not specified).
|
|
143
|
-
|
|
144
|
-
Returns:
|
|
145
|
-
|
|
146
|
-
- A promise that resolves to an array of `Principal` objects
|
|
147
|
-
representing the default subnets.
|
|
148
|
-
|
|
149
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/cmc/src/cmc.canister.ts#L110)
|
|
150
|
-
|
|
151
|
-
##### :gear: getSubnetTypesToSubnets
|
|
152
|
-
|
|
153
|
-
This function calls the `get_subnet_types_to_subnets` method of the CMC canister, which returns a list of subnets where canisters can be created.
|
|
154
|
-
These subnets are excluded from the random subnet selection process used by the CMC when no explicit subnet ID is provided
|
|
155
|
-
during canister creation and therefore, not provided in the results of the similar function `get_default_subnets`.
|
|
156
|
-
|
|
157
|
-
| Method | Type |
|
|
158
|
-
| ------------------------- | ------------------------------------------------------------------------- |
|
|
159
|
-
| `getSubnetTypesToSubnets` | `({ certified, }?: QueryParams) => Promise<SubnetTypesToSubnetsResponse>` |
|
|
160
|
-
|
|
161
|
-
Parameters:
|
|
162
|
-
|
|
163
|
-
- `params`: - The optional query parameters for the call.
|
|
164
|
-
- `params.certified`: - Specifies whether the response should be certified.
|
|
165
|
-
If not provided, the response defaults to non-certified.
|
|
166
|
-
|
|
167
|
-
Returns:
|
|
168
|
-
|
|
169
|
-
- A promise that resolves to an object representing
|
|
170
|
-
the mapping of subnet types to subnets.
|
|
171
|
-
|
|
172
|
-
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/cmc/src/cmc.canister.ts#L129)
|
|
53
|
+
## Documentation
|
|
173
54
|
|
|
174
|
-
|
|
55
|
+
You can find the API docs [here](https://js.icp.build/canisters/latest/api/cmc/).
|