@taquito/utils 17.3.2 → 17.4.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.
@@ -48,7 +48,7 @@ var Prefix;
48
48
  Prefix["TXW"] = "txw";
49
49
  Prefix["SR1"] = "sr1";
50
50
  Prefix["SRC1"] = "src1";
51
- })(Prefix = exports.Prefix || (exports.Prefix = {}));
51
+ })(Prefix || (exports.Prefix = Prefix = {}));
52
52
  exports.prefix = {
53
53
  [Prefix.TZ1]: new Uint8Array([6, 161, 159]),
54
54
  [Prefix.TZ2]: new Uint8Array([6, 161, 161]),
@@ -129,4 +129,3 @@ exports.prefixLength = {
129
129
  [Prefix.SR1]: 20,
130
130
  [Prefix.SRC1]: 32,
131
131
  };
132
- //# sourceMappingURL=constants.js.map
@@ -47,4 +47,3 @@ class ValueConversionError extends core_1.UnsupportedActionError {
47
47
  }
48
48
  }
49
49
  exports.ValueConversionError = ValueConversionError;
50
- //# sourceMappingURL=errors.js.map
@@ -25,4 +25,3 @@ function format(from = 'mutez', to = 'mutez', amount) {
25
25
  .dividedBy(Math.pow(10, getDecimal(to)));
26
26
  }
27
27
  exports.format = format;
28
- //# sourceMappingURL=format.js.map
@@ -5,7 +5,11 @@
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
9
13
  }) : (function(o, m, k, k2) {
10
14
  if (k2 === undefined) k2 = k;
11
15
  o[k2] = m[k];
@@ -49,7 +53,7 @@ Object.defineProperty(exports, "format", { enumerable: true, get: function () {
49
53
  * @param value Value in hex
50
54
  */
51
55
  function encodeExpr(value) {
52
- const blakeHash = blakejs_1.default.blake2b(exports.hex2buf(value), undefined, 32);
56
+ const blakeHash = blakejs_1.default.blake2b((0, exports.hex2buf)(value), undefined, 32);
53
57
  return b58cencode(blakeHash, constants_1.prefix['expr']);
54
58
  }
55
59
  exports.encodeExpr = encodeExpr;
@@ -59,7 +63,7 @@ exports.encodeExpr = encodeExpr;
59
63
  * @param value Value in hex of a signed operation
60
64
  */
61
65
  function encodeOpHash(value) {
62
- const blakeHash = blakejs_1.default.blake2b(exports.hex2buf(value), undefined, 32);
66
+ const blakeHash = blakejs_1.default.blake2b((0, exports.hex2buf)(value), undefined, 32);
63
67
  return b58cencode(blakeHash, constants_1.prefix.o);
64
68
  }
65
69
  exports.encodeOpHash = encodeOpHash;
@@ -107,16 +111,16 @@ function b58decode(payload) {
107
111
  const rollupPref = rollupPrefMap[new Uint8Array(buf.slice(0, 4)).toString()];
108
112
  if (pref) {
109
113
  // tz addresses
110
- const hex = exports.buf2hex(buf.slice(3));
114
+ const hex = (0, exports.buf2hex)(buf.slice(3));
111
115
  return pref + hex;
112
116
  }
113
117
  else if (rollupPref) {
114
- const hex = exports.buf2hex(buf.slice(4));
118
+ const hex = (0, exports.buf2hex)(buf.slice(4));
115
119
  return rollupPref + hex + '00';
116
120
  }
117
121
  else {
118
122
  // other (kt addresses)
119
- return '01' + exports.buf2hex(buf.slice(3, 42)) + '00';
123
+ return '01' + (0, exports.buf2hex)(buf.slice(3, 42)) + '00';
120
124
  }
121
125
  }
122
126
  exports.b58decode = b58decode;
@@ -129,7 +133,7 @@ exports.b58decode = b58decode;
129
133
  function b58decodeL2Address(payload) {
130
134
  const buf = bs58check_1.default.decode(payload);
131
135
  // tz4 address currently
132
- return exports.buf2hex(buf.slice(3, 42));
136
+ return (0, exports.buf2hex)(buf.slice(3, 42));
133
137
  }
134
138
  exports.b58decodeL2Address = b58decodeL2Address;
135
139
  /**
@@ -298,14 +302,13 @@ const mic2arr = function me2(s) {
298
302
  exports.mic2arr = mic2arr;
299
303
  /**
300
304
  *
301
- * @description Convert a buffer to an hex string
305
+ * @description Convert a Uint8Array to an hex string
302
306
  *
303
- * @param buffer Buffer to convert
307
+ * @param buffer Uint8Array to convert
304
308
  */
305
309
  const buf2hex = (buffer) => {
306
- const byteArray = new Uint8Array(buffer);
307
310
  const hexParts = [];
308
- byteArray.forEach((byte) => {
311
+ buffer.forEach((byte) => {
309
312
  const hex = byte.toString(16);
310
313
  const paddedHex = `00${hex}`.slice(-2);
311
314
  hexParts.push(paddedHex);
@@ -323,8 +326,8 @@ exports.buf2hex = buf2hex;
323
326
  const getPkhfromPk = (publicKey) => {
324
327
  let encodingPrefix;
325
328
  let prefixLen;
326
- const keyPrefix = verify_signature_1.validatePkAndExtractPrefix(publicKey);
327
- const decoded = exports.b58cdecode(publicKey, constants_1.prefix[keyPrefix]);
329
+ const keyPrefix = (0, verify_signature_1.validatePkAndExtractPrefix)(publicKey);
330
+ const decoded = (0, exports.b58cdecode)(publicKey, constants_1.prefix[keyPrefix]);
328
331
  switch (keyPrefix) {
329
332
  case constants_1.Prefix.EDPK:
330
333
  encodingPrefix = constants_1.prefix[constants_1.Prefix.TZ1];
@@ -342,7 +345,7 @@ const getPkhfromPk = (publicKey) => {
342
345
  encodingPrefix = constants_1.prefix[constants_1.Prefix.TZ4];
343
346
  prefixLen = constants_1.prefixLength[constants_1.Prefix.TZ4];
344
347
  }
345
- const hashed = blake2b_1.hash(decoded, prefixLen);
348
+ const hashed = (0, blake2b_1.hash)(decoded, prefixLen);
346
349
  const result = b58cencode(hashed, encodingPrefix);
347
350
  return result;
348
351
  };
@@ -364,7 +367,7 @@ exports.char2Bytes = char2Bytes;
364
367
  * @param str Bytes to convert
365
368
  */
366
369
  function bytes2Char(hex) {
367
- return buffer_1.Buffer.from(exports.hex2buf(hex)).toString('utf8');
370
+ return buffer_1.Buffer.from((0, exports.hex2buf)(hex)).toString('utf8');
368
371
  }
369
372
  exports.bytes2Char = bytes2Char;
370
373
  /**
@@ -402,7 +405,7 @@ function num2PaddedHex(val, bitLength = 8) {
402
405
  if (new bignumber_js_1.default(val).isPositive()) {
403
406
  const nibbleLength = Math.ceil(bitLength / 4);
404
407
  const hex = val.toString(16);
405
- // check whether nibble (4 bits) length is higher or lowerthan the current hex string length
408
+ // check whether nibble (4 bits) length is higher or lower than the current hex string length
406
409
  let targetLength = hex.length >= nibbleLength ? hex.length : nibbleLength;
407
410
  // make sure the hex string target length is even
408
411
  targetLength = targetLength % 2 == 0 ? targetLength : targetLength + 1;
@@ -436,4 +439,3 @@ function stripHexPrefix(hex) {
436
439
  return hex.startsWith('0x') ? hex.slice(2) : hex;
437
440
  }
438
441
  exports.stripHexPrefix = stripHexPrefix;
439
- //# sourceMappingURL=taquito-utils.js.map
@@ -9,7 +9,7 @@ var ValidationResult;
9
9
  ValidationResult[ValidationResult["INVALID_CHECKSUM"] = 1] = "INVALID_CHECKSUM";
10
10
  ValidationResult[ValidationResult["INVALID_LENGTH"] = 2] = "INVALID_LENGTH";
11
11
  ValidationResult[ValidationResult["VALID"] = 3] = "VALID";
12
- })(ValidationResult = exports.ValidationResult || (exports.ValidationResult = {}));
12
+ })(ValidationResult || (exports.ValidationResult = ValidationResult = {}));
13
13
  function isValidPrefix(value) {
14
14
  if (typeof value !== 'string') {
15
15
  return false;
@@ -260,4 +260,3 @@ function validateSmartRollupAddress(value) {
260
260
  return validatePrefixedValue(value, [...smartRollupPrefix]);
261
261
  }
262
262
  exports.validateSmartRollupAddress = validateSmartRollupAddress;
263
- //# sourceMappingURL=validators.js.map
@@ -29,13 +29,13 @@ const core_1 = require("@taquito/core");
29
29
  function verifySignature(messageBytes, publicKey, signature, watermark) {
30
30
  const pkPrefix = validatePkAndExtractPrefix(publicKey);
31
31
  const sigPrefix = validateSigAndExtractPrefix(signature);
32
- const decodedPublicKey = taquito_utils_1.b58cdecode(publicKey, taquito_utils_1.prefix[pkPrefix]);
33
- const decodedSig = taquito_utils_1.b58cdecode(signature, taquito_utils_1.prefix[sigPrefix]);
34
- let messageBuf = taquito_utils_1.hex2buf(validateMessageNotEmpty(messageBytes));
32
+ const decodedPublicKey = (0, taquito_utils_1.b58cdecode)(publicKey, taquito_utils_1.prefix[pkPrefix]);
33
+ const decodedSig = (0, taquito_utils_1.b58cdecode)(signature, taquito_utils_1.prefix[sigPrefix]);
34
+ let messageBuf = (0, taquito_utils_1.hex2buf)(validateMessageNotEmpty(messageBytes));
35
35
  if (typeof watermark !== 'undefined') {
36
- messageBuf = taquito_utils_1.mergebuf(watermark, messageBuf);
36
+ messageBuf = (0, taquito_utils_1.mergebuf)(watermark, messageBuf);
37
37
  }
38
- const bytesHash = blake2b_1.hash(messageBuf, 32);
38
+ const bytesHash = (0, blake2b_1.hash)(messageBuf, 32);
39
39
  if (pkPrefix === taquito_utils_1.Prefix.EDPK) {
40
40
  return verifyEdSignature(decodedSig, bytesHash, decodedPublicKey);
41
41
  }
@@ -61,9 +61,9 @@ function validatePkAndExtractPrefix(publicKey) {
61
61
  throw new core_1.InvalidPublicKeyError(publicKey, `can't be empty`);
62
62
  }
63
63
  const pkPrefix = publicKey.substring(0, 4);
64
- const publicKeyValidation = taquito_utils_1.validatePublicKey(publicKey);
64
+ const publicKeyValidation = (0, taquito_utils_1.validatePublicKey)(publicKey);
65
65
  if (publicKeyValidation !== taquito_utils_1.ValidationResult.VALID) {
66
- throw new core_1.InvalidPublicKeyError(publicKey, taquito_utils_1.invalidDetail(publicKeyValidation));
66
+ throw new core_1.InvalidPublicKeyError(publicKey, (0, taquito_utils_1.invalidDetail)(publicKeyValidation));
67
67
  }
68
68
  return pkPrefix;
69
69
  }
@@ -72,15 +72,15 @@ function validateSigAndExtractPrefix(signature) {
72
72
  const signaturePrefix = signature.startsWith('sig')
73
73
  ? signature.substring(0, 3)
74
74
  : signature.substring(0, 5);
75
- const validation = taquito_utils_1.validateSignature(signature);
75
+ const validation = (0, taquito_utils_1.validateSignature)(signature);
76
76
  if (validation !== taquito_utils_1.ValidationResult.VALID) {
77
- throw new core_1.InvalidSignatureError(signature, taquito_utils_1.invalidDetail(validation));
77
+ throw new core_1.InvalidSignatureError(signature, (0, taquito_utils_1.invalidDetail)(validation));
78
78
  }
79
79
  return signaturePrefix;
80
80
  }
81
81
  function verifyEdSignature(decodedSig, bytesHash, decodedPublicKey) {
82
82
  try {
83
- return ed25519_1.verify(decodedPublicKey, bytesHash, decodedSig);
83
+ return (0, ed25519_1.verify)(decodedPublicKey, bytesHash, decodedSig);
84
84
  }
85
85
  catch (e) {
86
86
  return false;
@@ -95,7 +95,7 @@ function verifyP2Signature(decodedSig, bytesHash, decodedPublicKey) {
95
95
  return verifySpOrP2Sig(decodedSig, bytesHash, key);
96
96
  }
97
97
  function verifySpOrP2Sig(decodedSig, bytesHash, key) {
98
- const hexSig = taquito_utils_1.buf2hex(typedarray_to_buffer_1.default(decodedSig));
98
+ const hexSig = (0, taquito_utils_1.buf2hex)((0, typedarray_to_buffer_1.default)(decodedSig));
99
99
  const match = hexSig.match(/([a-f\d]{64})/gi);
100
100
  if (match) {
101
101
  try {
@@ -108,4 +108,3 @@ function verifySpOrP2Sig(decodedSig, bytesHash, key) {
108
108
  }
109
109
  return false;
110
110
  }
111
- //# sourceMappingURL=verify-signature.js.map
@@ -3,7 +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": "a97e506efd61b86e39ae30db588401b8fda46553",
7
- "version": "17.3.2"
6
+ "commitHash": "a908ab176a8c52c025fd43e7acd452415396f54e",
7
+ "version": "17.4.0"
8
8
  };
9
- //# sourceMappingURL=version.js.map