@taquito/utils 18.0.0-RC.0 → 19.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.
@@ -38,16 +38,9 @@ var Prefix;
38
38
  Prefix["VH"] = "vh";
39
39
  Prefix["SASK"] = "sask";
40
40
  Prefix["ZET1"] = "zet1";
41
- //rollups
42
- Prefix["TXI"] = "txi";
43
- Prefix["TXM"] = "txm";
44
- Prefix["TXC"] = "txc";
45
- Prefix["TXMR"] = "txmr";
46
- Prefix["TXRL"] = "txM";
47
- Prefix["TXW"] = "txw";
48
41
  Prefix["SR1"] = "sr1";
49
42
  Prefix["SRC1"] = "src1";
50
- })(Prefix = exports.Prefix || (exports.Prefix = {}));
43
+ })(Prefix || (exports.Prefix = Prefix = {}));
51
44
  exports.prefix = {
52
45
  [Prefix.TZ1]: new Uint8Array([6, 161, 159]),
53
46
  [Prefix.TZ2]: new Uint8Array([6, 161, 161]),
@@ -85,12 +78,6 @@ exports.prefix = {
85
78
  [Prefix.VH]: new Uint8Array([1, 106, 242]),
86
79
  [Prefix.SASK]: new Uint8Array([11, 237, 20, 92]),
87
80
  [Prefix.ZET1]: new Uint8Array([18, 71, 40, 223]),
88
- [Prefix.TXI]: new Uint8Array([79, 148, 196]),
89
- [Prefix.TXM]: new Uint8Array([79, 149, 30]),
90
- [Prefix.TXC]: new Uint8Array([79, 148, 17]),
91
- [Prefix.TXMR]: new Uint8Array([18, 7, 206, 87]),
92
- [Prefix.TXRL]: new Uint8Array([79, 146, 82]),
93
- [Prefix.TXW]: new Uint8Array([79, 150, 72]),
94
81
  [Prefix.SR1]: new Uint8Array([6, 124, 117]),
95
82
  [Prefix.SRC1]: new Uint8Array([17, 165, 134, 138]),
96
83
  };
@@ -117,13 +104,6 @@ exports.prefixLength = {
117
104
  [Prefix.VH]: 32,
118
105
  [Prefix.SASK]: 169,
119
106
  [Prefix.ZET1]: 43,
120
- [Prefix.TXI]: 32,
121
- [Prefix.TXM]: 32,
122
- [Prefix.TXC]: 32,
123
- [Prefix.TXMR]: 32,
124
- [Prefix.TXRL]: 32,
125
- [Prefix.TXW]: 32,
126
107
  [Prefix.SR1]: 20,
127
108
  [Prefix.SRC1]: 32,
128
109
  };
129
- //# 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;
@@ -103,12 +107,12 @@ function b58decode(payload) {
103
107
  const pref = prefixMap[new Uint8Array(buf.slice(0, 3)).toString()];
104
108
  if (pref) {
105
109
  // tz addresses
106
- const hex = exports.buf2hex(buf.slice(3));
110
+ const hex = (0, exports.buf2hex)(buf.slice(3));
107
111
  return pref + hex;
108
112
  }
109
113
  else {
110
114
  // other (kt addresses)
111
- return '01' + exports.buf2hex(buf.slice(3, 42)) + '00';
115
+ return '01' + (0, exports.buf2hex)(buf.slice(3, 42)) + '00';
112
116
  }
113
117
  }
114
118
  exports.b58decode = b58decode;
@@ -121,7 +125,7 @@ exports.b58decode = b58decode;
121
125
  function b58decodeL2Address(payload) {
122
126
  const buf = bs58check_1.default.decode(payload);
123
127
  // tz4 address currently
124
- return exports.buf2hex(buf.slice(3, 42));
128
+ return (0, exports.buf2hex)(buf.slice(3, 42));
125
129
  }
126
130
  exports.b58decodeL2Address = b58decodeL2Address;
127
131
  /**
@@ -286,14 +290,13 @@ const mic2arr = function me2(s) {
286
290
  exports.mic2arr = mic2arr;
287
291
  /**
288
292
  *
289
- * @description Convert a buffer to an hex string
293
+ * @description Convert a Uint8Array to an hex string
290
294
  *
291
- * @param buffer Buffer to convert
295
+ * @param buffer Uint8Array to convert
292
296
  */
293
297
  const buf2hex = (buffer) => {
294
- const byteArray = new Uint8Array(buffer);
295
298
  const hexParts = [];
296
- byteArray.forEach((byte) => {
299
+ buffer.forEach((byte) => {
297
300
  const hex = byte.toString(16);
298
301
  const paddedHex = `00${hex}`.slice(-2);
299
302
  hexParts.push(paddedHex);
@@ -311,8 +314,8 @@ exports.buf2hex = buf2hex;
311
314
  const getPkhfromPk = (publicKey) => {
312
315
  let encodingPrefix;
313
316
  let prefixLen;
314
- const keyPrefix = verify_signature_1.validatePkAndExtractPrefix(publicKey);
315
- const decoded = exports.b58cdecode(publicKey, constants_1.prefix[keyPrefix]);
317
+ const keyPrefix = (0, verify_signature_1.validatePkAndExtractPrefix)(publicKey);
318
+ const decoded = (0, exports.b58cdecode)(publicKey, constants_1.prefix[keyPrefix]);
316
319
  switch (keyPrefix) {
317
320
  case constants_1.Prefix.EDPK:
318
321
  encodingPrefix = constants_1.prefix[constants_1.Prefix.TZ1];
@@ -330,7 +333,7 @@ const getPkhfromPk = (publicKey) => {
330
333
  encodingPrefix = constants_1.prefix[constants_1.Prefix.TZ4];
331
334
  prefixLen = constants_1.prefixLength[constants_1.Prefix.TZ4];
332
335
  }
333
- const hashed = blake2b_1.hash(decoded, prefixLen);
336
+ const hashed = (0, blake2b_1.hash)(decoded, prefixLen);
334
337
  const result = b58cencode(hashed, encodingPrefix);
335
338
  return result;
336
339
  };
@@ -352,7 +355,7 @@ exports.char2Bytes = char2Bytes;
352
355
  * @param str Bytes to convert
353
356
  */
354
357
  function bytes2Char(hex) {
355
- return buffer_1.Buffer.from(exports.hex2buf(hex)).toString('utf8');
358
+ return buffer_1.Buffer.from((0, exports.hex2buf)(hex)).toString('utf8');
356
359
  }
357
360
  exports.bytes2Char = bytes2Char;
358
361
  /**
@@ -390,7 +393,7 @@ function num2PaddedHex(val, bitLength = 8) {
390
393
  if (new bignumber_js_1.default(val).isPositive()) {
391
394
  const nibbleLength = Math.ceil(bitLength / 4);
392
395
  const hex = val.toString(16);
393
- // check whether nibble (4 bits) length is higher or lowerthan the current hex string length
396
+ // check whether nibble (4 bits) length is higher or lower than the current hex string length
394
397
  let targetLength = hex.length >= nibbleLength ? hex.length : nibbleLength;
395
398
  // make sure the hex string target length is even
396
399
  targetLength = targetLength % 2 == 0 ? targetLength : targetLength + 1;
@@ -424,4 +427,3 @@ function stripHexPrefix(hex) {
424
427
  return hex.startsWith('0x') ? hex.slice(2) : hex;
425
428
  }
426
429
  exports.stripHexPrefix = stripHexPrefix;
427
- //# 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
@@ -11,7 +11,7 @@ const core_1 = require("@taquito/core");
11
11
  * @description Verify signature of a payload
12
12
  *
13
13
  * @param messageBytes The forged message including the magic byte (11 for block,
14
- * 12 for preendorsement/preattestation, 13 for endorsement/attestation, 3 for generic, 5 for the PACK format of michelson)
14
+ * 12 for preattestation/preendorsement, 13 for attestation/endorsement, 3 for generic, 5 for the PACK format of michelson)
15
15
  * @param publicKey The public key to verify the signature against
16
16
  * @param signature The signature to verify
17
17
  * @returns A boolean indicating if the signature matches
@@ -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": "21f25a09b87809102b0214544d2c5396eeb5872e",
7
- "version": "18.0.0-RC.0"
6
+ "commitHash": "801b9525f497845e778696ccac8df3a7b0f299d8",
7
+ "version": "19.0.0"
8
8
  };
9
- //# sourceMappingURL=version.js.map