@taquito/utils 24.3.0-beta.1 → 24.3.0-beta.3
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 +1 -1
- package/dist/lib/encoding.js +8 -7
- package/dist/lib/format.js +7 -1
- package/dist/lib/verify-signature.js +6 -6
- package/dist/lib/version.js +2 -2
- package/dist/taquito-utils.es6.js +475 -15
- package/dist/taquito-utils.es6.js.map +1 -1
- package/dist/taquito-utils.umd.js +475 -14
- package/dist/taquito-utils.umd.js.map +1 -1
- package/dist/types/encoding.d.ts +4 -1
- package/package.json +10 -35
- package/signature.json +0 -202
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ console.log(validateKeyHash(keyHash));
|
|
|
52
52
|
```ts
|
|
53
53
|
import { validateContractAddress } from '@taquito/utils';
|
|
54
54
|
|
|
55
|
-
const contractAddress = '
|
|
55
|
+
const contractAddress = 'KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2';
|
|
56
56
|
console.log(validateContractAddress(contractAddress));
|
|
57
57
|
// output: 3 which is valid
|
|
58
58
|
```
|
package/dist/lib/encoding.js
CHANGED
|
@@ -38,9 +38,10 @@ exports.compareArrays = compareArrays;
|
|
|
38
38
|
*/
|
|
39
39
|
const buffer_1 = require("buffer");
|
|
40
40
|
const constants_1 = require("./constants");
|
|
41
|
-
const
|
|
41
|
+
const blake2_js_1 = require("@noble/hashes/blake2.js");
|
|
42
42
|
const bs58check_1 = require("bs58check");
|
|
43
43
|
const bignumber_js_1 = require("bignumber.js");
|
|
44
|
+
const BigNumber = bignumber_js_1.default;
|
|
44
45
|
const typedarray_to_buffer_1 = require("typedarray-to-buffer");
|
|
45
46
|
const core_1 = require("@taquito/core");
|
|
46
47
|
/**
|
|
@@ -270,7 +271,7 @@ function getPkhfromPk(publicKey) {
|
|
|
270
271
|
default:
|
|
271
272
|
throw new core_1.InvalidPublicKeyError(publicKey, core_1.ValidationResult.NO_PREFIX_MATCHED);
|
|
272
273
|
}
|
|
273
|
-
const hashed = (0,
|
|
274
|
+
const hashed = (0, blake2_js_1.blake2b)(key, { dkLen: 20 });
|
|
274
275
|
return b58Encode(hashed, pkhPre);
|
|
275
276
|
}
|
|
276
277
|
/**
|
|
@@ -395,7 +396,7 @@ function encodeBlsAddress(value) {
|
|
|
395
396
|
* @example encodeExpr('050a000000160000b2e19a9e74440d86c59f13dab8a18ff873e889ea') // return 'exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN'
|
|
396
397
|
*/
|
|
397
398
|
function encodeExpr(value) {
|
|
398
|
-
const blakeHash = (0,
|
|
399
|
+
const blakeHash = (0, blake2_js_1.blake2b)(hex2buf(value), { dkLen: 32 });
|
|
399
400
|
return b58Encode(blakeHash, constants_1.PrefixV2.ScriptExpr);
|
|
400
401
|
}
|
|
401
402
|
/**
|
|
@@ -405,7 +406,7 @@ function encodeExpr(value) {
|
|
|
405
406
|
* @example encodeOpHash('0f185d8a30061e8134c162dbb7a6c3ab8f5fdb153363ccd6149b49a33481156a6c00b2e19a9e74440d86c59f13dab8a18ff873e889eaa304ab05da13000001f1585a7384f36e45fb43dc37e8ce172bced3e05700ff0000000002002110c033f3a990c2e46a3d6054ecc2f74072aae7a34b5ac4d9ce9edc11c2410a97695682108951786f05b361da03b97245dc9897e1955e08b5b8d9e153b0bdeb0d') // return 'opapqvVXmebRTCFd2GQFydr4tJj3V5QocQuTmuhbatcHm4Seo2t'
|
|
406
407
|
*/
|
|
407
408
|
function encodeOpHash(value) {
|
|
408
|
-
const blakeHash = (0,
|
|
409
|
+
const blakeHash = (0, blake2_js_1.blake2b)(hex2buf(value), { dkLen: 32 });
|
|
409
410
|
return b58Encode(blakeHash, constants_1.PrefixV2.OperationHash);
|
|
410
411
|
}
|
|
411
412
|
/**
|
|
@@ -549,7 +550,7 @@ function numToHexBuffer(val, bitLength = 8) {
|
|
|
549
550
|
*
|
|
550
551
|
*/
|
|
551
552
|
function num2PaddedHex(val, bitLength = 8) {
|
|
552
|
-
if (new
|
|
553
|
+
if (new BigNumber(val).isPositive()) {
|
|
553
554
|
const nibbleLength = Math.ceil(bitLength / 4);
|
|
554
555
|
const hex = val.toString(16);
|
|
555
556
|
// check whether nibble (4 bits) length is higher or lower than the current hex string length
|
|
@@ -559,9 +560,9 @@ function num2PaddedHex(val, bitLength = 8) {
|
|
|
559
560
|
return padHexWithZero(hex, targetLength);
|
|
560
561
|
}
|
|
561
562
|
else {
|
|
562
|
-
const twosCompliment = new
|
|
563
|
+
const twosCompliment = new BigNumber(2)
|
|
563
564
|
.pow(bitLength)
|
|
564
|
-
.minus(new
|
|
565
|
+
.minus(new BigNumber(val).abs());
|
|
565
566
|
return twosCompliment.toString(16);
|
|
566
567
|
}
|
|
567
568
|
}
|
package/dist/lib/format.js
CHANGED
|
@@ -16,7 +16,13 @@ function getDecimal(format) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
function format(from = 'mutez', to = 'mutez', amount) {
|
|
19
|
-
|
|
19
|
+
let bigNum;
|
|
20
|
+
try {
|
|
21
|
+
bigNum = new bignumber_js_1.default(amount);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return amount;
|
|
25
|
+
}
|
|
20
26
|
if (bigNum.isNaN()) {
|
|
21
27
|
return amount;
|
|
22
28
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.POP_DST = exports.BLS12_381_DST = void 0;
|
|
4
4
|
exports.verifySignature = verifySignature;
|
|
5
|
-
const ed25519_1 = require("@
|
|
6
|
-
const
|
|
5
|
+
const ed25519_1 = require("@noble/curves/ed25519");
|
|
6
|
+
const blake2_js_1 = require("@noble/hashes/blake2.js");
|
|
7
7
|
const encoding_1 = require("./encoding");
|
|
8
8
|
const constants_1 = require("./constants");
|
|
9
9
|
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
@@ -89,16 +89,16 @@ function verifySignature(message, publicKey, signature, watermark, pop) {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
function verifyEdSignature(sig, msg, publicKey) {
|
|
92
|
-
const hash = (0,
|
|
92
|
+
const hash = (0, blake2_js_1.blake2b)(msg, { dkLen: 32 });
|
|
93
93
|
try {
|
|
94
|
-
return
|
|
94
|
+
return ed25519_1.ed25519.verify(sig, hash, publicKey);
|
|
95
95
|
}
|
|
96
96
|
catch {
|
|
97
97
|
return false;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
function verifySpSignature(sig, msg, publicKey) {
|
|
101
|
-
const hash = (0,
|
|
101
|
+
const hash = (0, blake2_js_1.blake2b)(msg, { dkLen: 32 });
|
|
102
102
|
try {
|
|
103
103
|
return secp256k1_1.secp256k1.verify(sig, hash, publicKey);
|
|
104
104
|
}
|
|
@@ -107,7 +107,7 @@ function verifySpSignature(sig, msg, publicKey) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
function verifyP2Signature(sig, msg, publicKey) {
|
|
110
|
-
const hash = (0,
|
|
110
|
+
const hash = (0, blake2_js_1.blake2b)(msg, { dkLen: 32 });
|
|
111
111
|
try {
|
|
112
112
|
return nist_1.p256.verify(sig, hash, publicKey);
|
|
113
113
|
}
|
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!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "24.3.0-beta.
|
|
6
|
+
"commitHash": "a312cd3f4fc0ab0fb3351bfffe6ad855772cb077",
|
|
7
|
+
"version": "24.3.0-beta.3"
|
|
8
8
|
};
|