@taquito/utils 20.0.2-beta.0 → 20.0.2-beta.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.format = void 0;
3
+ exports.format = format;
4
4
  const bignumber_js_1 = require("bignumber.js");
5
5
  const TZ_DECIMALS = 6;
6
6
  const MTZ_DECIMALS = 3;
@@ -24,4 +24,3 @@ function format(from = 'mutez', to = 'mutez', amount) {
24
24
  .multipliedBy(Math.pow(10, getDecimal(from)))
25
25
  .dividedBy(Math.pow(10, getDecimal(to)));
26
26
  }
27
- exports.format = format;
@@ -18,7 +18,26 @@ 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.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;
21
+ exports.getPkhfromPk = exports.buf2hex = exports.mic2arr = exports.mergebuf = exports.hex2buf = exports.b58cdecode = exports.format = exports.validatePkAndExtractPrefix = exports.verifySignature = exports.prefixLength = exports.Prefix = exports.prefix = exports.VERSION = void 0;
22
+ exports.encodeExpr = encodeExpr;
23
+ exports.encodeOpHash = encodeOpHash;
24
+ exports.b58cencode = b58cencode;
25
+ exports.b58decode = b58decode;
26
+ exports.b58decodeL2Address = b58decodeL2Address;
27
+ exports.encodePubKey = encodePubKey;
28
+ exports.encodeAddress = encodeAddress;
29
+ exports.encodeL2Address = encodeL2Address;
30
+ exports.encodeKey = encodeKey;
31
+ exports.encodeKeyHash = encodeKeyHash;
32
+ exports.char2Bytes = char2Bytes;
33
+ exports.stringToBytes = stringToBytes;
34
+ exports.bytes2Char = bytes2Char;
35
+ exports.bytesToString = bytesToString;
36
+ exports.hex2Bytes = hex2Bytes;
37
+ exports.toHexBuf = toHexBuf;
38
+ exports.numToHexBuffer = numToHexBuffer;
39
+ exports.num2PaddedHex = num2PaddedHex;
40
+ exports.stripHexPrefix = stripHexPrefix;
22
41
  /*
23
42
  * Some code in this file is originally from sotez and eztz
24
43
  * Copyright (c) 2018 Andrew Kishino
@@ -56,7 +75,6 @@ function encodeExpr(value) {
56
75
  const blakeHash = blakejs_1.default.blake2b((0, exports.hex2buf)(value), undefined, 32);
57
76
  return b58cencode(blakeHash, constants_1.prefix['expr']);
58
77
  }
59
- exports.encodeExpr = encodeExpr;
60
78
  /**
61
79
  *
62
80
  * @description Return the operation hash of a signed operation
@@ -66,7 +84,6 @@ function encodeOpHash(value) {
66
84
  const blakeHash = blakejs_1.default.blake2b((0, exports.hex2buf)(value), undefined, 32);
67
85
  return b58cencode(blakeHash, constants_1.prefix.o);
68
86
  }
69
- exports.encodeOpHash = encodeOpHash;
70
87
  /**
71
88
  *
72
89
  * @description Base58 encode a string or a Uint8Array and append a prefix to it
@@ -81,7 +98,6 @@ function b58cencode(value, prefix) {
81
98
  n.set(payloadAr, prefix.length);
82
99
  return bs58check_1.default.encode(buffer_1.Buffer.from(n.buffer));
83
100
  }
84
- exports.b58cencode = b58cencode;
85
101
  /**
86
102
  *
87
103
  * @description Base58 decode a string and remove the prefix from it
@@ -115,7 +131,6 @@ function b58decode(payload) {
115
131
  return '01' + (0, exports.buf2hex)(buf.slice(3, 42)) + '00';
116
132
  }
117
133
  }
118
- exports.b58decode = b58decode;
119
134
  /**
120
135
  *
121
136
  * @description b58 decode a string without predefined prefix
@@ -127,7 +142,6 @@ function b58decodeL2Address(payload) {
127
142
  // tz4 address currently
128
143
  return (0, exports.buf2hex)(buf.slice(3, 42));
129
144
  }
130
- exports.b58decodeL2Address = b58decodeL2Address;
131
145
  /**
132
146
  *
133
147
  * @description Base58 encode an address using predefined prefix
@@ -146,7 +160,6 @@ function encodePubKey(value) {
146
160
  }
147
161
  return b58cencode(value.substring(2, 42), constants_1.prefix.KT);
148
162
  }
149
- exports.encodePubKey = encodePubKey;
150
163
  /**
151
164
  *
152
165
  * @description Base58 encode an address using predefined prefix (tz1, tz2, tz3, or KT1 without annotation)
@@ -167,7 +180,6 @@ function encodeAddress(value) {
167
180
  }
168
181
  return b58cencode(value.substring(2, 42), constants_1.prefix.KT);
169
182
  }
170
- exports.encodeAddress = encodeAddress;
171
183
  /**
172
184
  *
173
185
  * @description Base58 encode an address without predefined prefix
@@ -177,7 +189,6 @@ exports.encodeAddress = encodeAddress;
177
189
  function encodeL2Address(value) {
178
190
  return b58cencode(value, constants_1.prefix.tz4);
179
191
  }
180
- exports.encodeL2Address = encodeL2Address;
181
192
  /**
182
193
  *
183
194
  * @description Base58 encode a key according to its prefix
@@ -194,7 +205,6 @@ function encodeKey(value) {
194
205
  return b58cencode(value.substring(2), pref[value.substring(0, 2)]);
195
206
  }
196
207
  }
197
- exports.encodeKey = encodeKey;
198
208
  /**
199
209
  *
200
210
  * @description Base58 encode a key hash according to its prefix
@@ -211,7 +221,6 @@ function encodeKeyHash(value) {
211
221
  return b58cencode(value.substring(2), pref[value.substring(0, 2)]);
212
222
  }
213
223
  }
214
- exports.encodeKeyHash = encodeKeyHash;
215
224
  /**
216
225
  *
217
226
  * @description Convert an hex string to a Uint8Array
@@ -370,7 +379,6 @@ exports.getPkhfromPk = getPkhfromPk;
370
379
  function char2Bytes(str) {
371
380
  return buffer_1.Buffer.from(str, 'utf8').toString('hex');
372
381
  }
373
- exports.char2Bytes = char2Bytes;
374
382
  /**
375
383
  *
376
384
  * @description Convert a string to a byte string representation
@@ -380,7 +388,6 @@ exports.char2Bytes = char2Bytes;
380
388
  function stringToBytes(str) {
381
389
  return buffer_1.Buffer.from(str, 'utf8').toString('hex');
382
390
  }
383
- exports.stringToBytes = stringToBytes;
384
391
  /**
385
392
  *
386
393
  * @description Convert bytes to a string
@@ -391,7 +398,6 @@ exports.stringToBytes = stringToBytes;
391
398
  function bytes2Char(hex) {
392
399
  return buffer_1.Buffer.from((0, exports.hex2buf)(hex)).toString('utf8');
393
400
  }
394
- exports.bytes2Char = bytes2Char;
395
401
  /**
396
402
  *
397
403
  * @description Convert byte string representation to string
@@ -401,7 +407,6 @@ exports.bytes2Char = bytes2Char;
401
407
  function bytesToString(hex) {
402
408
  return buffer_1.Buffer.from((0, exports.hex2buf)(hex)).toString('utf8');
403
409
  }
404
- exports.bytesToString = bytesToString;
405
410
  /**
406
411
  *
407
412
  * @description Convert hex string/UintArray/Buffer to bytes
@@ -415,7 +420,6 @@ function hex2Bytes(hex) {
415
420
  }
416
421
  return buffer_1.Buffer.from(hexDigits, 'hex');
417
422
  }
418
- exports.hex2Bytes = hex2Bytes;
419
423
  /**
420
424
  *
421
425
  * @description Converts a number or Bignumber to hexadecimal string
@@ -425,11 +429,9 @@ exports.hex2Bytes = hex2Bytes;
425
429
  function toHexBuf(val, bitLength = 8) {
426
430
  return buffer_1.Buffer.from(num2PaddedHex(val, bitLength), 'hex');
427
431
  }
428
- exports.toHexBuf = toHexBuf;
429
432
  function numToHexBuffer(val, bitLength = 8) {
430
433
  return buffer_1.Buffer.from(num2PaddedHex(val, bitLength), 'hex');
431
434
  }
432
- exports.numToHexBuffer = numToHexBuffer;
433
435
  /**
434
436
  *
435
437
  * @description Converts a number or BigNumber to a padded hexadecimal string
@@ -454,7 +456,6 @@ function num2PaddedHex(val, bitLength = 8) {
454
456
  return twosCompliment.toString(16);
455
457
  }
456
458
  }
457
- exports.num2PaddedHex = num2PaddedHex;
458
459
  function padHexWithZero(hex, targetLength) {
459
460
  const padString = '0';
460
461
  if (hex.length >= targetLength) {
@@ -474,4 +475,3 @@ function padHexWithZero(hex, targetLength) {
474
475
  function stripHexPrefix(hex) {
475
476
  return hex.startsWith('0x') ? hex.slice(2) : hex;
476
477
  }
477
- exports.stripHexPrefix = stripHexPrefix;
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSmartRollupAddress = exports.invalidDetail = exports.validateSpendingKey = exports.validateBlock = exports.validateProtocol = exports.validateOperation = exports.validatePublicKey = exports.validateSignature = exports.validateKeyHash = exports.validateContractAddress = exports.validateChain = exports.validateAddress = exports.isValidPrefix = exports.ValidationResult = void 0;
3
+ exports.ValidationResult = void 0;
4
+ exports.isValidPrefix = isValidPrefix;
5
+ exports.validateAddress = validateAddress;
6
+ exports.validateChain = validateChain;
7
+ exports.validateContractAddress = validateContractAddress;
8
+ exports.validateKeyHash = validateKeyHash;
9
+ exports.validateSignature = validateSignature;
10
+ exports.validatePublicKey = validatePublicKey;
11
+ exports.validateOperation = validateOperation;
12
+ exports.validateProtocol = validateProtocol;
13
+ exports.validateBlock = validateBlock;
14
+ exports.validateSpendingKey = validateSpendingKey;
15
+ exports.invalidDetail = invalidDetail;
16
+ exports.validateSmartRollupAddress = validateSmartRollupAddress;
4
17
  const constants_1 = require("./constants");
5
18
  const bs58check_1 = require("bs58check");
6
19
  var ValidationResult;
@@ -16,7 +29,6 @@ function isValidPrefix(value) {
16
29
  }
17
30
  return value in constants_1.prefix;
18
31
  }
19
- exports.isValidPrefix = isValidPrefix;
20
32
  /**
21
33
  * @description This function is called by the validation functions ([[validateAddress]], [[validateChain]], [[validateContractAddress]], [[validateKeyHash]], [[validateSignature]], [[validatePublicKey]]).
22
34
  * Verify if the value has the right prefix or return `NO_PREFIX_MATCHED`,
@@ -81,7 +93,6 @@ const smartRollupPrefix = [constants_1.Prefix.SR1];
81
93
  function validateAddress(value) {
82
94
  return validatePrefixedValue(value, [...implicitPrefix, ...contractPrefix, ...smartRollupPrefix]);
83
95
  }
84
- exports.validateAddress = validateAddress;
85
96
  /**
86
97
  * @description Used to check if a chain id is valid.
87
98
  *
@@ -100,7 +111,6 @@ exports.validateAddress = validateAddress;
100
111
  function validateChain(value) {
101
112
  return validatePrefixedValue(value, [constants_1.Prefix.NET]);
102
113
  }
103
- exports.validateChain = validateChain;
104
114
  /**
105
115
  * @description Used to check if a contract address is valid.
106
116
  *
@@ -119,7 +129,6 @@ exports.validateChain = validateChain;
119
129
  function validateContractAddress(value) {
120
130
  return validatePrefixedValue(value, contractPrefix);
121
131
  }
122
- exports.validateContractAddress = validateContractAddress;
123
132
  /**
124
133
  * @description Used to check if a key hash is valid.
125
134
  *
@@ -138,7 +147,6 @@ exports.validateContractAddress = validateContractAddress;
138
147
  function validateKeyHash(value) {
139
148
  return validatePrefixedValue(value, implicitPrefix);
140
149
  }
141
- exports.validateKeyHash = validateKeyHash;
142
150
  /**
143
151
  * @description Used to check if a signature is valid.
144
152
  *
@@ -157,7 +165,6 @@ exports.validateKeyHash = validateKeyHash;
157
165
  function validateSignature(value) {
158
166
  return validatePrefixedValue(value, signaturePrefix);
159
167
  }
160
- exports.validateSignature = validateSignature;
161
168
  /**
162
169
  * @description Used to check if a public key is valid.
163
170
  *
@@ -176,7 +183,6 @@ exports.validateSignature = validateSignature;
176
183
  function validatePublicKey(value) {
177
184
  return validatePrefixedValue(value, pkPrefix);
178
185
  }
179
- exports.validatePublicKey = validatePublicKey;
180
186
  /**
181
187
  * @description Used to check if an operation hash is valid.
182
188
  *
@@ -195,7 +201,6 @@ exports.validatePublicKey = validatePublicKey;
195
201
  function validateOperation(value) {
196
202
  return validatePrefixedValue(value, operationPrefix);
197
203
  }
198
- exports.validateOperation = validateOperation;
199
204
  /**
200
205
  * @description Used to check if a protocol hash is valid.
201
206
  *
@@ -214,7 +219,6 @@ exports.validateOperation = validateOperation;
214
219
  function validateProtocol(value) {
215
220
  return validatePrefixedValue(value, protocolPrefix);
216
221
  }
217
- exports.validateProtocol = validateProtocol;
218
222
  /**
219
223
  * @description Used to check if a block hash is valid.
220
224
  *
@@ -233,7 +237,6 @@ exports.validateProtocol = validateProtocol;
233
237
  function validateBlock(value) {
234
238
  return validatePrefixedValue(value, blockPrefix);
235
239
  }
236
- exports.validateBlock = validateBlock;
237
240
  /**
238
241
  * @description Used to check if a spending key is valid.
239
242
  * @returns 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
@@ -242,7 +245,6 @@ exports.validateBlock = validateBlock;
242
245
  function validateSpendingKey(value) {
243
246
  return validatePrefixedValue(value, [constants_1.Prefix.SASK]);
244
247
  }
245
- exports.validateSpendingKey = validateSpendingKey;
246
248
  function invalidDetail(validation) {
247
249
  switch (validation) {
248
250
  case ValidationResult.NO_PREFIX_MATCHED:
@@ -255,8 +257,6 @@ function invalidDetail(validation) {
255
257
  return '';
256
258
  }
257
259
  }
258
- exports.invalidDetail = invalidDetail;
259
260
  function validateSmartRollupAddress(value) {
260
261
  return validatePrefixedValue(value, [...smartRollupPrefix]);
261
262
  }
262
- exports.validateSmartRollupAddress = validateSmartRollupAddress;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validatePkAndExtractPrefix = exports.verifySignature = void 0;
3
+ exports.verifySignature = verifySignature;
4
+ exports.validatePkAndExtractPrefix = validatePkAndExtractPrefix;
4
5
  const ed25519_1 = require("@stablelib/ed25519");
5
6
  const blake2b_1 = require("@stablelib/blake2b");
6
7
  const taquito_utils_1 = require("./taquito-utils");
@@ -49,7 +50,6 @@ function verifySignature(messageBytes, publicKey, signature, watermark) {
49
50
  return false;
50
51
  }
51
52
  }
52
- exports.verifySignature = verifySignature;
53
53
  function validateMessageNotEmpty(message) {
54
54
  if (message === '') {
55
55
  throw new core_1.InvalidMessageError(message, `can't be empty`);
@@ -67,7 +67,6 @@ function validatePkAndExtractPrefix(publicKey) {
67
67
  }
68
68
  return pkPrefix;
69
69
  }
70
- exports.validatePkAndExtractPrefix = validatePkAndExtractPrefix;
71
70
  function validateSigAndExtractPrefix(signature) {
72
71
  const signaturePrefix = signature.startsWith('sig')
73
72
  ? signature.substring(0, 3)
@@ -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": "8c7737cb6ad36ea87f5f8833e012a9d472832790",
7
- "version": "20.0.2-beta.0"
6
+ "commitHash": "943d5fd11790da35f4a3e6ecfcaae3c4f0399a97",
7
+ "version": "20.0.2-beta.2"
8
8
  };
@@ -496,8 +496,8 @@ function validateSmartRollupAddress(value) {
496
496
 
497
497
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
498
498
  const VERSION = {
499
- "commitHash": "8c7737cb6ad36ea87f5f8833e012a9d472832790",
500
- "version": "20.0.2-beta.0"
499
+ "commitHash": "943d5fd11790da35f4a3e6ecfcaae3c4f0399a97",
500
+ "version": "20.0.2-beta.2"
501
501
  };
502
502
 
503
503
  const TZ_DECIMALS = 6;
@@ -491,8 +491,8 @@
491
491
 
492
492
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
493
493
  const VERSION = {
494
- "commitHash": "8c7737cb6ad36ea87f5f8833e012a9d472832790",
495
- "version": "20.0.2-beta.0"
494
+ "commitHash": "943d5fd11790da35f4a3e6ecfcaae3c4f0399a97",
495
+ "version": "20.0.2-beta.2"
496
496
  };
497
497
 
498
498
  const TZ_DECIMALS = 6;
@@ -31,9 +31,9 @@ export declare enum Prefix {
31
31
  ID = "id",
32
32
  EXPR = "expr",
33
33
  TZ = "TZ",
34
- VH = "vh",
35
- SASK = "sask",
36
- ZET1 = "zet1",
34
+ VH = "vh",// block_payload_hash
35
+ SASK = "sask",// sapling_spending_key
36
+ ZET1 = "zet1",// sapling_address
37
37
  SR1 = "sr1",
38
38
  SRC1 = "src1",
39
39
  SH = "sh"
@@ -2,7 +2,6 @@
2
2
  * @packageDocumentation
3
3
  * @module @taquito/utils
4
4
  */
5
- /// <reference types="node" />
6
5
  import { Buffer } from 'buffer';
7
6
  import BigNumber from 'bignumber.js';
8
7
  export * from './validators';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/utils",
3
- "version": "20.0.2-beta.0",
3
+ "version": "20.0.2-beta.2",
4
4
  "description": "converts michelson data and types into convenient JS/TS objects",
5
5
  "keywords": [
6
6
  "tezos",
@@ -64,42 +64,42 @@
64
64
  "dependencies": {
65
65
  "@stablelib/blake2b": "^1.0.1",
66
66
  "@stablelib/ed25519": "^1.0.3",
67
- "@taquito/core": "^20.0.2-beta.0",
68
- "@types/bs58check": "^2.1.0",
67
+ "@taquito/core": "^20.0.2-beta.2",
68
+ "@types/bs58check": "^2.1.2",
69
69
  "bignumber.js": "^9.1.2",
70
70
  "blakejs": "^1.2.1",
71
71
  "bs58check": "^3.0.1",
72
72
  "buffer": "^6.0.3",
73
- "elliptic": "^6.5.4",
73
+ "elliptic": "^6.5.6",
74
74
  "typedarray-to-buffer": "^4.0.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@types/bluebird": "^3.5.40",
78
- "@types/elliptic": "^6.4.15",
79
- "@types/jest": "^29.5.5",
80
- "@types/node": "^20",
81
- "@typescript-eslint/eslint-plugin": "^6.8.0",
82
- "@typescript-eslint/parser": "^6.8.0",
77
+ "@types/bluebird": "^3.5.42",
78
+ "@types/elliptic": "^6.4.18",
79
+ "@types/jest": "^29.5.12",
80
+ "@types/node": "^22",
81
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
82
+ "@typescript-eslint/parser": "^6.21.0",
83
83
  "colors": "^1.4.0",
84
84
  "coveralls": "^3.1.1",
85
85
  "cross-env": "^7.0.3",
86
- "eslint": "^8.51.0",
86
+ "eslint": "^8.57.0",
87
87
  "jest": "^29.7.0",
88
88
  "jest-config": "^29.7.0",
89
- "lint-staged": "^14.0.1",
89
+ "lint-staged": "^15.2.7",
90
90
  "lodash.camelcase": "^4.3.0",
91
- "prettier": "^3.0.3",
91
+ "prettier": "^3.3.3",
92
92
  "prompt": "^1.3.0",
93
- "replace-in-file": "^7.0.1",
94
- "rimraf": "^5.0.5",
95
- "rollup": "^4.1.4",
93
+ "replace-in-file": "^8.1.0",
94
+ "rimraf": "^6.0.1",
95
+ "rollup": "^4.19.1",
96
96
  "rollup-plugin-json": "^4.0.0",
97
97
  "rollup-plugin-typescript2": "^0.36.0",
98
98
  "shelljs": "^0.8.5",
99
- "ts-jest": "^29.1.1",
100
- "ts-node": "^10.9.1",
99
+ "ts-jest": "^29.2.3",
100
+ "ts-node": "^10.9.2",
101
101
  "ts-toolbelt": "^9.6.0",
102
- "typescript": "~5.2.2"
102
+ "typescript": "~5.5.4"
103
103
  },
104
- "gitHead": "668e57eda3f7408503646f564346704d0f979327"
104
+ "gitHead": "f0f9e4d22a374c72913abbb1991b0e5b34f4c978"
105
105
  }