@taquito/utils 24.2.0-beta.1 → 24.3.0-beta.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.
- package/dist/lib/constants.js +3 -3
- package/dist/lib/encoding.js +23 -23
- package/dist/lib/errors.js +2 -2
- package/dist/lib/validators.js +13 -13
- package/dist/lib/verify-signature.js +7 -7
- package/dist/lib/version.js +2 -2
- package/dist/taquito-utils.es6.js +50 -50
- package/dist/taquito-utils.umd.js +50 -50
- package/dist/types/constants.d.ts +3 -3
- package/dist/types/encoding.d.ts +30 -30
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/validators.d.ts +11 -11
- package/dist/types/verify-signature.d.ts +2 -2
- package/package.json +23 -10
- package/LICENSE +0 -202
|
@@ -1987,7 +1987,7 @@
|
|
|
1987
1987
|
|
|
1988
1988
|
// ref https://gitlab.com/tezos/tezos/-/blob/master/src/lib_crypto/base58.ml
|
|
1989
1989
|
/**
|
|
1990
|
-
*
|
|
1990
|
+
* base58 name to prefix mapping
|
|
1991
1991
|
*/
|
|
1992
1992
|
exports.PrefixV2 = void 0;
|
|
1993
1993
|
(function (PrefixV2) {
|
|
@@ -2054,7 +2054,7 @@
|
|
|
2054
2054
|
PrefixV2["SlotHeader"] = "sh";
|
|
2055
2055
|
})(exports.PrefixV2 || (exports.PrefixV2 = {}));
|
|
2056
2056
|
/**
|
|
2057
|
-
*
|
|
2057
|
+
* base58 prefix to bytes mapping
|
|
2058
2058
|
*/
|
|
2059
2059
|
const prefixV2 = {
|
|
2060
2060
|
[exports.PrefixV2.BlockHash]: new Uint8Array([1, 52]),
|
|
@@ -2120,7 +2120,7 @@
|
|
|
2120
2120
|
[exports.PrefixV2.SlotHeader]: new Uint8Array([2, 116, 180]),
|
|
2121
2121
|
};
|
|
2122
2122
|
/**
|
|
2123
|
-
*
|
|
2123
|
+
* base58 prefix to payload length mapping
|
|
2124
2124
|
*/
|
|
2125
2125
|
const payloadLength = {
|
|
2126
2126
|
[exports.PrefixV2.BlockHash]: 32,
|
|
@@ -2196,7 +2196,7 @@
|
|
|
2196
2196
|
* Copyright (c) 2017 Stephen Andrews
|
|
2197
2197
|
*/
|
|
2198
2198
|
/**
|
|
2199
|
-
*
|
|
2199
|
+
* list of prefixes that can be used to decode an address
|
|
2200
2200
|
*/
|
|
2201
2201
|
const addressPrefixes = [
|
|
2202
2202
|
exports.PrefixV2.P256PublicKeyHash,
|
|
@@ -2208,7 +2208,7 @@
|
|
|
2208
2208
|
// PrefixV2.ZkRollupHash,
|
|
2209
2209
|
];
|
|
2210
2210
|
/**
|
|
2211
|
-
*
|
|
2211
|
+
* list of prefixes that can be used to decode a public key
|
|
2212
2212
|
*/
|
|
2213
2213
|
const publicKeyPrefixes = [
|
|
2214
2214
|
exports.PrefixV2.P256PublicKey,
|
|
@@ -2217,7 +2217,7 @@
|
|
|
2217
2217
|
exports.PrefixV2.BLS12_381PublicKey,
|
|
2218
2218
|
];
|
|
2219
2219
|
/**
|
|
2220
|
-
*
|
|
2220
|
+
* list of prefixes that can be used to decode a public key hash
|
|
2221
2221
|
*/
|
|
2222
2222
|
const publicKeyHashPrefixes = [
|
|
2223
2223
|
exports.PrefixV2.P256PublicKeyHash,
|
|
@@ -2226,7 +2226,7 @@
|
|
|
2226
2226
|
exports.PrefixV2.BLS12_381PublicKeyHash,
|
|
2227
2227
|
];
|
|
2228
2228
|
/**
|
|
2229
|
-
*
|
|
2229
|
+
* list of prefixes that can be used to decode a signature
|
|
2230
2230
|
*/
|
|
2231
2231
|
const signaturePrefixes = [
|
|
2232
2232
|
exports.PrefixV2.P256Signature,
|
|
@@ -2398,7 +2398,7 @@
|
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
2400
|
/**
|
|
2401
|
-
*
|
|
2401
|
+
* Gets Tezos address (PKH) from Public Key
|
|
2402
2402
|
* @param publicKey Base58 Public Key
|
|
2403
2403
|
* @returns A string of the Tezos address (PKH) that was derived from the given Public Key
|
|
2404
2404
|
* @example getPkhfromPk('edpkuNjKKT48xBoT5asPrWdmuM1Yw8D93MwgFgVvtca8jb5pstzaCh') // return 'tz2MVED1t9Jery77Bwm1m5YhUx8Wp5KWWRQe'
|
|
@@ -2426,7 +2426,7 @@
|
|
|
2426
2426
|
return b58Encode(hashed, pkhPre);
|
|
2427
2427
|
}
|
|
2428
2428
|
/**
|
|
2429
|
-
*
|
|
2429
|
+
* Add the prefix to a hex string or Uint8Array and Base58 encode it
|
|
2430
2430
|
* @param value Value to Base58 encode
|
|
2431
2431
|
* @param pre prefix ID to append to the encoded string
|
|
2432
2432
|
* @example b58Encode('e96b9f8b19af9c7ffa0c0480e1977b295850961f', PrefixV2.Ed25519PublicKeyHash) // returns 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'
|
|
@@ -2440,7 +2440,7 @@
|
|
|
2440
2440
|
return bs58check.encode(toBuffer(n));
|
|
2441
2441
|
}
|
|
2442
2442
|
/**
|
|
2443
|
-
*
|
|
2443
|
+
* Parse binary public key and return Base58 representation
|
|
2444
2444
|
* @param value Binary key data
|
|
2445
2445
|
* @returns return prefixed public key
|
|
2446
2446
|
* @example encodeKey('02033aba7da4a2e7b5dd9f074555c118829aff16213ea1b65859686bd5fcfeaf3616') // return 'p2pk66xmhjiN7LpfrDGFwpxPtJxkLtPjQ6HUxJbKmRbxSR7RMpamDwi'
|
|
@@ -2473,7 +2473,7 @@
|
|
|
2473
2473
|
return b58Encode(buf.slice(1), pre);
|
|
2474
2474
|
}
|
|
2475
2475
|
/**
|
|
2476
|
-
*
|
|
2476
|
+
* Parse binary public key hash and return Base58 representation
|
|
2477
2477
|
* @param value Key hash to parse
|
|
2478
2478
|
* @returns return prefixed public key hash
|
|
2479
2479
|
* @example encodeKeyHash('0001907d6a7e9f084df840d6e67ffa8db5464f87d4d1') // return 'tz2MVED1t9Jery77Bwm1m5YhUx8Wp5KWWRQe'
|
|
@@ -2506,7 +2506,7 @@
|
|
|
2506
2506
|
return b58Encode(buf.slice(1, 21), pre);
|
|
2507
2507
|
}
|
|
2508
2508
|
/**
|
|
2509
|
-
*
|
|
2509
|
+
* Parse binary Contract ID and return Base58 representation
|
|
2510
2510
|
* @param value Address to parse (tz1, tz2, tz3, KT1, or sr1).
|
|
2511
2511
|
* @example encodeAddress('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f') // return 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'
|
|
2512
2512
|
*/
|
|
@@ -2532,7 +2532,7 @@
|
|
|
2532
2532
|
}
|
|
2533
2533
|
}
|
|
2534
2534
|
/**
|
|
2535
|
-
*
|
|
2535
|
+
* Base58 encode an address without predefined prefix
|
|
2536
2536
|
* @param value Address to base58 encode (tz4) hex dec
|
|
2537
2537
|
* @returns return address
|
|
2538
2538
|
* @example encodeBlsAddress('af2dc3c40667abc0e89c0ef40171d22aed08d5eb') // return 'tz4QyWfEiv56CVDATV3DT3CDVhPaMKif2Ce8'
|
|
@@ -2541,7 +2541,7 @@
|
|
|
2541
2541
|
return b58Encode(value, exports.PrefixV2.BLS12_381PublicKeyHash);
|
|
2542
2542
|
}
|
|
2543
2543
|
/**
|
|
2544
|
-
*
|
|
2544
|
+
* convert a fragment of Michelson code in hex string to an 'expr' prefix + base58 encoded BLAKE2b hash string
|
|
2545
2545
|
* @param value a fragment of Michelson code in hex string
|
|
2546
2546
|
* @returns return 'expr' prefix + base58 encoded BLAKE2b hash
|
|
2547
2547
|
* @example encodeExpr('050a000000160000b2e19a9e74440d86c59f13dab8a18ff873e889ea') // return 'exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN'
|
|
@@ -2551,7 +2551,7 @@
|
|
|
2551
2551
|
return b58Encode(blakeHash, exports.PrefixV2.ScriptExpr);
|
|
2552
2552
|
}
|
|
2553
2553
|
/**
|
|
2554
|
-
*
|
|
2554
|
+
* convert a signed operation in hex string to an 'op' prefix + base58 encoded BLAKE2b hash string
|
|
2555
2555
|
* @param value signed operation in hex string
|
|
2556
2556
|
* @returns return 'op' prefix + base58 encoded BLAKE2b hash
|
|
2557
2557
|
* @example encodeOpHash('0f185d8a30061e8134c162dbb7a6c3ab8f5fdb153363ccd6149b49a33481156a6c00b2e19a9e74440d86c59f13dab8a18ff873e889eaa304ab05da13000001f1585a7384f36e45fb43dc37e8ce172bced3e05700ff0000000002002110c033f3a990c2e46a3d6054ecc2f74072aae7a34b5ac4d9ce9edc11c2410a97695682108951786f05b361da03b97245dc9897e1955e08b5b8d9e153b0bdeb0d') // return 'opapqvVXmebRTCFd2GQFydr4tJj3V5QocQuTmuhbatcHm4Seo2t'
|
|
@@ -2561,7 +2561,7 @@
|
|
|
2561
2561
|
return b58Encode(blakeHash, exports.PrefixV2.OperationHash);
|
|
2562
2562
|
}
|
|
2563
2563
|
/**
|
|
2564
|
-
*
|
|
2564
|
+
* Convert an hex string to a Uint8Array
|
|
2565
2565
|
* @param hex Hex string to convert
|
|
2566
2566
|
* @throws {@link ValueConversionError}
|
|
2567
2567
|
*/
|
|
@@ -2586,7 +2586,7 @@
|
|
|
2586
2586
|
return res;
|
|
2587
2587
|
}
|
|
2588
2588
|
/**
|
|
2589
|
-
*
|
|
2589
|
+
* Merge 2 buffers together
|
|
2590
2590
|
* @param b1 First buffer
|
|
2591
2591
|
* @param b2 Second buffer
|
|
2592
2592
|
*/
|
|
@@ -2597,7 +2597,7 @@
|
|
|
2597
2597
|
return r;
|
|
2598
2598
|
}
|
|
2599
2599
|
/**
|
|
2600
|
-
*
|
|
2600
|
+
* Flatten a michelson json representation to an array
|
|
2601
2601
|
* @param s michelson json
|
|
2602
2602
|
*/
|
|
2603
2603
|
function mic2arr(s) {
|
|
@@ -2651,8 +2651,8 @@
|
|
|
2651
2651
|
return ret;
|
|
2652
2652
|
}
|
|
2653
2653
|
/**
|
|
2654
|
-
*
|
|
2655
|
-
* @param
|
|
2654
|
+
* Convert a Uint8Array to an hex string
|
|
2655
|
+
* @param bytes Uint8Array to convert
|
|
2656
2656
|
*/
|
|
2657
2657
|
function buf2hex(bytes) {
|
|
2658
2658
|
return Array.from(bytes)
|
|
@@ -2660,21 +2660,21 @@
|
|
|
2660
2660
|
.join('');
|
|
2661
2661
|
}
|
|
2662
2662
|
/**
|
|
2663
|
-
*
|
|
2663
|
+
* Convert a string to a byte string representation
|
|
2664
2664
|
* @param str String to convert
|
|
2665
2665
|
*/
|
|
2666
2666
|
function stringToBytes(str) {
|
|
2667
2667
|
return Buffer.from(str, 'utf8').toString('hex');
|
|
2668
2668
|
}
|
|
2669
2669
|
/**
|
|
2670
|
-
*
|
|
2670
|
+
* Convert byte string representation to string
|
|
2671
2671
|
* @param hex byte string to convert
|
|
2672
2672
|
*/
|
|
2673
2673
|
function bytesToString(hex) {
|
|
2674
2674
|
return Buffer.from(hex2buf(hex)).toString('utf8');
|
|
2675
2675
|
}
|
|
2676
2676
|
/**
|
|
2677
|
-
*
|
|
2677
|
+
* Convert hex string/UintArray/Buffer to bytes
|
|
2678
2678
|
* @param hex String value to convert to bytes
|
|
2679
2679
|
*/
|
|
2680
2680
|
function hex2Bytes(hex) {
|
|
@@ -2685,7 +2685,7 @@
|
|
|
2685
2685
|
return Buffer.from(hexDigits, 'hex');
|
|
2686
2686
|
}
|
|
2687
2687
|
/**
|
|
2688
|
-
*
|
|
2688
|
+
* Converts a number or Bignumber to hexadecimal string
|
|
2689
2689
|
* @param val The value that will be converted to a hexadecimal string value
|
|
2690
2690
|
*/
|
|
2691
2691
|
function toHexBuf(val, bitLength = 8) {
|
|
@@ -2695,7 +2695,7 @@
|
|
|
2695
2695
|
return Buffer.from(num2PaddedHex(val, bitLength), 'hex');
|
|
2696
2696
|
}
|
|
2697
2697
|
/**
|
|
2698
|
-
*
|
|
2698
|
+
* Converts a number or BigNumber to a padded hexadecimal string
|
|
2699
2699
|
* @param val The value that will be converted into a padded hexadecimal string value
|
|
2700
2700
|
* @param bitLength The length of bits
|
|
2701
2701
|
*
|
|
@@ -2729,7 +2729,7 @@
|
|
|
2729
2729
|
}
|
|
2730
2730
|
/**
|
|
2731
2731
|
*
|
|
2732
|
-
*
|
|
2732
|
+
* Strips the first 2 characters of a hex string (0x)
|
|
2733
2733
|
*
|
|
2734
2734
|
* @param hex string to strip prefix from
|
|
2735
2735
|
*/
|
|
@@ -2755,7 +2755,7 @@
|
|
|
2755
2755
|
}
|
|
2756
2756
|
|
|
2757
2757
|
/**
|
|
2758
|
-
*
|
|
2758
|
+
* Used to check if a value has one of the allowed prefixes.
|
|
2759
2759
|
* @returns true if the value has one of the allowed prefixes, false otherwise
|
|
2760
2760
|
* @example
|
|
2761
2761
|
* ```
|
|
@@ -2769,7 +2769,7 @@
|
|
|
2769
2769
|
return validatePrefixedValue(value, prefixes) === core.ValidationResult.VALID;
|
|
2770
2770
|
}
|
|
2771
2771
|
/**
|
|
2772
|
-
*
|
|
2772
|
+
* This function is called by the validation functions ([[validateAddress]], [[validateChain]], [[validateContractAddress]], [[validateKeyHash]], [[validateSignature]], [[validatePublicKey]]).
|
|
2773
2773
|
* Verify if the value can be decoded or return `1` (INVALID_CHECKSUM) / `5` (INVALID_ENCODING), then check if the prefix is valid or allowed or return `0` (NO_PREFIX_MATCHED) / `4` (PREFIX_NOT_ALLOWED)
|
|
2774
2774
|
* If all checks pass, return `3` (VALID).
|
|
2775
2775
|
* @param value Value to validate
|
|
@@ -2796,7 +2796,7 @@
|
|
|
2796
2796
|
return core.ValidationResult.VALID;
|
|
2797
2797
|
}
|
|
2798
2798
|
/**
|
|
2799
|
-
*
|
|
2799
|
+
* Used to check if an address or a contract address is valid.
|
|
2800
2800
|
*
|
|
2801
2801
|
* @returns
|
|
2802
2802
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2811,11 +2811,11 @@
|
|
|
2811
2811
|
* ```
|
|
2812
2812
|
*/
|
|
2813
2813
|
function validateAddress(value) {
|
|
2814
|
-
const [addr] = splitAddress(value
|
|
2814
|
+
const [addr] = splitAddress(value ?? '');
|
|
2815
2815
|
return validatePrefixedValue(addr, addressPrefixes);
|
|
2816
2816
|
}
|
|
2817
2817
|
/**
|
|
2818
|
-
*
|
|
2818
|
+
* Used to check if a chain id is valid.
|
|
2819
2819
|
*
|
|
2820
2820
|
* @returns
|
|
2821
2821
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2833,7 +2833,7 @@
|
|
|
2833
2833
|
return validatePrefixedValue(value, [exports.PrefixV2.ChainID]);
|
|
2834
2834
|
}
|
|
2835
2835
|
/**
|
|
2836
|
-
*
|
|
2836
|
+
* Used to check if a contract address is valid.
|
|
2837
2837
|
*
|
|
2838
2838
|
* @returns
|
|
2839
2839
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2851,7 +2851,7 @@
|
|
|
2851
2851
|
return validatePrefixedValue(value, [exports.PrefixV2.ContractHash]);
|
|
2852
2852
|
}
|
|
2853
2853
|
/**
|
|
2854
|
-
*
|
|
2854
|
+
* Used to check if a key hash is valid.
|
|
2855
2855
|
*
|
|
2856
2856
|
* @returns
|
|
2857
2857
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2869,7 +2869,7 @@
|
|
|
2869
2869
|
return validatePrefixedValue(value, publicKeyHashPrefixes);
|
|
2870
2870
|
}
|
|
2871
2871
|
/**
|
|
2872
|
-
*
|
|
2872
|
+
* Used to check if a signature is valid.
|
|
2873
2873
|
*
|
|
2874
2874
|
* @returns
|
|
2875
2875
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2887,7 +2887,7 @@
|
|
|
2887
2887
|
return validatePrefixedValue(value, signaturePrefixes);
|
|
2888
2888
|
}
|
|
2889
2889
|
/**
|
|
2890
|
-
*
|
|
2890
|
+
* Used to check if a public key is valid.
|
|
2891
2891
|
*
|
|
2892
2892
|
* @returns
|
|
2893
2893
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2905,7 +2905,7 @@
|
|
|
2905
2905
|
return validatePrefixedValue(value, publicKeyPrefixes);
|
|
2906
2906
|
}
|
|
2907
2907
|
/**
|
|
2908
|
-
*
|
|
2908
|
+
* Used to check if an operation hash is valid.
|
|
2909
2909
|
*
|
|
2910
2910
|
* @returns
|
|
2911
2911
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2923,7 +2923,7 @@
|
|
|
2923
2923
|
return validatePrefixedValue(value, [exports.PrefixV2.OperationHash]);
|
|
2924
2924
|
}
|
|
2925
2925
|
/**
|
|
2926
|
-
*
|
|
2926
|
+
* Used to check if a protocol hash is valid.
|
|
2927
2927
|
*
|
|
2928
2928
|
* @returns
|
|
2929
2929
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2941,7 +2941,7 @@
|
|
|
2941
2941
|
return validatePrefixedValue(value, [exports.PrefixV2.ProtocolHash]);
|
|
2942
2942
|
}
|
|
2943
2943
|
/**
|
|
2944
|
-
*
|
|
2944
|
+
* Used to check if a block hash is valid.
|
|
2945
2945
|
*
|
|
2946
2946
|
* @returns
|
|
2947
2947
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
@@ -2959,7 +2959,7 @@
|
|
|
2959
2959
|
return validatePrefixedValue(value, [exports.PrefixV2.BlockHash]);
|
|
2960
2960
|
}
|
|
2961
2961
|
/**
|
|
2962
|
-
*
|
|
2962
|
+
* Used to check if a spending key is valid.
|
|
2963
2963
|
* @returns
|
|
2964
2964
|
* 0 = NO_PREFIX_MATCHED, 1 = INVALID_CHECKSUM, 2 = INVALID_LENGTH, 3 = VALID, 4 = PREFIX_NOT_ALLOWED, 5 = INVALID_ENCODING, 6 = OTHER,
|
|
2965
2965
|
*
|
|
@@ -2973,21 +2973,21 @@
|
|
|
2973
2973
|
|
|
2974
2974
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
2975
2975
|
const VERSION = {
|
|
2976
|
-
"commitHash": "
|
|
2977
|
-
"version": "24.
|
|
2976
|
+
"commitHash": "27675679db6515e8b092195ef5c58c2c0ea5f5c8",
|
|
2977
|
+
"version": "24.3.0-beta.0"
|
|
2978
2978
|
};
|
|
2979
2979
|
|
|
2980
2980
|
const BLS12_381_DST = 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_';
|
|
2981
2981
|
const POP_DST = 'BLS_POP_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_';
|
|
2982
2982
|
/**
|
|
2983
|
-
*
|
|
2983
|
+
* Verify signature of a payload
|
|
2984
2984
|
* @param message The forged message including the magic byte (11 for block, 12 for preattestation, 13 for attestation, 3 for generic, 5 for the PACK format of michelson) in string or Uint8Array
|
|
2985
2985
|
* @param publicKey The public key to verify the signature against
|
|
2986
2986
|
* @param signature The signature to verify
|
|
2987
2987
|
* @param watermark Optional if not included in the message
|
|
2988
2988
|
* @param pop Optional if verifying proof of possession signature
|
|
2989
2989
|
* @returns A boolean indicating if the signature matches
|
|
2990
|
-
* @throws
|
|
2990
|
+
* @throws InvalidPublicKeyError | InvalidSignatureError | InvalidMessageError
|
|
2991
2991
|
* @example
|
|
2992
2992
|
* ```
|
|
2993
2993
|
* const message = '03d0c10e3ed11d7c6e3357f6ef335bab9e8f2bd54d0ce20c482e241191a6e4b8ce6c01be917311d9ac46959750e405d57e268e2ed9e174a80794fbd504e12a4a000141eb3781afed2f69679ff2bbe1c5375950b0e40d00ff000000005e05050505050507070100000024747a32526773486e74516b72794670707352466261313652546656503539684b72654a4d07070100000024747a315a6672455263414c42776d4171776f6e525859565142445439426a4e6a42484a750001';
|
|
@@ -3060,7 +3060,7 @@
|
|
|
3060
3060
|
try {
|
|
3061
3061
|
return ed25519.verify(publicKey, hash, sig);
|
|
3062
3062
|
}
|
|
3063
|
-
catch
|
|
3063
|
+
catch {
|
|
3064
3064
|
return false;
|
|
3065
3065
|
}
|
|
3066
3066
|
}
|
|
@@ -3069,7 +3069,7 @@
|
|
|
3069
3069
|
try {
|
|
3070
3070
|
return secp256k1.secp256k1.verify(sig, hash, publicKey);
|
|
3071
3071
|
}
|
|
3072
|
-
catch
|
|
3072
|
+
catch {
|
|
3073
3073
|
return false;
|
|
3074
3074
|
}
|
|
3075
3075
|
}
|
|
@@ -3078,7 +3078,7 @@
|
|
|
3078
3078
|
try {
|
|
3079
3079
|
return nist.p256.verify(sig, hash, publicKey);
|
|
3080
3080
|
}
|
|
3081
|
-
catch
|
|
3081
|
+
catch {
|
|
3082
3082
|
return false;
|
|
3083
3083
|
}
|
|
3084
3084
|
}
|
|
@@ -3088,7 +3088,7 @@
|
|
|
3088
3088
|
const point = bls.hash(msg, BLS12_381_DST);
|
|
3089
3089
|
return bls.verify(sig, point, publicKey);
|
|
3090
3090
|
}
|
|
3091
|
-
catch
|
|
3091
|
+
catch {
|
|
3092
3092
|
return false;
|
|
3093
3093
|
}
|
|
3094
3094
|
}
|
|
@@ -3097,14 +3097,14 @@
|
|
|
3097
3097
|
const point = bls.hash(msg, POP_DST);
|
|
3098
3098
|
return bls.verify(sig, point, publicKey);
|
|
3099
3099
|
}
|
|
3100
|
-
catch
|
|
3100
|
+
catch {
|
|
3101
3101
|
return false;
|
|
3102
3102
|
}
|
|
3103
3103
|
}
|
|
3104
3104
|
|
|
3105
3105
|
/**
|
|
3106
3106
|
* @category Error
|
|
3107
|
-
*
|
|
3107
|
+
* Error that indicates invalid protocol hash being passed or used
|
|
3108
3108
|
*/
|
|
3109
3109
|
class InvalidProtocolHashError extends core.ParameterValidationError {
|
|
3110
3110
|
constructor(protocolHash, errorDetails) {
|
|
@@ -3116,7 +3116,7 @@
|
|
|
3116
3116
|
}
|
|
3117
3117
|
/**
|
|
3118
3118
|
* @category Error
|
|
3119
|
-
*
|
|
3119
|
+
* Error that indicates unable to convert data type from one to another
|
|
3120
3120
|
*/
|
|
3121
3121
|
class ValueConversionError extends core.UnsupportedActionError {
|
|
3122
3122
|
constructor(value, desiredType) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* base58 name to prefix mapping
|
|
3
3
|
*/
|
|
4
4
|
export declare enum PrefixV2 {
|
|
5
5
|
BlockHash = "B",
|
|
@@ -65,13 +65,13 @@ export declare enum PrefixV2 {
|
|
|
65
65
|
SlotHeader = "sh"
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* base58 prefix to bytes mapping
|
|
69
69
|
*/
|
|
70
70
|
export declare const prefixV2: {
|
|
71
71
|
[key in PrefixV2]: Uint8Array;
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* base58 prefix to payload length mapping
|
|
75
75
|
*/
|
|
76
76
|
export declare const payloadLength: {
|
|
77
77
|
[key in PrefixV2]: number;
|
package/dist/types/encoding.d.ts
CHANGED
|
@@ -6,23 +6,23 @@ import { Buffer } from 'buffer';
|
|
|
6
6
|
import { PrefixV2 } from './constants';
|
|
7
7
|
import BigNumber from 'bignumber.js';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* list of prefixes that can be used to decode an address
|
|
10
10
|
*/
|
|
11
11
|
export declare const addressPrefixes: PrefixV2[];
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* list of prefixes that can be used to decode a public key
|
|
14
14
|
*/
|
|
15
15
|
export declare const publicKeyPrefixes: PrefixV2[];
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* list of prefixes that can be used to decode a public key hash
|
|
18
18
|
*/
|
|
19
19
|
export declare const publicKeyHashPrefixes: PrefixV2[];
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* list of prefixes that can be used to decode a signature
|
|
22
22
|
*/
|
|
23
23
|
export declare const signaturePrefixes: PrefixV2[];
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Decodes Base58 string, looks for known prefix and strips it
|
|
26
26
|
* @param src Base58 string
|
|
27
27
|
* @returns Payload and prefix
|
|
28
28
|
* @example b58DecodeAndCheckPrefix('tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM') // returns [Uint8Array, PrefixV2.Ed25519PublicKeyHash]
|
|
@@ -33,7 +33,7 @@ export declare function b58DecodeAndCheckPrefix<T extends readonly PrefixV2[]>(s
|
|
|
33
33
|
export declare function b58DecodeAndCheckPrefix<T extends readonly PrefixV2[]>(src: string, allowed: T, payloadOnly: false): [Uint8Array, T[number]];
|
|
34
34
|
export declare function b58DecodeAndCheckPrefix<T extends readonly PrefixV2[]>(src: string, allowed: T, payloadOnly: true): Uint8Array;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Decode a Base58 public key and return its binary representation
|
|
37
37
|
* @param value Value to decode
|
|
38
38
|
* @param fmt optional format of the decoded return value, 'hex' or 'array'
|
|
39
39
|
* @returns string or Uint8Array of bytes
|
|
@@ -42,7 +42,7 @@ export declare function b58DecodeAndCheckPrefix<T extends readonly PrefixV2[]>(s
|
|
|
42
42
|
export declare function b58DecodePublicKey(value: string, fmt?: 'hex'): string;
|
|
43
43
|
export declare function b58DecodePublicKey(value: string, fmt: 'array'): Uint8Array;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Decode a Base58 public key hash and return its binary representation
|
|
46
46
|
* @param value Value to decode
|
|
47
47
|
* @param fmt optional format of the decoded return value, 'hex' or 'array'
|
|
48
48
|
* @returns string or Uint8Array of bytes
|
|
@@ -51,7 +51,7 @@ export declare function b58DecodePublicKey(value: string, fmt: 'array'): Uint8Ar
|
|
|
51
51
|
export declare function b58DecodePublicKeyHash(value: string, fmt?: 'hex'): string;
|
|
52
52
|
export declare function b58DecodePublicKeyHash(value: string, fmt: 'array'): Uint8Array;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Decode a Base58 string and assert tz4 type
|
|
55
55
|
* @param value a bls address(tz4) to decode
|
|
56
56
|
* @param fmt optional format of the decoded return value, 'hex' or 'array'
|
|
57
57
|
* @returns string or Uint8Array of bytes
|
|
@@ -60,7 +60,7 @@ export declare function b58DecodePublicKeyHash(value: string, fmt: 'array'): Uin
|
|
|
60
60
|
export declare function b58DecodeBlsAddress(value: string, fmt?: 'hex'): string;
|
|
61
61
|
export declare function b58DecodeBlsAddress(value: string, fmt: 'array'): Uint8Array;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Decode a Base58 contract ID and return its binary representation
|
|
64
64
|
* @param value Value to decode
|
|
65
65
|
* @param fmt optional format of the decoded return value, 'hex' or 'array'
|
|
66
66
|
* @returns string or Uint8Array of bytes
|
|
@@ -69,105 +69,105 @@ export declare function b58DecodeBlsAddress(value: string, fmt: 'array'): Uint8A
|
|
|
69
69
|
export declare function b58DecodeAddress(value: string, fmt?: 'hex'): string;
|
|
70
70
|
export declare function b58DecodeAddress(value: string, fmt: 'array'): Uint8Array;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Gets Tezos address (PKH) from Public Key
|
|
73
73
|
* @param publicKey Base58 Public Key
|
|
74
74
|
* @returns A string of the Tezos address (PKH) that was derived from the given Public Key
|
|
75
75
|
* @example getPkhfromPk('edpkuNjKKT48xBoT5asPrWdmuM1Yw8D93MwgFgVvtca8jb5pstzaCh') // return 'tz2MVED1t9Jery77Bwm1m5YhUx8Wp5KWWRQe'
|
|
76
76
|
*/
|
|
77
77
|
export declare function getPkhfromPk(publicKey: string): string;
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
79
|
+
* Add the prefix to a hex string or Uint8Array and Base58 encode it
|
|
80
80
|
* @param value Value to Base58 encode
|
|
81
81
|
* @param pre prefix ID to append to the encoded string
|
|
82
82
|
* @example b58Encode('e96b9f8b19af9c7ffa0c0480e1977b295850961f', PrefixV2.Ed25519PublicKeyHash) // returns 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'
|
|
83
83
|
*/
|
|
84
84
|
export declare function b58Encode(value: string | Uint8Array, pre: PrefixV2): string;
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* Parse binary public key and return Base58 representation
|
|
87
87
|
* @param value Binary key data
|
|
88
88
|
* @returns return prefixed public key
|
|
89
89
|
* @example encodeKey('02033aba7da4a2e7b5dd9f074555c118829aff16213ea1b65859686bd5fcfeaf3616') // return 'p2pk66xmhjiN7LpfrDGFwpxPtJxkLtPjQ6HUxJbKmRbxSR7RMpamDwi'
|
|
90
90
|
*/
|
|
91
91
|
export declare function encodeKey(value: string | Uint8Array): string;
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
93
|
+
* Parse binary public key hash and return Base58 representation
|
|
94
94
|
* @param value Key hash to parse
|
|
95
95
|
* @returns return prefixed public key hash
|
|
96
96
|
* @example encodeKeyHash('0001907d6a7e9f084df840d6e67ffa8db5464f87d4d1') // return 'tz2MVED1t9Jery77Bwm1m5YhUx8Wp5KWWRQe'
|
|
97
97
|
*/
|
|
98
98
|
export declare function encodeKeyHash(value: string | Uint8Array): string;
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* Parse binary Contract ID and return Base58 representation
|
|
101
101
|
* @param value Address to parse (tz1, tz2, tz3, KT1, or sr1).
|
|
102
102
|
* @example encodeAddress('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f') // return 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'
|
|
103
103
|
*/
|
|
104
104
|
export declare function encodeAddress(value: string | Uint8Array): string;
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
106
|
+
* Base58 encode an address without predefined prefix
|
|
107
107
|
* @param value Address to base58 encode (tz4) hex dec
|
|
108
108
|
* @returns return address
|
|
109
109
|
* @example encodeBlsAddress('af2dc3c40667abc0e89c0ef40171d22aed08d5eb') // return 'tz4QyWfEiv56CVDATV3DT3CDVhPaMKif2Ce8'
|
|
110
110
|
*/
|
|
111
111
|
export declare function encodeBlsAddress(value: string): string;
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* convert a fragment of Michelson code in hex string to an 'expr' prefix + base58 encoded BLAKE2b hash string
|
|
114
114
|
* @param value a fragment of Michelson code in hex string
|
|
115
115
|
* @returns return 'expr' prefix + base58 encoded BLAKE2b hash
|
|
116
116
|
* @example encodeExpr('050a000000160000b2e19a9e74440d86c59f13dab8a18ff873e889ea') // return 'exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN'
|
|
117
117
|
*/
|
|
118
118
|
export declare function encodeExpr(value: string): string;
|
|
119
119
|
/**
|
|
120
|
-
*
|
|
120
|
+
* convert a signed operation in hex string to an 'op' prefix + base58 encoded BLAKE2b hash string
|
|
121
121
|
* @param value signed operation in hex string
|
|
122
122
|
* @returns return 'op' prefix + base58 encoded BLAKE2b hash
|
|
123
123
|
* @example encodeOpHash('0f185d8a30061e8134c162dbb7a6c3ab8f5fdb153363ccd6149b49a33481156a6c00b2e19a9e74440d86c59f13dab8a18ff873e889eaa304ab05da13000001f1585a7384f36e45fb43dc37e8ce172bced3e05700ff0000000002002110c033f3a990c2e46a3d6054ecc2f74072aae7a34b5ac4d9ce9edc11c2410a97695682108951786f05b361da03b97245dc9897e1955e08b5b8d9e153b0bdeb0d') // return 'opapqvVXmebRTCFd2GQFydr4tJj3V5QocQuTmuhbatcHm4Seo2t'
|
|
124
124
|
*/
|
|
125
125
|
export declare function encodeOpHash(value: string): string;
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
127
|
+
* Convert an hex string to a Uint8Array
|
|
128
128
|
* @param hex Hex string to convert
|
|
129
129
|
* @throws {@link ValueConversionError}
|
|
130
130
|
*/
|
|
131
131
|
export declare function hex2buf(hex: string): Uint8Array;
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
133
|
+
* Merge 2 buffers together
|
|
134
134
|
* @param b1 First buffer
|
|
135
135
|
* @param b2 Second buffer
|
|
136
136
|
*/
|
|
137
137
|
export declare function mergebuf(b1: Uint8Array, b2: Uint8Array): Uint8Array;
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* Flatten a michelson json representation to an array
|
|
140
140
|
* @param s michelson json
|
|
141
141
|
*/
|
|
142
142
|
export declare function mic2arr(s: any): any;
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
* @param
|
|
144
|
+
* Convert a Uint8Array to an hex string
|
|
145
|
+
* @param bytes Uint8Array to convert
|
|
146
146
|
*/
|
|
147
147
|
export declare function buf2hex(bytes: ArrayLike<number>): string;
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
149
|
+
* Convert a string to a byte string representation
|
|
150
150
|
* @param str String to convert
|
|
151
151
|
*/
|
|
152
152
|
export declare function stringToBytes(str: string): string;
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
154
|
+
* Convert byte string representation to string
|
|
155
155
|
* @param hex byte string to convert
|
|
156
156
|
*/
|
|
157
157
|
export declare function bytesToString(hex: string): string;
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
159
|
+
* Convert hex string/UintArray/Buffer to bytes
|
|
160
160
|
* @param hex String value to convert to bytes
|
|
161
161
|
*/
|
|
162
162
|
export declare function hex2Bytes(hex: string): Buffer;
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
164
|
+
* Converts a number or Bignumber to hexadecimal string
|
|
165
165
|
* @param val The value that will be converted to a hexadecimal string value
|
|
166
166
|
*/
|
|
167
|
-
export declare function toHexBuf(val: number | BigNumber, bitLength?: number): Buffer
|
|
168
|
-
export declare function numToHexBuffer(val: number | BigNumber, bitLength?: number): Buffer
|
|
167
|
+
export declare function toHexBuf(val: number | BigNumber, bitLength?: number): Buffer<ArrayBuffer>;
|
|
168
|
+
export declare function numToHexBuffer(val: number | BigNumber, bitLength?: number): Buffer<ArrayBuffer>;
|
|
169
169
|
/**
|
|
170
|
-
*
|
|
170
|
+
* Converts a number or BigNumber to a padded hexadecimal string
|
|
171
171
|
* @param val The value that will be converted into a padded hexadecimal string value
|
|
172
172
|
* @param bitLength The length of bits
|
|
173
173
|
*
|
|
@@ -175,7 +175,7 @@ export declare function numToHexBuffer(val: number | BigNumber, bitLength?: numb
|
|
|
175
175
|
export declare function num2PaddedHex(val: number | BigNumber, bitLength?: number): string;
|
|
176
176
|
/**
|
|
177
177
|
*
|
|
178
|
-
*
|
|
178
|
+
* Strips the first 2 characters of a hex string (0x)
|
|
179
179
|
*
|
|
180
180
|
* @param hex string to strip prefix from
|
|
181
181
|
*/
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ParameterValidationError, UnsupportedActionError, ValidationResult } fr
|
|
|
2
2
|
export { InvalidAddressError, InvalidBlockHashError, InvalidHexStringError, InvalidMessageError, InvalidKeyError, InvalidPublicKeyError, InvalidSignatureError, InvalidContractAddressError, InvalidChainIdError, InvalidKeyHashError, InvalidOperationHashError, InvalidOperationKindError, DeprecationError, ProhibitedActionError, } from '@taquito/core';
|
|
3
3
|
/**
|
|
4
4
|
* @category Error
|
|
5
|
-
*
|
|
5
|
+
* Error that indicates invalid protocol hash being passed or used
|
|
6
6
|
*/
|
|
7
7
|
export declare class InvalidProtocolHashError extends ParameterValidationError {
|
|
8
8
|
readonly protocolHash: string;
|
|
@@ -11,7 +11,7 @@ export declare class InvalidProtocolHashError extends ParameterValidationError {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* @category Error
|
|
14
|
-
*
|
|
14
|
+
* Error that indicates unable to convert data type from one to another
|
|
15
15
|
*/
|
|
16
16
|
export declare class ValueConversionError extends UnsupportedActionError {
|
|
17
17
|
readonly value: string;
|