@taquito/utils
Advanced tools
Comparing version 19.0.2 to 19.1.0-RC.1
@@ -21,3 +21,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
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; | ||
/* | ||
@@ -137,2 +137,3 @@ * Some code in this file is originally from sotez and eztz | ||
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1) | ||
* @deprecated use encodeAddress instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -153,2 +154,23 @@ function encodePubKey(value) { | ||
* | ||
* @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation) | ||
* | ||
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1). Supports value with or without '0x' prefix | ||
*/ | ||
function encodeAddress(value) { | ||
if (value.substring(0, 2) === '0x') { | ||
value = value.slice(2); | ||
} | ||
if (value.substring(0, 2) === '00') { | ||
const pref = { | ||
'0000': constants_1.prefix.tz1, | ||
'0001': constants_1.prefix.tz2, | ||
'0002': constants_1.prefix.tz3, | ||
}; | ||
return b58cencode(value.substring(4), pref[value.substring(0, 4)]); | ||
} | ||
return b58cencode(value.substring(2, 42), constants_1.prefix.KT); | ||
} | ||
exports.encodeAddress = encodeAddress; | ||
/** | ||
* | ||
* @description Base58 encode an address without predefined prefix | ||
@@ -349,2 +371,3 @@ * @param value Address to base58 encode (tz4) hex dec | ||
* @param str String to convert | ||
* @deprecated use stringToBytes instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -357,5 +380,16 @@ function char2Bytes(str) { | ||
* | ||
* @description Convert a string to a byte string representation | ||
* | ||
* @param str String to convert | ||
*/ | ||
function stringToBytes(str) { | ||
return buffer_1.Buffer.from(str, 'utf8').toString('hex'); | ||
} | ||
exports.stringToBytes = stringToBytes; | ||
/** | ||
* | ||
* @description Convert bytes to a string | ||
* | ||
* @param str Bytes to convert | ||
* @deprecated use hexStringToBytes instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -368,2 +402,12 @@ function bytes2Char(hex) { | ||
* | ||
* @description Convert byte string representation to string | ||
* | ||
* @param str byte string to convert | ||
*/ | ||
function bytesToString(hex) { | ||
return buffer_1.Buffer.from((0, exports.hex2buf)(hex)).toString('utf8'); | ||
} | ||
exports.bytesToString = bytesToString; | ||
/** | ||
* | ||
* @description Convert hex string/UintArray/Buffer to bytes | ||
@@ -391,2 +435,6 @@ * | ||
exports.toHexBuf = toHexBuf; | ||
function numToHexBuffer(val, bitLength = 8) { | ||
return buffer_1.Buffer.from(num2PaddedHex(val, bitLength), 'hex'); | ||
} | ||
exports.numToHexBuffer = numToHexBuffer; | ||
/** | ||
@@ -393,0 +441,0 @@ * |
@@ -6,4 +6,4 @@ "use strict"; | ||
exports.VERSION = { | ||
"commitHash": "13a12ab7cf442043526745db2bbf4ef3b089c34a", | ||
"version": "19.0.2" | ||
"commitHash": "708d150af0e1d81cf4bd44df7e41867689f39d22", | ||
"version": "19.1.0-RC.1" | ||
}; |
@@ -495,4 +495,4 @@ import { Buffer } from 'buffer'; | ||
const VERSION = { | ||
"commitHash": "13a12ab7cf442043526745db2bbf4ef3b089c34a", | ||
"version": "19.0.2" | ||
"commitHash": "708d150af0e1d81cf4bd44df7e41867689f39d22", | ||
"version": "19.1.0-RC.1" | ||
}; | ||
@@ -613,2 +613,3 @@ | ||
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1) | ||
* @deprecated use encodeAddress instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -628,2 +629,22 @@ function encodePubKey(value) { | ||
* | ||
* @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation) | ||
* | ||
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1). Supports value with or without '0x' prefix | ||
*/ | ||
function encodeAddress(value) { | ||
if (value.substring(0, 2) === '0x') { | ||
value = value.slice(2); | ||
} | ||
if (value.substring(0, 2) === '00') { | ||
const pref = { | ||
'0000': prefix.tz1, | ||
'0001': prefix.tz2, | ||
'0002': prefix.tz3, | ||
}; | ||
return b58cencode(value.substring(4), pref[value.substring(0, 4)]); | ||
} | ||
return b58cencode(value.substring(2, 42), prefix.KT); | ||
} | ||
/** | ||
* | ||
* @description Base58 encode an address without predefined prefix | ||
@@ -816,2 +837,3 @@ * @param value Address to base58 encode (tz4) hex dec | ||
* @param str String to convert | ||
* @deprecated use stringToBytes instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -823,5 +845,15 @@ function char2Bytes(str) { | ||
* | ||
* @description Convert a string to a byte string representation | ||
* | ||
* @param str String to convert | ||
*/ | ||
function stringToBytes(str) { | ||
return Buffer.from(str, 'utf8').toString('hex'); | ||
} | ||
/** | ||
* | ||
* @description Convert bytes to a string | ||
* | ||
* @param str Bytes to convert | ||
* @deprecated use hexStringToBytes instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -833,2 +865,11 @@ function bytes2Char(hex) { | ||
* | ||
* @description Convert byte string representation to string | ||
* | ||
* @param str byte string to convert | ||
*/ | ||
function bytesToString(hex) { | ||
return Buffer.from(hex2buf(hex)).toString('utf8'); | ||
} | ||
/** | ||
* | ||
* @description Convert hex string/UintArray/Buffer to bytes | ||
@@ -854,2 +895,5 @@ * | ||
} | ||
function numToHexBuffer(val, bitLength = 8) { | ||
return Buffer.from(num2PaddedHex(val, bitLength), 'hex'); | ||
} | ||
/** | ||
@@ -899,3 +943,3 @@ * | ||
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 }; | ||
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 }; | ||
//# sourceMappingURL=taquito-utils.es6.js.map |
@@ -490,4 +490,4 @@ (function (global, factory) { | ||
const VERSION = { | ||
"commitHash": "13a12ab7cf442043526745db2bbf4ef3b089c34a", | ||
"version": "19.0.2" | ||
"commitHash": "708d150af0e1d81cf4bd44df7e41867689f39d22", | ||
"version": "19.1.0-RC.1" | ||
}; | ||
@@ -608,2 +608,3 @@ | ||
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1) | ||
* @deprecated use encodeAddress instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -623,2 +624,22 @@ function encodePubKey(value) { | ||
* | ||
* @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation) | ||
* | ||
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1). Supports value with or without '0x' prefix | ||
*/ | ||
function encodeAddress(value) { | ||
if (value.substring(0, 2) === '0x') { | ||
value = value.slice(2); | ||
} | ||
if (value.substring(0, 2) === '00') { | ||
const pref = { | ||
'0000': prefix.tz1, | ||
'0001': prefix.tz2, | ||
'0002': prefix.tz3, | ||
}; | ||
return b58cencode(value.substring(4), pref[value.substring(0, 4)]); | ||
} | ||
return b58cencode(value.substring(2, 42), prefix.KT); | ||
} | ||
/** | ||
* | ||
* @description Base58 encode an address without predefined prefix | ||
@@ -811,2 +832,3 @@ * @param value Address to base58 encode (tz4) hex dec | ||
* @param str String to convert | ||
* @deprecated use stringToBytes instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -818,5 +840,15 @@ function char2Bytes(str) { | ||
* | ||
* @description Convert a string to a byte string representation | ||
* | ||
* @param str String to convert | ||
*/ | ||
function stringToBytes(str) { | ||
return buffer.Buffer.from(str, 'utf8').toString('hex'); | ||
} | ||
/** | ||
* | ||
* @description Convert bytes to a string | ||
* | ||
* @param str Bytes to convert | ||
* @deprecated use hexStringToBytes instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -828,2 +860,11 @@ function bytes2Char(hex) { | ||
* | ||
* @description Convert byte string representation to string | ||
* | ||
* @param str byte string to convert | ||
*/ | ||
function bytesToString(hex) { | ||
return buffer.Buffer.from(hex2buf(hex)).toString('utf8'); | ||
} | ||
/** | ||
* | ||
* @description Convert hex string/UintArray/Buffer to bytes | ||
@@ -849,2 +890,5 @@ * | ||
} | ||
function numToHexBuffer(val, bitLength = 8) { | ||
return buffer.Buffer.from(num2PaddedHex(val, bitLength), 'hex'); | ||
} | ||
/** | ||
@@ -959,3 +1003,5 @@ * | ||
exports.bytes2Char = bytes2Char; | ||
exports.bytesToString = bytesToString; | ||
exports.char2Bytes = char2Bytes; | ||
exports.encodeAddress = encodeAddress; | ||
exports.encodeExpr = encodeExpr; | ||
@@ -976,4 +1022,6 @@ exports.encodeKey = encodeKey; | ||
exports.num2PaddedHex = num2PaddedHex; | ||
exports.numToHexBuffer = numToHexBuffer; | ||
exports.prefix = prefix; | ||
exports.prefixLength = prefixLength; | ||
exports.stringToBytes = stringToBytes; | ||
exports.stripHexPrefix = stripHexPrefix; | ||
@@ -980,0 +1028,0 @@ exports.toHexBuf = toHexBuf; |
@@ -62,2 +62,3 @@ /** | ||
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1) | ||
* @deprecated use encodeAddress instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -67,2 +68,9 @@ export declare function encodePubKey(value: string): string; | ||
* | ||
* @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation) | ||
* | ||
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1). Supports value with or without '0x' prefix | ||
*/ | ||
export declare function encodeAddress(value: string): string; | ||
/** | ||
* | ||
* @description Base58 encode an address without predefined prefix | ||
@@ -130,2 +138,3 @@ * @param value Address to base58 encode (tz4) hex dec | ||
* @param str String to convert | ||
* @deprecated use stringToBytes instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -135,5 +144,13 @@ export declare function char2Bytes(str: string): string; | ||
* | ||
* @description Convert a string to a byte string representation | ||
* | ||
* @param str String to convert | ||
*/ | ||
export declare function stringToBytes(str: string): string; | ||
/** | ||
* | ||
* @description Convert bytes to a string | ||
* | ||
* @param str Bytes to convert | ||
* @deprecated use hexStringToBytes instead, same functionality with a more descriptive name | ||
*/ | ||
@@ -143,2 +160,9 @@ export declare function bytes2Char(hex: string): string; | ||
* | ||
* @description Convert byte string representation to string | ||
* | ||
* @param str byte string to convert | ||
*/ | ||
export declare function bytesToString(hex: string): string; | ||
/** | ||
* | ||
* @description Convert hex string/UintArray/Buffer to bytes | ||
@@ -156,2 +180,3 @@ * | ||
export declare function toHexBuf(val: number | BigNumber, bitLength?: number): Buffer; | ||
export declare function numToHexBuffer(val: number | BigNumber, bitLength?: number): Buffer; | ||
/** | ||
@@ -158,0 +183,0 @@ * |
{ | ||
"name": "@taquito/utils", | ||
"version": "19.0.2", | ||
"version": "19.1.0-RC.1", | ||
"description": "converts michelson data and types into convenient JS/TS objects", | ||
@@ -67,3 +67,3 @@ "keywords": [ | ||
"@stablelib/ed25519": "^1.0.3", | ||
"@taquito/core": "^19.0.2", | ||
"@taquito/core": "^19.1.0-RC.1", | ||
"@types/bs58check": "^2.1.0", | ||
@@ -105,3 +105,3 @@ "bignumber.js": "^9.1.2", | ||
}, | ||
"gitHead": "ede4790173abf0f153b87fec23a36e1b2b8114e2" | ||
"gitHead": "dc0254c0ded7574d36705761c123b25116c7eeaf" | ||
} |
@@ -138,3 +138,3 @@ # Taquito Utils package | ||
```ts | ||
import { char2Bytes, bytes2Char } from '@taquito/utils'; | ||
import { stringToBytes, bytesToString } from '@taquito/utils'; | ||
@@ -144,6 +144,6 @@ const url = 'https://storage.googleapis.com/tzip-16/fa2-views.json'; | ||
console.log(char2Bytes(url)); | ||
console.log(stringToBytes(url)); | ||
// output: 68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f747a69702d31362f6661322d76696577732e6a736f6e | ||
console.log(bytes2Char(hex)); | ||
console.log(bytesToString(hex)); | ||
// output: https://storage.googleapis.com/tzip-16/fa2-views.json | ||
@@ -199,8 +199,8 @@ ``` | ||
```ts | ||
import { encodePubKey } from '@taquito/utils'; | ||
import { encodeAddress } from '@taquito/utils'; | ||
console.log(encodePubKey('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f')); | ||
console.log(encodeAddress('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f')); | ||
// output: tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM | ||
console.log(encodePubKey('01f9b689a478253793bd92357c5e08e5ebcd8db47600')); | ||
console.log(encodeAddress('01f9b689a478253793bd92357c5e08e5ebcd8db47600')); | ||
// output: KT1XM8VUFBiM9AC5czWU15fEeE9nmuEYWt3Y | ||
@@ -207,0 +207,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
157798
3698
2
Updated@taquito/core@^19.1.0-RC.1