@dfinity/utils 0.0.18-next-2023-07-03 → 0.0.18

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.
Files changed (2) hide show
  1. package/README.md +71 -23
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -71,6 +71,8 @@ Parameters:
71
71
 
72
72
  - `amount`: - in string format
73
73
 
74
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L10)
75
+
74
76
  #### :gear: defaultAgent
75
77
 
76
78
  Get a default agent that connects to mainnet with the anonymous identity.
@@ -79,6 +81,8 @@ Get a default agent that connects to mainnet with the anonymous identity.
79
81
  | -------------- | ------------- |
80
82
  | `defaultAgent` | `() => Agent` |
81
83
 
84
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L8)
85
+
82
86
  #### :gear: createAgent
83
87
 
84
88
  Create an agent for a given identity
@@ -93,78 +97,104 @@ Parameters:
93
97
  - `host`: An optional host to connect to
94
98
  - `fetchRootKey`: Fetch root key for certificate validation during local development or on testnet
95
99
 
100
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L20)
101
+
96
102
  #### :gear: createServices
97
103
 
98
104
  | Function | Type |
99
105
  | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
100
106
  | `createServices` | `<T>({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, }, idlFactory, certifiedIdlFactory, }: { options: RequiredCanisterOptions<T>; idlFactory: InterfaceFactory; certifiedIdlFactory: InterfaceFactory; }) => { ...; }` |
101
107
 
108
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/actor.utils.ts#L13)
109
+
102
110
  #### :gear: assertNonNullish
103
111
 
104
112
  | Function | Type |
105
113
  | ------------------ | -------------------------------------------------------------------- |
106
114
  | `assertNonNullish` | `<T>(value: T, message?: string) => asserts value is NonNullable<T>` |
107
115
 
116
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L7)
117
+
108
118
  #### :gear: assertPercentageNumber
109
119
 
110
120
  | Function | Type |
111
121
  | ------------------------ | ------------------------------ |
112
122
  | `assertPercentageNumber` | `(percentage: number) => void` |
113
123
 
124
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L15)
125
+
114
126
  #### :gear: uint8ArrayToBigInt
115
127
 
116
128
  | Function | Type |
117
129
  | -------------------- | ------------------------------- |
118
130
  | `uint8ArrayToBigInt` | `(array: Uint8Array) => bigint` |
119
131
 
132
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L3)
133
+
120
134
  #### :gear: bigIntToUint8Array
121
135
 
122
136
  | Function | Type |
123
137
  | -------------------- | ------------------------------- |
124
138
  | `bigIntToUint8Array` | `(value: bigint) => Uint8Array` |
125
139
 
140
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L15)
141
+
126
142
  #### :gear: numberToUint8Array
127
143
 
128
144
  | Function | Type |
129
145
  | -------------------- | ------------------------------- |
130
146
  | `numberToUint8Array` | `(value: number) => Uint8Array` |
131
147
 
148
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L31)
149
+
132
150
  #### :gear: arrayBufferToUint8Array
133
151
 
134
152
  | Function | Type |
135
153
  | ------------------------- | ------------------------------------- |
136
154
  | `arrayBufferToUint8Array` | `(buffer: ArrayBuffer) => Uint8Array` |
137
155
 
156
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L40)
157
+
138
158
  #### :gear: uint8ArrayToArrayOfNumber
139
159
 
140
160
  | Function | Type |
141
161
  | --------------------------- | --------------------------------- |
142
162
  | `uint8ArrayToArrayOfNumber` | `(array: Uint8Array) => number[]` |
143
163
 
164
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L43)
165
+
144
166
  #### :gear: arrayOfNumberToUint8Array
145
167
 
146
168
  | Function | Type |
147
169
  | --------------------------- | ----------------------------------- |
148
170
  | `arrayOfNumberToUint8Array` | `(numbers: number[]) => Uint8Array` |
149
171
 
172
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L46)
173
+
150
174
  #### :gear: asciiStringToByteArray
151
175
 
152
176
  | Function | Type |
153
177
  | ------------------------ | ---------------------------- |
154
178
  | `asciiStringToByteArray` | `(text: string) => number[]` |
155
179
 
180
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L49)
181
+
156
182
  #### :gear: hexStringToUint8Array
157
183
 
158
184
  | Function | Type |
159
185
  | ----------------------- | ----------------------------------- |
160
186
  | `hexStringToUint8Array` | `(hexString: string) => Uint8Array` |
161
187
 
188
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L52)
189
+
162
190
  #### :gear: uint8ArrayToHexString
163
191
 
164
192
  | Function | Type |
165
193
  | ----------------------- | ------------------------------- |
166
194
  | `uint8ArrayToHexString` | `(bytes: Uint8Array) => string` |
167
195
 
196
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/arrays.utils.ts#L60)
197
+
168
198
  #### :gear: encodeBase32
169
199
 
170
200
  Encode an Uint8Array to a base32 string.
@@ -177,6 +207,8 @@ Parameters:
177
207
 
178
208
  - `input`: The input array to encode.
179
209
 
210
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/base32.utils.ts#L21)
211
+
180
212
  #### :gear: decodeBase32
181
213
 
182
214
  Decode a base32 string to Uint8Array.
@@ -190,18 +222,24 @@ Parameters:
190
222
  - `input`: The input string to decode.
191
223
  - `input`: The base32 encoded string to decode.
192
224
 
225
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/base32.utils.ts#L67)
226
+
193
227
  #### :gear: bigEndianCrc32
194
228
 
195
229
  | Function | Type |
196
230
  | ---------------- | ----------------------------------- |
197
231
  | `bigEndianCrc32` | `(bytes: Uint8Array) => Uint8Array` |
198
232
 
233
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/crc.utils.ts#L61)
234
+
199
235
  #### :gear: debounce
200
236
 
201
237
  | Function | Type |
202
238
  | ---------- | -------------------------------------------------------------------- |
203
239
  | `debounce` | `(func: Function, timeout?: number) => (...args: unknown[]) => void` |
204
240
 
241
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/debounce.utils.ts#L2)
242
+
205
243
  #### :gear: isNullish
206
244
 
207
245
  Is null or undefined
@@ -210,6 +248,8 @@ Is null or undefined
210
248
  | ----------- | -------------------------------------- |
211
249
  | `isNullish` | `<T>(argument: T) => argument is null` |
212
250
 
251
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L2)
252
+
213
253
  #### :gear: nonNullish
214
254
 
215
255
  Not null and not undefined
@@ -218,6 +258,8 @@ Not null and not undefined
218
258
  | ------------ | ------------------------------------------------ |
219
259
  | `nonNullish` | `<T>(argument: T) => argument is NonNullable<T>` |
220
260
 
261
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L7)
262
+
221
263
  #### :gear: notEmptyString
222
264
 
223
265
  Not null and not undefined and not empty
@@ -226,24 +268,32 @@ Not null and not undefined and not empty
226
268
  | ---------------- | ---------------------------- |
227
269
  | `notEmptyString` | `(value: string) => boolean` |
228
270
 
271
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L12)
272
+
229
273
  #### :gear: toNullable
230
274
 
231
275
  | Function | Type |
232
276
  | ------------ | ----------------------------- |
233
277
  | `toNullable` | `<T>(value?: T) => [] or [T]` |
234
278
 
279
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L4)
280
+
235
281
  #### :gear: fromNullable
236
282
 
237
283
  | Function | Type |
238
284
  | -------------- | ---------------------------- |
239
285
  | `fromNullable` | `<T>(value: [] or [T]) => T` |
240
286
 
287
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L8)
288
+
241
289
  #### :gear: fromDefinedNullable
242
290
 
243
291
  | Function | Type |
244
292
  | --------------------- | ---------------------------- |
245
293
  | `fromDefinedNullable` | `<T>(value: [] or [T]) => T` |
246
294
 
295
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L12)
296
+
247
297
  #### :gear: principalToSubAccount
248
298
 
249
299
  Convert a principal to a Uint8Array 32 length.
@@ -257,6 +307,8 @@ Parameters:
257
307
 
258
308
  - `principal`: The principal that needs to be converted to Subaccount
259
309
 
310
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/principal.utils.ts#L8)
311
+
260
312
  #### :gear: smallerVersion
261
313
 
262
314
  Returns true if the current version is smaller than the minVersion, false if equal or bigger.
@@ -266,6 +318,8 @@ Tags after patch version are ignored, e.g. 1.0.0-beta.1 is considered equal to 1
266
318
  | ---------------- | ----------------------------------------------------------------------------------------------- |
267
319
  | `smallerVersion` | `({ minVersion, currentVersion, }: { minVersion: string; currentVersion: string; }) => boolean` |
268
320
 
321
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/version.utils.ts#L28)
322
+
269
323
  ### :wrench: Constants
270
324
 
271
325
  - [E8S_PER_TOKEN](#gear-e8s_per_token)
@@ -277,16 +331,22 @@ Tags after patch version are ignored, e.g. 1.0.0-beta.1 is considered equal to 1
277
331
  | --------------- | -------- |
278
332
  | `E8S_PER_TOKEN` | `bigint` |
279
333
 
334
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/constants/constants.ts#L1)
335
+
280
336
  #### :gear: ICPToken
281
337
 
282
338
  | Constant | Type |
283
339
  | ---------- | ------- |
284
340
  | `ICPToken` | `Token` |
285
341
 
342
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L62)
343
+
286
344
  ### :factory: TokenAmount
287
345
 
288
346
  Represents an amount of tokens.
289
347
 
348
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L73)
349
+
290
350
  #### Methods
291
351
 
292
352
  - [fromE8s](#gear-frome8s)
@@ -307,6 +367,8 @@ Parameters:
307
367
  - `params.amount`: The amount in bigint format.
308
368
  - `params.token`: The token type.
309
369
 
370
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L83)
371
+
310
372
  ##### :gear: fromString
311
373
 
312
374
  Initialize from a string. Accepted formats:
@@ -324,6 +386,8 @@ Parameters:
324
386
  - `params.amount`: The amount in string format.
325
387
  - `params.token`: The token type.
326
388
 
389
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L104)
390
+
327
391
  ##### :gear: fromNumber
328
392
 
329
393
  Initialize from a number.
@@ -339,42 +403,26 @@ Parameters:
339
403
  - `params.amount`: The amount in number format.
340
404
  - `params.token`: The token type.
341
405
 
406
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L128)
407
+
342
408
  ##### :gear: toE8s
343
409
 
344
410
  | Method | Type |
345
411
  | ------- | -------------- |
346
412
  | `toE8s` | `() => bigint` |
347
413
 
348
- ### :factory: Canister
349
-
350
- #### Constructors
414
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L154)
351
415
 
352
- `public`
353
-
354
- Parameters:
416
+ ### :factory: Canister
355
417
 
356
- - `id`
357
- - `service`
358
- - `certifiedService`
418
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/services/canister.ts#L4)
359
419
 
360
420
  ### :factory: InvalidPercentageError
361
421
 
362
- #### Constructors
363
-
364
- `public`
365
-
366
- Parameters:
367
-
368
- - `message`
422
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L1)
369
423
 
370
424
  ### :factory: NullishError
371
425
 
372
- #### Constructors
373
-
374
- `public`
375
-
376
- Parameters:
377
-
378
- - `message`
426
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L2)
379
427
 
380
428
  <!-- TSDOC_END -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/utils",
3
- "version": "0.0.18-next-2023-07-03",
3
+ "version": "0.0.18",
4
4
  "description": "A collection of utilities and constants for NNS/SNS projects.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/cjs/index.cjs.js",
@@ -47,8 +47,8 @@
47
47
  "service-nervous-system"
48
48
  ],
49
49
  "peerDependencies": {
50
- "@dfinity/agent": "*",
51
- "@dfinity/candid": "*",
52
- "@dfinity/principal": "*"
50
+ "@dfinity/agent": "^0.15.4",
51
+ "@dfinity/candid": "^0.15.4",
52
+ "@dfinity/principal": "^0.15.4"
53
53
  }
54
- }
54
+ }