@dfinity/utils 4.0.0-next-2025-10-22.4 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -64
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Returns:
|
|
|
91
91
|
|
|
92
92
|
bigint | FromStringToTokenError
|
|
93
93
|
|
|
94
|
-
[:link: Source](https://github.com/dfinity/
|
|
94
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L12)
|
|
95
95
|
|
|
96
96
|
#### :gear: isNullish
|
|
97
97
|
|
|
@@ -109,7 +109,7 @@ Returns:
|
|
|
109
109
|
|
|
110
110
|
`true` if the argument is null or undefined; otherwise, `false`.
|
|
111
111
|
|
|
112
|
-
[:link: Source](https://github.com/dfinity/
|
|
112
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/nullish.utils.ts#L8)
|
|
113
113
|
|
|
114
114
|
#### :gear: nonNullish
|
|
115
115
|
|
|
@@ -127,7 +127,7 @@ Returns:
|
|
|
127
127
|
|
|
128
128
|
`true` if the argument is not null or undefined; otherwise, `false`.
|
|
129
129
|
|
|
130
|
-
[:link: Source](https://github.com/dfinity/
|
|
130
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/nullish.utils.ts#L19)
|
|
131
131
|
|
|
132
132
|
#### :gear: notEmptyString
|
|
133
133
|
|
|
@@ -145,7 +145,7 @@ Returns:
|
|
|
145
145
|
|
|
146
146
|
`true` if the value is not null, not undefined, and not an empty string; otherwise, `false`.
|
|
147
147
|
|
|
148
|
-
[:link: Source](https://github.com/dfinity/
|
|
148
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/nullish.utils.ts#L29)
|
|
149
149
|
|
|
150
150
|
#### :gear: isEmptyString
|
|
151
151
|
|
|
@@ -163,7 +163,7 @@ Returns:
|
|
|
163
163
|
|
|
164
164
|
Type predicate indicating if the value is null, undefined, or an empty string.
|
|
165
165
|
|
|
166
|
-
[:link: Source](https://github.com/dfinity/
|
|
166
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/nullish.utils.ts#L39)
|
|
167
167
|
|
|
168
168
|
#### :gear: queryAndUpdate
|
|
169
169
|
|
|
@@ -205,7 +205,7 @@ Returns:
|
|
|
205
205
|
|
|
206
206
|
A promise that resolves when the request is done.
|
|
207
207
|
|
|
208
|
-
[:link: Source](https://github.com/dfinity/
|
|
208
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/services/query.ts#L36)
|
|
209
209
|
|
|
210
210
|
#### :gear: defaultAgent
|
|
211
211
|
|
|
@@ -219,7 +219,7 @@ Returns:
|
|
|
219
219
|
|
|
220
220
|
The default agent to use
|
|
221
221
|
|
|
222
|
-
[:link: Source](https://github.com/dfinity/
|
|
222
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/agent.utils.ts#L14)
|
|
223
223
|
|
|
224
224
|
#### :gear: createAgent
|
|
225
225
|
|
|
@@ -238,7 +238,7 @@ Parameters:
|
|
|
238
238
|
- `params.verifyQuerySignatures`: Check for signatures in the state tree signed by the node that replies to queries - i.e. certify responses.
|
|
239
239
|
- `params.retryTimes`: Set the number of retries the agent should perform before error.
|
|
240
240
|
|
|
241
|
-
[:link: Source](https://github.com/dfinity/
|
|
241
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/agent.utils.ts#L30)
|
|
242
242
|
|
|
243
243
|
#### :gear: createServices
|
|
244
244
|
|
|
@@ -246,7 +246,7 @@ Parameters:
|
|
|
246
246
|
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
247
247
|
| `createServices` | `<T>({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, callTransform, queryTransform, }, idlFactory, certifiedIdlFactory, }: { options: Required<Pick<CanisterOptions<T>, "canisterId">> and Omit<CanisterOptions<T>, "canisterId"> and Pick<...>; idlFactory: IDL.InterfaceFactory; certifi...` |
|
|
248
248
|
|
|
249
|
-
[:link: Source](https://github.com/dfinity/
|
|
249
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/actor.utils.ts#L17)
|
|
250
250
|
|
|
251
251
|
#### :gear: assertNonNullish
|
|
252
252
|
|
|
@@ -254,7 +254,7 @@ Parameters:
|
|
|
254
254
|
| ------------------ | --------------------------------------------------------------------------------- |
|
|
255
255
|
| `assertNonNullish` | `<T>(value: T, message?: string or undefined) => asserts value is NonNullable<T>` |
|
|
256
256
|
|
|
257
|
-
[:link: Source](https://github.com/dfinity/
|
|
257
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/asserts.utils.ts#L4)
|
|
258
258
|
|
|
259
259
|
#### :gear: asNonNullish
|
|
260
260
|
|
|
@@ -262,7 +262,7 @@ Parameters:
|
|
|
262
262
|
| -------------- | ---------------------------------------------------------------- |
|
|
263
263
|
| `asNonNullish` | `<T>(value: T, message?: string or undefined) => NonNullable<T>` |
|
|
264
264
|
|
|
265
|
-
[:link: Source](https://github.com/dfinity/
|
|
265
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/asserts.utils.ts#L18)
|
|
266
266
|
|
|
267
267
|
#### :gear: assertPercentageNumber
|
|
268
268
|
|
|
@@ -270,7 +270,7 @@ Parameters:
|
|
|
270
270
|
| ------------------------ | ------------------------------ |
|
|
271
271
|
| `assertPercentageNumber` | `(percentage: number) => void` |
|
|
272
272
|
|
|
273
|
-
[:link: Source](https://github.com/dfinity/
|
|
273
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/asserts.utils.ts#L23)
|
|
274
274
|
|
|
275
275
|
#### :gear: assertNever
|
|
276
276
|
|
|
@@ -292,7 +292,7 @@ Parameters:
|
|
|
292
292
|
the TypeScript compiler will flag a type error.
|
|
293
293
|
- `message`: - Optional custom error message to include in the thrown error.
|
|
294
294
|
|
|
295
|
-
[:link: Source](https://github.com/dfinity/
|
|
295
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/asserts.utils.ts#L47)
|
|
296
296
|
|
|
297
297
|
#### :gear: uint8ArrayToBigInt
|
|
298
298
|
|
|
@@ -300,7 +300,7 @@ Parameters:
|
|
|
300
300
|
| -------------------- | ------------------------------------------------ |
|
|
301
301
|
| `uint8ArrayToBigInt` | `(array: Uint8Array<ArrayBufferLike>) => bigint` |
|
|
302
302
|
|
|
303
|
-
[:link: Source](https://github.com/dfinity/
|
|
303
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L3)
|
|
304
304
|
|
|
305
305
|
#### :gear: bigIntToUint8Array
|
|
306
306
|
|
|
@@ -308,7 +308,7 @@ Parameters:
|
|
|
308
308
|
| -------------------- | ------------------------------------------------ |
|
|
309
309
|
| `bigIntToUint8Array` | `(value: bigint) => Uint8Array<ArrayBufferLike>` |
|
|
310
310
|
|
|
311
|
-
[:link: Source](https://github.com/dfinity/
|
|
311
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L14)
|
|
312
312
|
|
|
313
313
|
#### :gear: numberToUint8Array
|
|
314
314
|
|
|
@@ -316,7 +316,7 @@ Parameters:
|
|
|
316
316
|
| -------------------- | ------------------------------------------------ |
|
|
317
317
|
| `numberToUint8Array` | `(value: number) => Uint8Array<ArrayBufferLike>` |
|
|
318
318
|
|
|
319
|
-
[:link: Source](https://github.com/dfinity/
|
|
319
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L30)
|
|
320
320
|
|
|
321
321
|
#### :gear: arrayBufferToUint8Array
|
|
322
322
|
|
|
@@ -324,7 +324,7 @@ Parameters:
|
|
|
324
324
|
| ------------------------- | ------------------------------------------------------ |
|
|
325
325
|
| `arrayBufferToUint8Array` | `(buffer: ArrayBuffer) => Uint8Array<ArrayBufferLike>` |
|
|
326
326
|
|
|
327
|
-
[:link: Source](https://github.com/dfinity/
|
|
327
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L39)
|
|
328
328
|
|
|
329
329
|
#### :gear: uint8ArrayToArrayOfNumber
|
|
330
330
|
|
|
@@ -332,7 +332,7 @@ Parameters:
|
|
|
332
332
|
| --------------------------- | -------------------------------------------------- |
|
|
333
333
|
| `uint8ArrayToArrayOfNumber` | `(array: Uint8Array<ArrayBufferLike>) => number[]` |
|
|
334
334
|
|
|
335
|
-
[:link: Source](https://github.com/dfinity/
|
|
335
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L42)
|
|
336
336
|
|
|
337
337
|
#### :gear: arrayOfNumberToUint8Array
|
|
338
338
|
|
|
@@ -340,7 +340,7 @@ Parameters:
|
|
|
340
340
|
| --------------------------- | ---------------------------------------------------- |
|
|
341
341
|
| `arrayOfNumberToUint8Array` | `(numbers: number[]) => Uint8Array<ArrayBufferLike>` |
|
|
342
342
|
|
|
343
|
-
[:link: Source](https://github.com/dfinity/
|
|
343
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L45)
|
|
344
344
|
|
|
345
345
|
#### :gear: asciiStringToByteArray
|
|
346
346
|
|
|
@@ -348,7 +348,7 @@ Parameters:
|
|
|
348
348
|
| ------------------------ | ---------------------------- |
|
|
349
349
|
| `asciiStringToByteArray` | `(text: string) => number[]` |
|
|
350
350
|
|
|
351
|
-
[:link: Source](https://github.com/dfinity/
|
|
351
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L48)
|
|
352
352
|
|
|
353
353
|
#### :gear: hexStringToUint8Array
|
|
354
354
|
|
|
@@ -356,7 +356,7 @@ Parameters:
|
|
|
356
356
|
| ----------------------- | ---------------------------------------------------- |
|
|
357
357
|
| `hexStringToUint8Array` | `(hexString: string) => Uint8Array<ArrayBufferLike>` |
|
|
358
358
|
|
|
359
|
-
[:link: Source](https://github.com/dfinity/
|
|
359
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L51)
|
|
360
360
|
|
|
361
361
|
#### :gear: uint8ArraysEqual
|
|
362
362
|
|
|
@@ -375,7 +375,7 @@ Returns:
|
|
|
375
375
|
|
|
376
376
|
True if both arrays have the same length and identical contents.
|
|
377
377
|
|
|
378
|
-
[:link: Source](https://github.com/dfinity/
|
|
378
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L67)
|
|
379
379
|
|
|
380
380
|
#### :gear: uint8ArrayToHexString
|
|
381
381
|
|
|
@@ -383,7 +383,7 @@ True if both arrays have the same length and identical contents.
|
|
|
383
383
|
| ----------------------- | ------------------------------------------------------------ |
|
|
384
384
|
| `uint8ArrayToHexString` | `(bytes: Uint8Array<ArrayBufferLike> or number[]) => string` |
|
|
385
385
|
|
|
386
|
-
[:link: Source](https://github.com/dfinity/
|
|
386
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L70)
|
|
387
387
|
|
|
388
388
|
#### :gear: candidNumberArrayToBigInt
|
|
389
389
|
|
|
@@ -391,7 +391,7 @@ True if both arrays have the same length and identical contents.
|
|
|
391
391
|
| --------------------------- | ----------------------------- |
|
|
392
392
|
| `candidNumberArrayToBigInt` | `(array: number[]) => bigint` |
|
|
393
393
|
|
|
394
|
-
[:link: Source](https://github.com/dfinity/
|
|
394
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/arrays.utils.ts#L80)
|
|
395
395
|
|
|
396
396
|
#### :gear: encodeBase32
|
|
397
397
|
|
|
@@ -409,7 +409,7 @@ Returns:
|
|
|
409
409
|
|
|
410
410
|
A Base32 string encoding the input.
|
|
411
411
|
|
|
412
|
-
[:link: Source](https://github.com/dfinity/
|
|
412
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/base32.utils.ts#L21)
|
|
413
413
|
|
|
414
414
|
#### :gear: decodeBase32
|
|
415
415
|
|
|
@@ -424,7 +424,7 @@ Parameters:
|
|
|
424
424
|
- `input`: The input string to decode.
|
|
425
425
|
- `input`: The base32 encoded string to decode.
|
|
426
426
|
|
|
427
|
-
[:link: Source](https://github.com/dfinity/
|
|
427
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/base32.utils.ts#L67)
|
|
428
428
|
|
|
429
429
|
#### :gear: uint8ArrayToBase64
|
|
430
430
|
|
|
@@ -442,7 +442,7 @@ Returns:
|
|
|
442
442
|
|
|
443
443
|
- The base64 encoded string representation of the binary data.
|
|
444
444
|
|
|
445
|
-
[:link: Source](https://github.com/dfinity/
|
|
445
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/base64.utils.ts#L7)
|
|
446
446
|
|
|
447
447
|
#### :gear: base64ToUint8Array
|
|
448
448
|
|
|
@@ -460,7 +460,7 @@ Returns:
|
|
|
460
460
|
|
|
461
461
|
- The Uint8Array representation of the decoded binary data.
|
|
462
462
|
|
|
463
|
-
[:link: Source](https://github.com/dfinity/
|
|
463
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/base64.utils.ts#L16)
|
|
464
464
|
|
|
465
465
|
#### :gear: bigEndianCrc32
|
|
466
466
|
|
|
@@ -468,7 +468,7 @@ Returns:
|
|
|
468
468
|
| ---------------- | --------------------------------------------------------------------- |
|
|
469
469
|
| `bigEndianCrc32` | `(bytes: Uint8Array<ArrayBufferLike>) => Uint8Array<ArrayBufferLike>` |
|
|
470
470
|
|
|
471
|
-
[:link: Source](https://github.com/dfinity/
|
|
471
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/crc.utils.ts#L61)
|
|
472
472
|
|
|
473
473
|
#### :gear: jsonReplacer
|
|
474
474
|
|
|
@@ -494,7 +494,7 @@ Returns:
|
|
|
494
494
|
|
|
495
495
|
The transformed value if it matches a known type, otherwise the original value.
|
|
496
496
|
|
|
497
|
-
[:link: Source](https://github.com/dfinity/
|
|
497
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/json.utils.ts#L22)
|
|
498
498
|
|
|
499
499
|
#### :gear: jsonReviver
|
|
500
500
|
|
|
@@ -521,7 +521,7 @@ Returns:
|
|
|
521
521
|
|
|
522
522
|
The reconstructed value if it matches a known type, otherwise the original value.
|
|
523
523
|
|
|
524
|
-
[:link: Source](https://github.com/dfinity/
|
|
524
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/json.utils.ts#L55)
|
|
525
525
|
|
|
526
526
|
#### :gear: hashObject
|
|
527
527
|
|
|
@@ -542,7 +542,7 @@ Returns:
|
|
|
542
542
|
|
|
543
543
|
A promise that resolves to the hex string of the SHA-256 hash.
|
|
544
544
|
|
|
545
|
-
[:link: Source](https://github.com/dfinity/
|
|
545
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/crypto.utils.ts#L14)
|
|
546
546
|
|
|
547
547
|
#### :gear: hashText
|
|
548
548
|
|
|
@@ -563,7 +563,7 @@ Returns:
|
|
|
563
563
|
|
|
564
564
|
A promise that resolves to the hex string of the SHA-256 hash.
|
|
565
565
|
|
|
566
|
-
[:link: Source](https://github.com/dfinity/
|
|
566
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/crypto.utils.ts#L31)
|
|
567
567
|
|
|
568
568
|
#### :gear: secondsToDuration
|
|
569
569
|
|
|
@@ -583,7 +583,7 @@ Returns:
|
|
|
583
583
|
|
|
584
584
|
The human-readable duration string.
|
|
585
585
|
|
|
586
|
-
[:link: Source](https://github.com/dfinity/
|
|
586
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/date.utils.ts#L43)
|
|
587
587
|
|
|
588
588
|
#### :gear: nowInBigIntNanoSeconds
|
|
589
589
|
|
|
@@ -597,7 +597,7 @@ Returns:
|
|
|
597
597
|
|
|
598
598
|
The current timestamp in nanoseconds.
|
|
599
599
|
|
|
600
|
-
[:link: Source](https://github.com/dfinity/
|
|
600
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/date.utils.ts#L123)
|
|
601
601
|
|
|
602
602
|
#### :gear: toBigIntNanoSeconds
|
|
603
603
|
|
|
@@ -615,7 +615,7 @@ Returns:
|
|
|
615
615
|
|
|
616
616
|
The timestamp in nanoseconds.
|
|
617
617
|
|
|
618
|
-
[:link: Source](https://github.com/dfinity/
|
|
618
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/date.utils.ts#L132)
|
|
619
619
|
|
|
620
620
|
#### :gear: debounce
|
|
621
621
|
|
|
@@ -638,7 +638,7 @@ Returns:
|
|
|
638
638
|
|
|
639
639
|
A debounced version of the original function.
|
|
640
640
|
|
|
641
|
-
[:link: Source](https://github.com/dfinity/
|
|
641
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/debounce.utils.ts#L13)
|
|
642
642
|
|
|
643
643
|
#### :gear: toNullable
|
|
644
644
|
|
|
@@ -656,7 +656,7 @@ Returns:
|
|
|
656
656
|
|
|
657
657
|
A Candid-style variant representation: an empty array for `null` and `undefined` or an array with the value.
|
|
658
658
|
|
|
659
|
-
[:link: Source](https://github.com/dfinity/
|
|
659
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/did.utils.ts#L12)
|
|
660
660
|
|
|
661
661
|
#### :gear: fromNullable
|
|
662
662
|
|
|
@@ -674,7 +674,7 @@ Returns:
|
|
|
674
674
|
|
|
675
675
|
The extracted value, or `undefined` if the array is empty.
|
|
676
676
|
|
|
677
|
-
[:link: Source](https://github.com/dfinity/
|
|
677
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/did.utils.ts#L22)
|
|
678
678
|
|
|
679
679
|
#### :gear: fromDefinedNullable
|
|
680
680
|
|
|
@@ -693,7 +693,7 @@ Returns:
|
|
|
693
693
|
|
|
694
694
|
The extracted value.
|
|
695
695
|
|
|
696
|
-
[:link: Source](https://github.com/dfinity/
|
|
696
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/did.utils.ts#L34)
|
|
697
697
|
|
|
698
698
|
#### :gear: fromNullishNullable
|
|
699
699
|
|
|
@@ -711,7 +711,7 @@ Returns:
|
|
|
711
711
|
|
|
712
712
|
The extracted value, or `undefined` if the input is nullish or the array is empty.
|
|
713
713
|
|
|
714
|
-
[:link: Source](https://github.com/dfinity/
|
|
714
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/did.utils.ts#L49)
|
|
715
715
|
|
|
716
716
|
#### :gear: principalToSubAccount
|
|
717
717
|
|
|
@@ -726,7 +726,7 @@ Parameters:
|
|
|
726
726
|
|
|
727
727
|
- `principal`: The principal that needs to be converted to Subaccount
|
|
728
728
|
|
|
729
|
-
[:link: Source](https://github.com/dfinity/
|
|
729
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/principal.utils.ts#L8)
|
|
730
730
|
|
|
731
731
|
#### :gear: smallerVersion
|
|
732
732
|
|
|
@@ -746,7 +746,7 @@ Returns:
|
|
|
746
746
|
|
|
747
747
|
boolean
|
|
748
748
|
|
|
749
|
-
[:link: Source](https://github.com/dfinity/
|
|
749
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/version.utils.ts#L34)
|
|
750
750
|
|
|
751
751
|
### :wrench: Constants
|
|
752
752
|
|
|
@@ -759,7 +759,7 @@ boolean
|
|
|
759
759
|
| --------------- | -------- |
|
|
760
760
|
| `E8S_PER_TOKEN` | `bigint` |
|
|
761
761
|
|
|
762
|
-
[:link: Source](https://github.com/dfinity/
|
|
762
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/constants/constants.ts#L1)
|
|
763
763
|
|
|
764
764
|
#### :gear: ICPToken
|
|
765
765
|
|
|
@@ -767,7 +767,7 @@ boolean
|
|
|
767
767
|
| ---------- | ------- |
|
|
768
768
|
| `ICPToken` | `Token` |
|
|
769
769
|
|
|
770
|
-
[:link: Source](https://github.com/dfinity/
|
|
770
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L116)
|
|
771
771
|
|
|
772
772
|
### :factory: TokenAmount
|
|
773
773
|
|
|
@@ -775,7 +775,7 @@ Deprecated. Use TokenAmountV2 instead which supports decimals !== 8.
|
|
|
775
775
|
|
|
776
776
|
Represents an amount of tokens.
|
|
777
777
|
|
|
778
|
-
[:link: Source](https://github.com/dfinity/
|
|
778
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L130)
|
|
779
779
|
|
|
780
780
|
#### Static Methods
|
|
781
781
|
|
|
@@ -796,7 +796,7 @@ Parameters:
|
|
|
796
796
|
- `params.amount`: The amount in bigint format.
|
|
797
797
|
- `params.token`: The token type.
|
|
798
798
|
|
|
799
|
-
[:link: Source](https://github.com/dfinity/
|
|
799
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L147)
|
|
800
800
|
|
|
801
801
|
##### :gear: fromString
|
|
802
802
|
|
|
@@ -815,7 +815,7 @@ Parameters:
|
|
|
815
815
|
- `params.amount`: The amount in string format.
|
|
816
816
|
- `params.token`: The token type.
|
|
817
817
|
|
|
818
|
-
[:link: Source](https://github.com/dfinity/
|
|
818
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L168)
|
|
819
819
|
|
|
820
820
|
##### :gear: fromNumber
|
|
821
821
|
|
|
@@ -832,7 +832,7 @@ Parameters:
|
|
|
832
832
|
- `params.amount`: The amount in number format.
|
|
833
833
|
- `params.token`: The token type.
|
|
834
834
|
|
|
835
|
-
[:link: Source](https://github.com/dfinity/
|
|
835
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L198)
|
|
836
836
|
|
|
837
837
|
#### Methods
|
|
838
838
|
|
|
@@ -848,13 +848,13 @@ Returns:
|
|
|
848
848
|
|
|
849
849
|
The amount of e8s.
|
|
850
850
|
|
|
851
|
-
[:link: Source](https://github.com/dfinity/
|
|
851
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L224)
|
|
852
852
|
|
|
853
853
|
### :factory: TokenAmountV2
|
|
854
854
|
|
|
855
855
|
Represents an amount of tokens.
|
|
856
856
|
|
|
857
|
-
[:link: Source](https://github.com/dfinity/
|
|
857
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L236)
|
|
858
858
|
|
|
859
859
|
#### Static Methods
|
|
860
860
|
|
|
@@ -875,7 +875,7 @@ Parameters:
|
|
|
875
875
|
- `params.amount`: The amount in bigint format.
|
|
876
876
|
- `params.token`: The token type.
|
|
877
877
|
|
|
878
|
-
[:link: Source](https://github.com/dfinity/
|
|
878
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L249)
|
|
879
879
|
|
|
880
880
|
##### :gear: fromString
|
|
881
881
|
|
|
@@ -894,7 +894,7 @@ Parameters:
|
|
|
894
894
|
- `params.amount`: The amount in string format.
|
|
895
895
|
- `params.token`: The token type.
|
|
896
896
|
|
|
897
|
-
[:link: Source](https://github.com/dfinity/
|
|
897
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L270)
|
|
898
898
|
|
|
899
899
|
##### :gear: fromNumber
|
|
900
900
|
|
|
@@ -911,7 +911,7 @@ Parameters:
|
|
|
911
911
|
- `params.amount`: The amount in number format.
|
|
912
912
|
- `params.token`: The token type.
|
|
913
913
|
|
|
914
|
-
[:link: Source](https://github.com/dfinity/
|
|
914
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L294)
|
|
915
915
|
|
|
916
916
|
#### Methods
|
|
917
917
|
|
|
@@ -928,7 +928,7 @@ Returns:
|
|
|
928
928
|
|
|
929
929
|
The amount of ulps.
|
|
930
930
|
|
|
931
|
-
[:link: Source](https://github.com/dfinity/
|
|
931
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L324)
|
|
932
932
|
|
|
933
933
|
##### :gear: toE8s
|
|
934
934
|
|
|
@@ -940,11 +940,11 @@ Returns:
|
|
|
940
940
|
|
|
941
941
|
The amount of ulps in e8s precision
|
|
942
942
|
|
|
943
|
-
[:link: Source](https://github.com/dfinity/
|
|
943
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/parser/token.ts#L332)
|
|
944
944
|
|
|
945
945
|
### :factory: Canister
|
|
946
946
|
|
|
947
|
-
[:link: Source](https://github.com/dfinity/
|
|
947
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/services/canister.ts#L4)
|
|
948
948
|
|
|
949
949
|
### :factory: AgentManager
|
|
950
950
|
|
|
@@ -953,7 +953,7 @@ AgentManager class manages HttpAgent instances for different identities.
|
|
|
953
953
|
It caches agents by identity to optimise resource usage and avoid unnecessary agent creation.
|
|
954
954
|
Provides functionality to create new agents, retrieve cached agents, and clear the cache when needed.
|
|
955
955
|
|
|
956
|
-
[:link: Source](https://github.com/dfinity/
|
|
956
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/agent.utils.ts#L56)
|
|
957
957
|
|
|
958
958
|
#### Static Methods
|
|
959
959
|
|
|
@@ -980,7 +980,7 @@ Returns:
|
|
|
980
980
|
|
|
981
981
|
A new instance of `AgentManager`.
|
|
982
982
|
|
|
983
|
-
[:link: Source](https://github.com/dfinity/
|
|
983
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/agent.utils.ts#L72)
|
|
984
984
|
|
|
985
985
|
#### Methods
|
|
986
986
|
|
|
@@ -1006,7 +1006,7 @@ Returns:
|
|
|
1006
1006
|
|
|
1007
1007
|
The HttpAgent associated with the given identity.
|
|
1008
1008
|
|
|
1009
|
-
[:link: Source](https://github.com/dfinity/
|
|
1009
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/agent.utils.ts#L85)
|
|
1010
1010
|
|
|
1011
1011
|
##### :gear: clearAgents
|
|
1012
1012
|
|
|
@@ -1019,15 +1019,15 @@ Useful when identities have changed or if you want to reset all active connectio
|
|
|
1019
1019
|
| ------------- | ------------ |
|
|
1020
1020
|
| `clearAgents` | `() => void` |
|
|
1021
1021
|
|
|
1022
|
-
[:link: Source](https://github.com/dfinity/
|
|
1022
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/agent.utils.ts#L117)
|
|
1023
1023
|
|
|
1024
1024
|
### :factory: InvalidPercentageError
|
|
1025
1025
|
|
|
1026
|
-
[:link: Source](https://github.com/dfinity/
|
|
1026
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/asserts.utils.ts#L1)
|
|
1027
1027
|
|
|
1028
1028
|
### :factory: NullishError
|
|
1029
1029
|
|
|
1030
|
-
[:link: Source](https://github.com/dfinity/
|
|
1030
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/utils/asserts.utils.ts#L2)
|
|
1031
1031
|
|
|
1032
1032
|
### :nut_and_bolt: Enum
|
|
1033
1033
|
|
|
@@ -1041,6 +1041,6 @@ Useful when identities have changed or if you want to reset all active connectio
|
|
|
1041
1041
|
| `InvalidFormat` | `` | |
|
|
1042
1042
|
| `FractionalTooManyDecimals` | `` | |
|
|
1043
1043
|
|
|
1044
|
-
[:link: Source](https://github.com/dfinity/
|
|
1044
|
+
[:link: Source](https://github.com/dfinity/icp-js-canisters/tree/main/packages/utils/src/enums/token.enums.ts#L1)
|
|
1045
1045
|
|
|
1046
1046
|
<!-- TSDOC_END -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfinity/utils",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A collection of utilities and constants for NNS/SNS projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/dfinity/
|
|
36
|
+
"url": "git+https://github.com/dfinity/icp-js-canisters.git",
|
|
37
37
|
"directory": "packages/utils"
|
|
38
38
|
},
|
|
39
39
|
"bugs": {
|
|
40
|
-
"url": "https://github.com/dfinity/
|
|
40
|
+
"url": "https://github.com/dfinity/icp-js-canisters"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"internet computer",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"service-nervous-system"
|
|
61
61
|
],
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@icp-sdk/core": "
|
|
63
|
+
"@icp-sdk/core": "^4"
|
|
64
64
|
}
|
|
65
|
-
}
|
|
65
|
+
}
|