@taquito/utils 19.0.2 → 19.1.0-RC.2
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 +6 -6
- package/dist/lib/taquito-utils.js +49 -1
- package/dist/lib/version.js +2 -2
- package/dist/taquito-utils.es6.js +47 -3
- package/dist/taquito-utils.es6.js.map +1 -1
- package/dist/taquito-utils.umd.js +50 -2
- package/dist/taquito-utils.umd.js.map +1 -1
- package/dist/types/taquito-utils.d.ts +25 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -135,15 +135,15 @@ console.log(isValid);
|
|
|
135
135
|
|
|
136
136
|
**Conversion between hexadecimal and ASCII strings**
|
|
137
137
|
```ts
|
|
138
|
-
import {
|
|
138
|
+
import { stringToBytes, bytesToString } from '@taquito/utils';
|
|
139
139
|
|
|
140
140
|
const url = 'https://storage.googleapis.com/tzip-16/fa2-views.json';
|
|
141
141
|
const hex = '68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f747a69702d31362f6661322d76696577732e6a736f6e';
|
|
142
142
|
|
|
143
|
-
console.log(
|
|
143
|
+
console.log(stringToBytes(url));
|
|
144
144
|
// output: 68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f747a69702d31362f6661322d76696577732e6a736f6e
|
|
145
145
|
|
|
146
|
-
console.log(
|
|
146
|
+
console.log(bytesToString(hex));
|
|
147
147
|
// output: https://storage.googleapis.com/tzip-16/fa2-views.json
|
|
148
148
|
```
|
|
149
149
|
|
|
@@ -194,12 +194,12 @@ console.log(encodeKey('0060842d4ba23a9940ef5dcf4404fdaa430cfaaccb5029fad06cb5ea8
|
|
|
194
194
|
|
|
195
195
|
**Base58 encode an address using a predefined prefix**
|
|
196
196
|
```ts
|
|
197
|
-
import {
|
|
197
|
+
import { encodeAddress } from '@taquito/utils';
|
|
198
198
|
|
|
199
|
-
console.log(
|
|
199
|
+
console.log(encodeAddress('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f'));
|
|
200
200
|
// output: tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM
|
|
201
201
|
|
|
202
|
-
console.log(
|
|
202
|
+
console.log(encodeAddress('01f9b689a478253793bd92357c5e08e5ebcd8db47600'));
|
|
203
203
|
// output: KT1XM8VUFBiM9AC5czWU15fEeE9nmuEYWt3Y
|
|
204
204
|
```
|
|
205
205
|
|
|
@@ -18,7 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.stripHexPrefix = exports.num2PaddedHex = exports.toHexBuf = exports.hex2Bytes = exports.bytes2Char = exports.char2Bytes = exports.getPkhfromPk = exports.buf2hex = exports.mic2arr = exports.mergebuf = exports.hex2buf = exports.encodeKeyHash = exports.encodeKey = exports.encodeL2Address = exports.encodePubKey = exports.b58decodeL2Address = exports.b58decode = exports.b58cdecode = exports.b58cencode = exports.encodeOpHash = exports.encodeExpr = exports.format = exports.validatePkAndExtractPrefix = exports.verifySignature = exports.prefixLength = exports.Prefix = exports.prefix = exports.VERSION = void 0;
|
|
21
|
+
exports.stripHexPrefix = exports.num2PaddedHex = exports.numToHexBuffer = exports.toHexBuf = exports.hex2Bytes = exports.bytesToString = exports.bytes2Char = exports.stringToBytes = exports.char2Bytes = exports.getPkhfromPk = exports.buf2hex = exports.mic2arr = exports.mergebuf = exports.hex2buf = exports.encodeKeyHash = exports.encodeKey = exports.encodeL2Address = exports.encodeAddress = exports.encodePubKey = exports.b58decodeL2Address = exports.b58decode = exports.b58cdecode = exports.b58cencode = exports.encodeOpHash = exports.encodeExpr = exports.format = exports.validatePkAndExtractPrefix = exports.verifySignature = exports.prefixLength = exports.Prefix = exports.prefix = exports.VERSION = void 0;
|
|
22
22
|
/*
|
|
23
23
|
* Some code in this file is originally from sotez and eztz
|
|
24
24
|
* Copyright (c) 2018 Andrew Kishino
|
|
@@ -133,6 +133,7 @@ exports.b58decodeL2Address = b58decodeL2Address;
|
|
|
133
133
|
* @description Base58 encode an address using predefined prefix
|
|
134
134
|
*
|
|
135
135
|
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1)
|
|
136
|
+
* @deprecated use encodeAddress instead, same functionality with a more descriptive name
|
|
136
137
|
*/
|
|
137
138
|
function encodePubKey(value) {
|
|
138
139
|
if (value.substring(0, 2) === '00') {
|
|
@@ -146,6 +147,27 @@ function encodePubKey(value) {
|
|
|
146
147
|
return b58cencode(value.substring(2, 42), constants_1.prefix.KT);
|
|
147
148
|
}
|
|
148
149
|
exports.encodePubKey = encodePubKey;
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation)
|
|
153
|
+
*
|
|
154
|
+
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1). Supports value with or without '0x' prefix
|
|
155
|
+
*/
|
|
156
|
+
function encodeAddress(value) {
|
|
157
|
+
if (value.substring(0, 2) === '0x') {
|
|
158
|
+
value = value.slice(2);
|
|
159
|
+
}
|
|
160
|
+
if (value.substring(0, 2) === '00') {
|
|
161
|
+
const pref = {
|
|
162
|
+
'0000': constants_1.prefix.tz1,
|
|
163
|
+
'0001': constants_1.prefix.tz2,
|
|
164
|
+
'0002': constants_1.prefix.tz3,
|
|
165
|
+
};
|
|
166
|
+
return b58cencode(value.substring(4), pref[value.substring(0, 4)]);
|
|
167
|
+
}
|
|
168
|
+
return b58cencode(value.substring(2, 42), constants_1.prefix.KT);
|
|
169
|
+
}
|
|
170
|
+
exports.encodeAddress = encodeAddress;
|
|
149
171
|
/**
|
|
150
172
|
*
|
|
151
173
|
* @description Base58 encode an address without predefined prefix
|
|
@@ -343,21 +365,43 @@ exports.getPkhfromPk = getPkhfromPk;
|
|
|
343
365
|
* @description Convert a string to bytes
|
|
344
366
|
*
|
|
345
367
|
* @param str String to convert
|
|
368
|
+
* @deprecated use stringToBytes instead, same functionality with a more descriptive name
|
|
346
369
|
*/
|
|
347
370
|
function char2Bytes(str) {
|
|
348
371
|
return buffer_1.Buffer.from(str, 'utf8').toString('hex');
|
|
349
372
|
}
|
|
350
373
|
exports.char2Bytes = char2Bytes;
|
|
374
|
+
/**
|
|
375
|
+
*
|
|
376
|
+
* @description Convert a string to a byte string representation
|
|
377
|
+
*
|
|
378
|
+
* @param str String to convert
|
|
379
|
+
*/
|
|
380
|
+
function stringToBytes(str) {
|
|
381
|
+
return buffer_1.Buffer.from(str, 'utf8').toString('hex');
|
|
382
|
+
}
|
|
383
|
+
exports.stringToBytes = stringToBytes;
|
|
351
384
|
/**
|
|
352
385
|
*
|
|
353
386
|
* @description Convert bytes to a string
|
|
354
387
|
*
|
|
355
388
|
* @param str Bytes to convert
|
|
389
|
+
* @deprecated use hexStringToBytes instead, same functionality with a more descriptive name
|
|
356
390
|
*/
|
|
357
391
|
function bytes2Char(hex) {
|
|
358
392
|
return buffer_1.Buffer.from((0, exports.hex2buf)(hex)).toString('utf8');
|
|
359
393
|
}
|
|
360
394
|
exports.bytes2Char = bytes2Char;
|
|
395
|
+
/**
|
|
396
|
+
*
|
|
397
|
+
* @description Convert byte string representation to string
|
|
398
|
+
*
|
|
399
|
+
* @param str byte string to convert
|
|
400
|
+
*/
|
|
401
|
+
function bytesToString(hex) {
|
|
402
|
+
return buffer_1.Buffer.from((0, exports.hex2buf)(hex)).toString('utf8');
|
|
403
|
+
}
|
|
404
|
+
exports.bytesToString = bytesToString;
|
|
361
405
|
/**
|
|
362
406
|
*
|
|
363
407
|
* @description Convert hex string/UintArray/Buffer to bytes
|
|
@@ -382,6 +426,10 @@ function toHexBuf(val, bitLength = 8) {
|
|
|
382
426
|
return buffer_1.Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
383
427
|
}
|
|
384
428
|
exports.toHexBuf = toHexBuf;
|
|
429
|
+
function numToHexBuffer(val, bitLength = 8) {
|
|
430
|
+
return buffer_1.Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
431
|
+
}
|
|
432
|
+
exports.numToHexBuffer = numToHexBuffer;
|
|
385
433
|
/**
|
|
386
434
|
*
|
|
387
435
|
* @description Converts a number or BigNumber to a padded hexadecimal string
|
package/dist/lib/version.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "19.0.2"
|
|
6
|
+
"commitHash": "1aa9945ea2318318f16f494216a1c09801fa4bf8",
|
|
7
|
+
"version": "19.1.0-RC.2"
|
|
8
8
|
};
|
|
@@ -492,8 +492,8 @@ function validateSmartRollupAddress(value) {
|
|
|
492
492
|
|
|
493
493
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
494
494
|
const VERSION = {
|
|
495
|
-
"commitHash": "
|
|
496
|
-
"version": "19.0.2"
|
|
495
|
+
"commitHash": "1aa9945ea2318318f16f494216a1c09801fa4bf8",
|
|
496
|
+
"version": "19.1.0-RC.2"
|
|
497
497
|
};
|
|
498
498
|
|
|
499
499
|
const TZ_DECIMALS = 6;
|
|
@@ -609,6 +609,7 @@ function b58decodeL2Address(payload) {
|
|
|
609
609
|
* @description Base58 encode an address using predefined prefix
|
|
610
610
|
*
|
|
611
611
|
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1)
|
|
612
|
+
* @deprecated use encodeAddress instead, same functionality with a more descriptive name
|
|
612
613
|
*/
|
|
613
614
|
function encodePubKey(value) {
|
|
614
615
|
if (value.substring(0, 2) === '00') {
|
|
@@ -621,6 +622,26 @@ function encodePubKey(value) {
|
|
|
621
622
|
}
|
|
622
623
|
return b58cencode(value.substring(2, 42), prefix.KT);
|
|
623
624
|
}
|
|
625
|
+
/**
|
|
626
|
+
*
|
|
627
|
+
* @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation)
|
|
628
|
+
*
|
|
629
|
+
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1). Supports value with or without '0x' prefix
|
|
630
|
+
*/
|
|
631
|
+
function encodeAddress(value) {
|
|
632
|
+
if (value.substring(0, 2) === '0x') {
|
|
633
|
+
value = value.slice(2);
|
|
634
|
+
}
|
|
635
|
+
if (value.substring(0, 2) === '00') {
|
|
636
|
+
const pref = {
|
|
637
|
+
'0000': prefix.tz1,
|
|
638
|
+
'0001': prefix.tz2,
|
|
639
|
+
'0002': prefix.tz3,
|
|
640
|
+
};
|
|
641
|
+
return b58cencode(value.substring(4), pref[value.substring(0, 4)]);
|
|
642
|
+
}
|
|
643
|
+
return b58cencode(value.substring(2, 42), prefix.KT);
|
|
644
|
+
}
|
|
624
645
|
/**
|
|
625
646
|
*
|
|
626
647
|
* @description Base58 encode an address without predefined prefix
|
|
@@ -810,19 +831,39 @@ const getPkhfromPk = (publicKey) => {
|
|
|
810
831
|
* @description Convert a string to bytes
|
|
811
832
|
*
|
|
812
833
|
* @param str String to convert
|
|
834
|
+
* @deprecated use stringToBytes instead, same functionality with a more descriptive name
|
|
813
835
|
*/
|
|
814
836
|
function char2Bytes(str) {
|
|
815
837
|
return Buffer.from(str, 'utf8').toString('hex');
|
|
816
838
|
}
|
|
839
|
+
/**
|
|
840
|
+
*
|
|
841
|
+
* @description Convert a string to a byte string representation
|
|
842
|
+
*
|
|
843
|
+
* @param str String to convert
|
|
844
|
+
*/
|
|
845
|
+
function stringToBytes(str) {
|
|
846
|
+
return Buffer.from(str, 'utf8').toString('hex');
|
|
847
|
+
}
|
|
817
848
|
/**
|
|
818
849
|
*
|
|
819
850
|
* @description Convert bytes to a string
|
|
820
851
|
*
|
|
821
852
|
* @param str Bytes to convert
|
|
853
|
+
* @deprecated use hexStringToBytes instead, same functionality with a more descriptive name
|
|
822
854
|
*/
|
|
823
855
|
function bytes2Char(hex) {
|
|
824
856
|
return Buffer.from(hex2buf(hex)).toString('utf8');
|
|
825
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
*
|
|
860
|
+
* @description Convert byte string representation to string
|
|
861
|
+
*
|
|
862
|
+
* @param str byte string to convert
|
|
863
|
+
*/
|
|
864
|
+
function bytesToString(hex) {
|
|
865
|
+
return Buffer.from(hex2buf(hex)).toString('utf8');
|
|
866
|
+
}
|
|
826
867
|
/**
|
|
827
868
|
*
|
|
828
869
|
* @description Convert hex string/UintArray/Buffer to bytes
|
|
@@ -845,6 +886,9 @@ function hex2Bytes(hex) {
|
|
|
845
886
|
function toHexBuf(val, bitLength = 8) {
|
|
846
887
|
return Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
847
888
|
}
|
|
889
|
+
function numToHexBuffer(val, bitLength = 8) {
|
|
890
|
+
return Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
891
|
+
}
|
|
848
892
|
/**
|
|
849
893
|
*
|
|
850
894
|
* @description Converts a number or BigNumber to a padded hexadecimal string
|
|
@@ -889,5 +933,5 @@ function stripHexPrefix(hex) {
|
|
|
889
933
|
return hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
890
934
|
}
|
|
891
935
|
|
|
892
|
-
export { InvalidProtocolHashError, Prefix, VERSION, ValidationResult, ValueConversionError, b58cdecode, b58cencode, b58decode, b58decodeL2Address, buf2hex, bytes2Char, char2Bytes, encodeExpr, encodeKey, encodeKeyHash, encodeL2Address, encodeOpHash, encodePubKey, format, getPkhfromPk, hex2Bytes, hex2buf, invalidDetail, isValidPrefix, mergebuf, mic2arr, num2PaddedHex, prefix, prefixLength, stripHexPrefix, toHexBuf, validateAddress, validateBlock, validateChain, validateContractAddress, validateKeyHash, validateOperation, validatePkAndExtractPrefix, validateProtocol, validatePublicKey, validateSignature, validateSmartRollupAddress, validateSpendingKey, verifySignature };
|
|
936
|
+
export { InvalidProtocolHashError, Prefix, VERSION, ValidationResult, ValueConversionError, b58cdecode, b58cencode, b58decode, b58decodeL2Address, buf2hex, bytes2Char, bytesToString, char2Bytes, encodeAddress, encodeExpr, encodeKey, encodeKeyHash, encodeL2Address, encodeOpHash, encodePubKey, format, getPkhfromPk, hex2Bytes, hex2buf, invalidDetail, isValidPrefix, mergebuf, mic2arr, num2PaddedHex, numToHexBuffer, prefix, prefixLength, stringToBytes, stripHexPrefix, toHexBuf, validateAddress, validateBlock, validateChain, validateContractAddress, validateKeyHash, validateOperation, validatePkAndExtractPrefix, validateProtocol, validatePublicKey, validateSignature, validateSmartRollupAddress, validateSpendingKey, verifySignature };
|
|
893
937
|
//# sourceMappingURL=taquito-utils.es6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-utils.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taquito-utils.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -487,8 +487,8 @@
|
|
|
487
487
|
|
|
488
488
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
489
489
|
const VERSION = {
|
|
490
|
-
"commitHash": "
|
|
491
|
-
"version": "19.0.2"
|
|
490
|
+
"commitHash": "1aa9945ea2318318f16f494216a1c09801fa4bf8",
|
|
491
|
+
"version": "19.1.0-RC.2"
|
|
492
492
|
};
|
|
493
493
|
|
|
494
494
|
const TZ_DECIMALS = 6;
|
|
@@ -604,6 +604,7 @@
|
|
|
604
604
|
* @description Base58 encode an address using predefined prefix
|
|
605
605
|
*
|
|
606
606
|
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1)
|
|
607
|
+
* @deprecated use encodeAddress instead, same functionality with a more descriptive name
|
|
607
608
|
*/
|
|
608
609
|
function encodePubKey(value) {
|
|
609
610
|
if (value.substring(0, 2) === '00') {
|
|
@@ -616,6 +617,26 @@
|
|
|
616
617
|
}
|
|
617
618
|
return b58cencode(value.substring(2, 42), prefix.KT);
|
|
618
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
*
|
|
622
|
+
* @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation)
|
|
623
|
+
*
|
|
624
|
+
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1). Supports value with or without '0x' prefix
|
|
625
|
+
*/
|
|
626
|
+
function encodeAddress(value) {
|
|
627
|
+
if (value.substring(0, 2) === '0x') {
|
|
628
|
+
value = value.slice(2);
|
|
629
|
+
}
|
|
630
|
+
if (value.substring(0, 2) === '00') {
|
|
631
|
+
const pref = {
|
|
632
|
+
'0000': prefix.tz1,
|
|
633
|
+
'0001': prefix.tz2,
|
|
634
|
+
'0002': prefix.tz3,
|
|
635
|
+
};
|
|
636
|
+
return b58cencode(value.substring(4), pref[value.substring(0, 4)]);
|
|
637
|
+
}
|
|
638
|
+
return b58cencode(value.substring(2, 42), prefix.KT);
|
|
639
|
+
}
|
|
619
640
|
/**
|
|
620
641
|
*
|
|
621
642
|
* @description Base58 encode an address without predefined prefix
|
|
@@ -805,19 +826,39 @@
|
|
|
805
826
|
* @description Convert a string to bytes
|
|
806
827
|
*
|
|
807
828
|
* @param str String to convert
|
|
829
|
+
* @deprecated use stringToBytes instead, same functionality with a more descriptive name
|
|
808
830
|
*/
|
|
809
831
|
function char2Bytes(str) {
|
|
810
832
|
return buffer.Buffer.from(str, 'utf8').toString('hex');
|
|
811
833
|
}
|
|
834
|
+
/**
|
|
835
|
+
*
|
|
836
|
+
* @description Convert a string to a byte string representation
|
|
837
|
+
*
|
|
838
|
+
* @param str String to convert
|
|
839
|
+
*/
|
|
840
|
+
function stringToBytes(str) {
|
|
841
|
+
return buffer.Buffer.from(str, 'utf8').toString('hex');
|
|
842
|
+
}
|
|
812
843
|
/**
|
|
813
844
|
*
|
|
814
845
|
* @description Convert bytes to a string
|
|
815
846
|
*
|
|
816
847
|
* @param str Bytes to convert
|
|
848
|
+
* @deprecated use hexStringToBytes instead, same functionality with a more descriptive name
|
|
817
849
|
*/
|
|
818
850
|
function bytes2Char(hex) {
|
|
819
851
|
return buffer.Buffer.from(hex2buf(hex)).toString('utf8');
|
|
820
852
|
}
|
|
853
|
+
/**
|
|
854
|
+
*
|
|
855
|
+
* @description Convert byte string representation to string
|
|
856
|
+
*
|
|
857
|
+
* @param str byte string to convert
|
|
858
|
+
*/
|
|
859
|
+
function bytesToString(hex) {
|
|
860
|
+
return buffer.Buffer.from(hex2buf(hex)).toString('utf8');
|
|
861
|
+
}
|
|
821
862
|
/**
|
|
822
863
|
*
|
|
823
864
|
* @description Convert hex string/UintArray/Buffer to bytes
|
|
@@ -840,6 +881,9 @@
|
|
|
840
881
|
function toHexBuf(val, bitLength = 8) {
|
|
841
882
|
return buffer.Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
842
883
|
}
|
|
884
|
+
function numToHexBuffer(val, bitLength = 8) {
|
|
885
|
+
return buffer.Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
886
|
+
}
|
|
843
887
|
/**
|
|
844
888
|
*
|
|
845
889
|
* @description Converts a number or BigNumber to a padded hexadecimal string
|
|
@@ -949,7 +993,9 @@
|
|
|
949
993
|
exports.b58decodeL2Address = b58decodeL2Address;
|
|
950
994
|
exports.buf2hex = buf2hex;
|
|
951
995
|
exports.bytes2Char = bytes2Char;
|
|
996
|
+
exports.bytesToString = bytesToString;
|
|
952
997
|
exports.char2Bytes = char2Bytes;
|
|
998
|
+
exports.encodeAddress = encodeAddress;
|
|
953
999
|
exports.encodeExpr = encodeExpr;
|
|
954
1000
|
exports.encodeKey = encodeKey;
|
|
955
1001
|
exports.encodeKeyHash = encodeKeyHash;
|
|
@@ -965,8 +1011,10 @@
|
|
|
965
1011
|
exports.mergebuf = mergebuf;
|
|
966
1012
|
exports.mic2arr = mic2arr;
|
|
967
1013
|
exports.num2PaddedHex = num2PaddedHex;
|
|
1014
|
+
exports.numToHexBuffer = numToHexBuffer;
|
|
968
1015
|
exports.prefix = prefix;
|
|
969
1016
|
exports.prefixLength = prefixLength;
|
|
1017
|
+
exports.stringToBytes = stringToBytes;
|
|
970
1018
|
exports.stripHexPrefix = stripHexPrefix;
|
|
971
1019
|
exports.toHexBuf = toHexBuf;
|
|
972
1020
|
exports.validateAddress = validateAddress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-utils.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taquito-utils.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -59,8 +59,16 @@ export declare function b58decodeL2Address(payload: string): string;
|
|
|
59
59
|
* @description Base58 encode an address using predefined prefix
|
|
60
60
|
*
|
|
61
61
|
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1)
|
|
62
|
+
* @deprecated use encodeAddress instead, same functionality with a more descriptive name
|
|
62
63
|
*/
|
|
63
64
|
export declare function encodePubKey(value: string): string;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation)
|
|
68
|
+
*
|
|
69
|
+
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1). Supports value with or without '0x' prefix
|
|
70
|
+
*/
|
|
71
|
+
export declare function encodeAddress(value: string): string;
|
|
64
72
|
/**
|
|
65
73
|
*
|
|
66
74
|
* @description Base58 encode an address without predefined prefix
|
|
@@ -125,15 +133,31 @@ export declare const getPkhfromPk: (publicKey: string) => string;
|
|
|
125
133
|
* @description Convert a string to bytes
|
|
126
134
|
*
|
|
127
135
|
* @param str String to convert
|
|
136
|
+
* @deprecated use stringToBytes instead, same functionality with a more descriptive name
|
|
128
137
|
*/
|
|
129
138
|
export declare function char2Bytes(str: string): string;
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @description Convert a string to a byte string representation
|
|
142
|
+
*
|
|
143
|
+
* @param str String to convert
|
|
144
|
+
*/
|
|
145
|
+
export declare function stringToBytes(str: string): string;
|
|
130
146
|
/**
|
|
131
147
|
*
|
|
132
148
|
* @description Convert bytes to a string
|
|
133
149
|
*
|
|
134
150
|
* @param str Bytes to convert
|
|
151
|
+
* @deprecated use hexStringToBytes instead, same functionality with a more descriptive name
|
|
135
152
|
*/
|
|
136
153
|
export declare function bytes2Char(hex: string): string;
|
|
154
|
+
/**
|
|
155
|
+
*
|
|
156
|
+
* @description Convert byte string representation to string
|
|
157
|
+
*
|
|
158
|
+
* @param str byte string to convert
|
|
159
|
+
*/
|
|
160
|
+
export declare function bytesToString(hex: string): string;
|
|
137
161
|
/**
|
|
138
162
|
*
|
|
139
163
|
* @description Convert hex string/UintArray/Buffer to bytes
|
|
@@ -148,6 +172,7 @@ export declare function hex2Bytes(hex: string): Buffer;
|
|
|
148
172
|
* @param val The value that will be converted to a hexadecimal string value
|
|
149
173
|
*/
|
|
150
174
|
export declare function toHexBuf(val: number | BigNumber, bitLength?: number): Buffer;
|
|
175
|
+
export declare function numToHexBuffer(val: number | BigNumber, bitLength?: number): Buffer;
|
|
151
176
|
/**
|
|
152
177
|
*
|
|
153
178
|
* @description Converts a number or BigNumber to a padded hexadecimal string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taquito/utils",
|
|
3
|
-
"version": "19.0.2",
|
|
3
|
+
"version": "19.1.0-RC.2",
|
|
4
4
|
"description": "converts michelson data and types into convenient JS/TS objects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tezos",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@stablelib/blake2b": "^1.0.1",
|
|
66
66
|
"@stablelib/ed25519": "^1.0.3",
|
|
67
|
-
"@taquito/core": "^19.0.2",
|
|
67
|
+
"@taquito/core": "^19.1.0-RC.2",
|
|
68
68
|
"@types/bs58check": "^2.1.0",
|
|
69
69
|
"bignumber.js": "^9.1.2",
|
|
70
70
|
"blakejs": "^1.2.1",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"ts-toolbelt": "^9.6.0",
|
|
102
102
|
"typescript": "~5.2.2"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "72feb924392ac02aa06f08a9c4f535a876ac57d8"
|
|
105
105
|
}
|