@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.
- package/dist/lib/constants.js +1 -2
- package/dist/lib/errors.js +0 -1
- package/dist/lib/format.js +0 -1
- package/dist/lib/taquito-utils.js +19 -17
- package/dist/lib/validators.js +1 -2
- package/dist/lib/verify-signature.js +11 -12
- package/dist/lib/version.js +2 -3
- package/dist/taquito-utils.es6.js +900 -896
- package/dist/taquito-utils.es6.js.map +1 -1
- package/dist/taquito-utils.umd.js +900 -906
- package/dist/taquito-utils.umd.js.map +1 -1
- package/dist/types/constants.d.ts +95 -95
- package/dist/types/errors.d.ts +21 -21
- package/dist/types/format.d.ts +4 -4
- package/dist/types/taquito-utils.d.ts +165 -165
- package/dist/types/validators.d.ts +160 -160
- package/dist/types/verify-signature.d.ts +24 -24
- package/dist/types/version.d.ts +4 -4
- package/package.json +27 -29
- package/signature.json +3 -5
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/errors.js.map +0 -1
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/taquito-utils.js.map +0 -1
- package/dist/lib/validators.js.map +0 -1
- package/dist/lib/verify-signature.js.map +0 -1
- package/dist/lib/version.js.map +0 -1
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
* @module @taquito/utils
|
|
4
|
-
*/
|
|
5
|
-
/// <reference types="node" />
|
|
6
|
-
import { Buffer } from 'buffer';
|
|
7
|
-
import BigNumber from 'bignumber.js';
|
|
8
|
-
export * from './validators';
|
|
9
|
-
export { VERSION } from './version';
|
|
10
|
-
export { prefix, Prefix, prefixLength } from './constants';
|
|
11
|
-
export { verifySignature, validatePkAndExtractPrefix } from './verify-signature';
|
|
12
|
-
export * from './errors';
|
|
13
|
-
export { format } from './format';
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @description Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and appends the prefix 'expr' to it
|
|
17
|
-
*
|
|
18
|
-
* @param value Value in hex
|
|
19
|
-
*/
|
|
20
|
-
export declare function encodeExpr(value: string): string;
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @description Return the operation hash of a signed operation
|
|
24
|
-
* @param value Value in hex of a signed operation
|
|
25
|
-
*/
|
|
26
|
-
export declare function encodeOpHash(value: string): string;
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @description Base58 encode a string or a Uint8Array and append a prefix to it
|
|
30
|
-
*
|
|
31
|
-
* @param value Value to base58 encode
|
|
32
|
-
* @param prefix prefix to append to the encoded string
|
|
33
|
-
*/
|
|
34
|
-
export declare function b58cencode(value: string | Uint8Array, prefix: Uint8Array): string;
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @description Base58 decode a string and remove the prefix from it
|
|
38
|
-
*
|
|
39
|
-
* @param value Value to base58 decode
|
|
40
|
-
* @param prefix prefix to remove from the decoded string
|
|
41
|
-
*/
|
|
42
|
-
export declare const b58cdecode: (enc: string, prefixArg: Uint8Array) => Uint8Array;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @description Base58 decode a string with predefined prefix
|
|
46
|
-
*
|
|
47
|
-
* @param value Value to base58 decode
|
|
48
|
-
*/
|
|
49
|
-
export declare function b58decode(payload: string): string;
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @description b58 decode a string without predefined prefix
|
|
53
|
-
* @param value
|
|
54
|
-
* @returns string of bytes
|
|
55
|
-
*/
|
|
56
|
-
export declare function b58decodeL2Address(payload: string): string;
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @description Base58 encode an address using predefined prefix
|
|
60
|
-
*
|
|
61
|
-
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1)
|
|
62
|
-
*/
|
|
63
|
-
export declare function encodePubKey(value: string): string;
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
* @description Base58 encode an address without predefined prefix
|
|
67
|
-
* @param value Address to base58 encode (tz4) hex dec
|
|
68
|
-
* @returns return address
|
|
69
|
-
*/
|
|
70
|
-
export declare function encodeL2Address(value: string): string;
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* @description Base58 encode a key according to its prefix
|
|
74
|
-
*
|
|
75
|
-
* @param value Key to base58 encode
|
|
76
|
-
*/
|
|
77
|
-
export declare function encodeKey(value: string): string | undefined;
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
* @description Base58 encode a key hash according to its prefix
|
|
81
|
-
*
|
|
82
|
-
* @param value Key hash to base58 encode
|
|
83
|
-
*/
|
|
84
|
-
export declare function encodeKeyHash(value: string): string | undefined;
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* @description Convert an hex string to a Uint8Array
|
|
88
|
-
*
|
|
89
|
-
* @param hex Hex string to convert
|
|
90
|
-
* @throws {@link ValueConversionError}
|
|
91
|
-
*/
|
|
92
|
-
export declare const hex2buf: (hex: string) => Uint8Array;
|
|
93
|
-
/**
|
|
94
|
-
*
|
|
95
|
-
* @description Merge 2 buffers together
|
|
96
|
-
*
|
|
97
|
-
* @param b1 First buffer
|
|
98
|
-
* @param b2 Second buffer
|
|
99
|
-
*/
|
|
100
|
-
export declare const mergebuf: (b1: Uint8Array, b2: Uint8Array) => Uint8Array;
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* @description Flatten a michelson json representation to an array
|
|
104
|
-
*
|
|
105
|
-
* @param s michelson json
|
|
106
|
-
*/
|
|
107
|
-
export declare const mic2arr: (s: any) => any;
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
110
|
-
* @description Convert a
|
|
111
|
-
*
|
|
112
|
-
* @param buffer
|
|
113
|
-
*/
|
|
114
|
-
export declare const buf2hex: (buffer:
|
|
115
|
-
/**
|
|
116
|
-
*
|
|
117
|
-
* @description Gets Tezos address (PKH) from Public Key
|
|
118
|
-
*
|
|
119
|
-
* @param publicKey Public Key
|
|
120
|
-
* @returns A string of the Tezos address (PKH) that was derived from the given Public Key
|
|
121
|
-
*/
|
|
122
|
-
export declare const getPkhfromPk: (publicKey: string) => string;
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
* @description Convert a string to bytes
|
|
126
|
-
*
|
|
127
|
-
* @param str String to convert
|
|
128
|
-
*/
|
|
129
|
-
export declare function char2Bytes(str: string): string;
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
* @description Convert bytes to a string
|
|
133
|
-
*
|
|
134
|
-
* @param str Bytes to convert
|
|
135
|
-
*/
|
|
136
|
-
export declare function bytes2Char(hex: string): string;
|
|
137
|
-
/**
|
|
138
|
-
*
|
|
139
|
-
* @description Convert hex string/UintArray/Buffer to bytes
|
|
140
|
-
*
|
|
141
|
-
* @param hex String value to convert to bytes
|
|
142
|
-
*/
|
|
143
|
-
export declare function hex2Bytes(hex: string): Buffer;
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
146
|
-
* @description Converts a number or Bignumber to hexadecimal string
|
|
147
|
-
*
|
|
148
|
-
* @param val The value that will be converted to a hexadecimal string value
|
|
149
|
-
*/
|
|
150
|
-
export declare function toHexBuf(val: number | BigNumber, bitLength?: number): Buffer;
|
|
151
|
-
/**
|
|
152
|
-
*
|
|
153
|
-
* @description Converts a number or BigNumber to a padded hexadecimal string
|
|
154
|
-
* @param val The value that will be converted into a padded hexadecimal string value
|
|
155
|
-
* @param bitLength The length of bits
|
|
156
|
-
*
|
|
157
|
-
*/
|
|
158
|
-
export declare function num2PaddedHex(val: number | BigNumber, bitLength?: number): string;
|
|
159
|
-
/**
|
|
160
|
-
*
|
|
161
|
-
* @description Strips the first 2 characters of a hex string (0x)
|
|
162
|
-
*
|
|
163
|
-
* @param hex string to strip prefix from
|
|
164
|
-
*/
|
|
165
|
-
export declare function stripHexPrefix(hex: string): string;
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module @taquito/utils
|
|
4
|
+
*/
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
import { Buffer } from 'buffer';
|
|
7
|
+
import BigNumber from 'bignumber.js';
|
|
8
|
+
export * from './validators';
|
|
9
|
+
export { VERSION } from './version';
|
|
10
|
+
export { prefix, Prefix, prefixLength } from './constants';
|
|
11
|
+
export { verifySignature, validatePkAndExtractPrefix } from './verify-signature';
|
|
12
|
+
export * from './errors';
|
|
13
|
+
export { format } from './format';
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @description Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and appends the prefix 'expr' to it
|
|
17
|
+
*
|
|
18
|
+
* @param value Value in hex
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeExpr(value: string): string;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @description Return the operation hash of a signed operation
|
|
24
|
+
* @param value Value in hex of a signed operation
|
|
25
|
+
*/
|
|
26
|
+
export declare function encodeOpHash(value: string): string;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @description Base58 encode a string or a Uint8Array and append a prefix to it
|
|
30
|
+
*
|
|
31
|
+
* @param value Value to base58 encode
|
|
32
|
+
* @param prefix prefix to append to the encoded string
|
|
33
|
+
*/
|
|
34
|
+
export declare function b58cencode(value: string | Uint8Array, prefix: Uint8Array): string;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @description Base58 decode a string and remove the prefix from it
|
|
38
|
+
*
|
|
39
|
+
* @param value Value to base58 decode
|
|
40
|
+
* @param prefix prefix to remove from the decoded string
|
|
41
|
+
*/
|
|
42
|
+
export declare const b58cdecode: (enc: string, prefixArg: Uint8Array) => Uint8Array;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @description Base58 decode a string with predefined prefix
|
|
46
|
+
*
|
|
47
|
+
* @param value Value to base58 decode
|
|
48
|
+
*/
|
|
49
|
+
export declare function b58decode(payload: string): string;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @description b58 decode a string without predefined prefix
|
|
53
|
+
* @param value
|
|
54
|
+
* @returns string of bytes
|
|
55
|
+
*/
|
|
56
|
+
export declare function b58decodeL2Address(payload: string): string;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @description Base58 encode an address using predefined prefix
|
|
60
|
+
*
|
|
61
|
+
* @param value Address to base58 encode (tz1, tz2, tz3 or KT1)
|
|
62
|
+
*/
|
|
63
|
+
export declare function encodePubKey(value: string): string;
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @description Base58 encode an address without predefined prefix
|
|
67
|
+
* @param value Address to base58 encode (tz4) hex dec
|
|
68
|
+
* @returns return address
|
|
69
|
+
*/
|
|
70
|
+
export declare function encodeL2Address(value: string): string;
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @description Base58 encode a key according to its prefix
|
|
74
|
+
*
|
|
75
|
+
* @param value Key to base58 encode
|
|
76
|
+
*/
|
|
77
|
+
export declare function encodeKey(value: string): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @description Base58 encode a key hash according to its prefix
|
|
81
|
+
*
|
|
82
|
+
* @param value Key hash to base58 encode
|
|
83
|
+
*/
|
|
84
|
+
export declare function encodeKeyHash(value: string): string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @description Convert an hex string to a Uint8Array
|
|
88
|
+
*
|
|
89
|
+
* @param hex Hex string to convert
|
|
90
|
+
* @throws {@link ValueConversionError}
|
|
91
|
+
*/
|
|
92
|
+
export declare const hex2buf: (hex: string) => Uint8Array;
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* @description Merge 2 buffers together
|
|
96
|
+
*
|
|
97
|
+
* @param b1 First buffer
|
|
98
|
+
* @param b2 Second buffer
|
|
99
|
+
*/
|
|
100
|
+
export declare const mergebuf: (b1: Uint8Array, b2: Uint8Array) => Uint8Array;
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @description Flatten a michelson json representation to an array
|
|
104
|
+
*
|
|
105
|
+
* @param s michelson json
|
|
106
|
+
*/
|
|
107
|
+
export declare const mic2arr: (s: any) => any;
|
|
108
|
+
/**
|
|
109
|
+
*
|
|
110
|
+
* @description Convert a Uint8Array to an hex string
|
|
111
|
+
*
|
|
112
|
+
* @param buffer Uint8Array to convert
|
|
113
|
+
*/
|
|
114
|
+
export declare const buf2hex: (buffer: Uint8Array) => string;
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @description Gets Tezos address (PKH) from Public Key
|
|
118
|
+
*
|
|
119
|
+
* @param publicKey Public Key
|
|
120
|
+
* @returns A string of the Tezos address (PKH) that was derived from the given Public Key
|
|
121
|
+
*/
|
|
122
|
+
export declare const getPkhfromPk: (publicKey: string) => string;
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
* @description Convert a string to bytes
|
|
126
|
+
*
|
|
127
|
+
* @param str String to convert
|
|
128
|
+
*/
|
|
129
|
+
export declare function char2Bytes(str: string): string;
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
* @description Convert bytes to a string
|
|
133
|
+
*
|
|
134
|
+
* @param str Bytes to convert
|
|
135
|
+
*/
|
|
136
|
+
export declare function bytes2Char(hex: string): string;
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
* @description Convert hex string/UintArray/Buffer to bytes
|
|
140
|
+
*
|
|
141
|
+
* @param hex String value to convert to bytes
|
|
142
|
+
*/
|
|
143
|
+
export declare function hex2Bytes(hex: string): Buffer;
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @description Converts a number or Bignumber to hexadecimal string
|
|
147
|
+
*
|
|
148
|
+
* @param val The value that will be converted to a hexadecimal string value
|
|
149
|
+
*/
|
|
150
|
+
export declare function toHexBuf(val: number | BigNumber, bitLength?: number): Buffer;
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
* @description Converts a number or BigNumber to a padded hexadecimal string
|
|
154
|
+
* @param val The value that will be converted into a padded hexadecimal string value
|
|
155
|
+
* @param bitLength The length of bits
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
export declare function num2PaddedHex(val: number | BigNumber, bitLength?: number): string;
|
|
159
|
+
/**
|
|
160
|
+
*
|
|
161
|
+
* @description Strips the first 2 characters of a hex string (0x)
|
|
162
|
+
*
|
|
163
|
+
* @param hex string to strip prefix from
|
|
164
|
+
*/
|
|
165
|
+
export declare function stripHexPrefix(hex: string): string;
|
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
import { Prefix } from './constants';
|
|
2
|
-
export declare enum ValidationResult {
|
|
3
|
-
NO_PREFIX_MATCHED = 0,
|
|
4
|
-
INVALID_CHECKSUM = 1,
|
|
5
|
-
INVALID_LENGTH = 2,
|
|
6
|
-
VALID = 3
|
|
7
|
-
}
|
|
8
|
-
export declare function isValidPrefix(value: unknown): value is Prefix;
|
|
9
|
-
/**
|
|
10
|
-
* @description Used to check if an address or a contract address is valid.
|
|
11
|
-
*
|
|
12
|
-
* @returns
|
|
13
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```
|
|
17
|
-
* import { validateAddress } from '@taquito/utils';
|
|
18
|
-
* const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
|
|
19
|
-
* const validation = validateAddress(pkh)
|
|
20
|
-
* console.log(validation)
|
|
21
|
-
* // This example return 3 which correspond to VALID
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function validateAddress(value: string): ValidationResult;
|
|
25
|
-
/**
|
|
26
|
-
* @description Used to check if a chain id is valid.
|
|
27
|
-
*
|
|
28
|
-
* @returns
|
|
29
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```
|
|
33
|
-
* import { validateChain } from '@taquito/utils';
|
|
34
|
-
* const chainId = 'NetXdQprcVkpaWU'
|
|
35
|
-
* const validation = validateChain(chainId)
|
|
36
|
-
* console.log(validation)
|
|
37
|
-
* // This example return 3 which correspond to VALID
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare function validateChain(value: string): ValidationResult;
|
|
41
|
-
/**
|
|
42
|
-
* @description Used to check if a contract address is valid.
|
|
43
|
-
*
|
|
44
|
-
* @returns
|
|
45
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```
|
|
49
|
-
* import { validateContractAddress } from '@taquito/utils';
|
|
50
|
-
* const contractAddress = 'KT1JVErLYTgtY8uGGZ4mso2npTSxqVLDRVbC'
|
|
51
|
-
* const validation = validateContractAddress(contractAddress)
|
|
52
|
-
* console.log(validation)
|
|
53
|
-
* // This example return 3 which correspond to VALID
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
export declare function validateContractAddress(value: string): ValidationResult;
|
|
57
|
-
/**
|
|
58
|
-
* @description Used to check if a key hash is valid.
|
|
59
|
-
*
|
|
60
|
-
* @returns
|
|
61
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```
|
|
65
|
-
* import { validateKeyHash } from '@taquito/utils';
|
|
66
|
-
* const keyHashWithoutPrefix = '1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
|
|
67
|
-
* const validation = validateKeyHash(keyHashWithoutPrefix)
|
|
68
|
-
* console.log(validation)
|
|
69
|
-
* // This example return 0 which correspond to NO_PREFIX_MATCHED
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
export declare function validateKeyHash(value: string): ValidationResult;
|
|
73
|
-
/**
|
|
74
|
-
* @description Used to check if a signature is valid.
|
|
75
|
-
*
|
|
76
|
-
* @returns
|
|
77
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```
|
|
81
|
-
* import { validateSignature } from '@taquito/utils';
|
|
82
|
-
* const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
|
|
83
|
-
* const validation = validateSignature(signature)
|
|
84
|
-
* console.log(validation)
|
|
85
|
-
* // This example return 3 which correspond to VALID
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export declare function validateSignature(value: string): ValidationResult;
|
|
89
|
-
/**
|
|
90
|
-
* @description Used to check if a public key is valid.
|
|
91
|
-
*
|
|
92
|
-
* @returns
|
|
93
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```
|
|
97
|
-
* import { validatePublicKey } from '@taquito/utils';
|
|
98
|
-
* const publicKey = 'edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g'
|
|
99
|
-
* const validation = validatePublicKey(publicKey)
|
|
100
|
-
* console.log(validation)
|
|
101
|
-
* // This example return 3 which correspond to VALID
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
export declare function validatePublicKey(value: string): ValidationResult;
|
|
105
|
-
/**
|
|
106
|
-
* @description Used to check if an operation hash is valid.
|
|
107
|
-
*
|
|
108
|
-
* @returns
|
|
109
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```
|
|
113
|
-
* import { validateOperation } from '@taquito/utils';
|
|
114
|
-
* const operationHash = 'oo6JPEAy8VuMRGaFuMmLNFFGdJgiaKfnmT1CpHJfKP3Ye5ZahiP'
|
|
115
|
-
* const validation = validateOperation(operationHash)
|
|
116
|
-
* console.log(validation)
|
|
117
|
-
* // This example return 3 which correspond to VALID
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
export declare function validateOperation(value: string): ValidationResult;
|
|
121
|
-
/**
|
|
122
|
-
* @description Used to check if a protocol hash is valid.
|
|
123
|
-
*
|
|
124
|
-
* @returns
|
|
125
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```
|
|
129
|
-
* import { validateProtocol } from '@taquito/utils';
|
|
130
|
-
* const protocolHash = 'PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx'
|
|
131
|
-
* const validation = validateProtocol(protocolHash)
|
|
132
|
-
* console.log(validation)
|
|
133
|
-
* // This example return 3 which correspond to VALID
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
export declare function validateProtocol(value: string): ValidationResult;
|
|
137
|
-
/**
|
|
138
|
-
* @description Used to check if a block hash is valid.
|
|
139
|
-
*
|
|
140
|
-
* @returns
|
|
141
|
-
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* ```
|
|
145
|
-
* import { validateBlock } from '@taquito/utils';
|
|
146
|
-
* const blockHash = 'PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx'
|
|
147
|
-
* const validation = validateBlock(blockHash)
|
|
148
|
-
* console.log(validation)
|
|
149
|
-
* // This example return 3 which correspond to VALID
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
export declare function validateBlock(value: string): ValidationResult;
|
|
153
|
-
/**
|
|
154
|
-
* @description Used to check if a spending key is valid.
|
|
155
|
-
* @returns 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
156
|
-
*
|
|
157
|
-
*/
|
|
158
|
-
export declare function validateSpendingKey(value: any): ValidationResult;
|
|
159
|
-
export declare function invalidDetail(validation: ValidationResult): string;
|
|
160
|
-
export declare function validateSmartRollupAddress(value: string): ValidationResult;
|
|
1
|
+
import { Prefix } from './constants';
|
|
2
|
+
export declare enum ValidationResult {
|
|
3
|
+
NO_PREFIX_MATCHED = 0,
|
|
4
|
+
INVALID_CHECKSUM = 1,
|
|
5
|
+
INVALID_LENGTH = 2,
|
|
6
|
+
VALID = 3
|
|
7
|
+
}
|
|
8
|
+
export declare function isValidPrefix(value: unknown): value is Prefix;
|
|
9
|
+
/**
|
|
10
|
+
* @description Used to check if an address or a contract address is valid.
|
|
11
|
+
*
|
|
12
|
+
* @returns
|
|
13
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* import { validateAddress } from '@taquito/utils';
|
|
18
|
+
* const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
|
|
19
|
+
* const validation = validateAddress(pkh)
|
|
20
|
+
* console.log(validation)
|
|
21
|
+
* // This example return 3 which correspond to VALID
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateAddress(value: string): ValidationResult;
|
|
25
|
+
/**
|
|
26
|
+
* @description Used to check if a chain id is valid.
|
|
27
|
+
*
|
|
28
|
+
* @returns
|
|
29
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```
|
|
33
|
+
* import { validateChain } from '@taquito/utils';
|
|
34
|
+
* const chainId = 'NetXdQprcVkpaWU'
|
|
35
|
+
* const validation = validateChain(chainId)
|
|
36
|
+
* console.log(validation)
|
|
37
|
+
* // This example return 3 which correspond to VALID
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateChain(value: string): ValidationResult;
|
|
41
|
+
/**
|
|
42
|
+
* @description Used to check if a contract address is valid.
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```
|
|
49
|
+
* import { validateContractAddress } from '@taquito/utils';
|
|
50
|
+
* const contractAddress = 'KT1JVErLYTgtY8uGGZ4mso2npTSxqVLDRVbC'
|
|
51
|
+
* const validation = validateContractAddress(contractAddress)
|
|
52
|
+
* console.log(validation)
|
|
53
|
+
* // This example return 3 which correspond to VALID
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateContractAddress(value: string): ValidationResult;
|
|
57
|
+
/**
|
|
58
|
+
* @description Used to check if a key hash is valid.
|
|
59
|
+
*
|
|
60
|
+
* @returns
|
|
61
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```
|
|
65
|
+
* import { validateKeyHash } from '@taquito/utils';
|
|
66
|
+
* const keyHashWithoutPrefix = '1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
|
|
67
|
+
* const validation = validateKeyHash(keyHashWithoutPrefix)
|
|
68
|
+
* console.log(validation)
|
|
69
|
+
* // This example return 0 which correspond to NO_PREFIX_MATCHED
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function validateKeyHash(value: string): ValidationResult;
|
|
73
|
+
/**
|
|
74
|
+
* @description Used to check if a signature is valid.
|
|
75
|
+
*
|
|
76
|
+
* @returns
|
|
77
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```
|
|
81
|
+
* import { validateSignature } from '@taquito/utils';
|
|
82
|
+
* const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
|
|
83
|
+
* const validation = validateSignature(signature)
|
|
84
|
+
* console.log(validation)
|
|
85
|
+
* // This example return 3 which correspond to VALID
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function validateSignature(value: string): ValidationResult;
|
|
89
|
+
/**
|
|
90
|
+
* @description Used to check if a public key is valid.
|
|
91
|
+
*
|
|
92
|
+
* @returns
|
|
93
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```
|
|
97
|
+
* import { validatePublicKey } from '@taquito/utils';
|
|
98
|
+
* const publicKey = 'edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g'
|
|
99
|
+
* const validation = validatePublicKey(publicKey)
|
|
100
|
+
* console.log(validation)
|
|
101
|
+
* // This example return 3 which correspond to VALID
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function validatePublicKey(value: string): ValidationResult;
|
|
105
|
+
/**
|
|
106
|
+
* @description Used to check if an operation hash is valid.
|
|
107
|
+
*
|
|
108
|
+
* @returns
|
|
109
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```
|
|
113
|
+
* import { validateOperation } from '@taquito/utils';
|
|
114
|
+
* const operationHash = 'oo6JPEAy8VuMRGaFuMmLNFFGdJgiaKfnmT1CpHJfKP3Ye5ZahiP'
|
|
115
|
+
* const validation = validateOperation(operationHash)
|
|
116
|
+
* console.log(validation)
|
|
117
|
+
* // This example return 3 which correspond to VALID
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function validateOperation(value: string): ValidationResult;
|
|
121
|
+
/**
|
|
122
|
+
* @description Used to check if a protocol hash is valid.
|
|
123
|
+
*
|
|
124
|
+
* @returns
|
|
125
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```
|
|
129
|
+
* import { validateProtocol } from '@taquito/utils';
|
|
130
|
+
* const protocolHash = 'PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx'
|
|
131
|
+
* const validation = validateProtocol(protocolHash)
|
|
132
|
+
* console.log(validation)
|
|
133
|
+
* // This example return 3 which correspond to VALID
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare function validateProtocol(value: string): ValidationResult;
|
|
137
|
+
/**
|
|
138
|
+
* @description Used to check if a block hash is valid.
|
|
139
|
+
*
|
|
140
|
+
* @returns
|
|
141
|
+
* 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```
|
|
145
|
+
* import { validateBlock } from '@taquito/utils';
|
|
146
|
+
* const blockHash = 'PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx'
|
|
147
|
+
* const validation = validateBlock(blockHash)
|
|
148
|
+
* console.log(validation)
|
|
149
|
+
* // This example return 3 which correspond to VALID
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function validateBlock(value: string): ValidationResult;
|
|
153
|
+
/**
|
|
154
|
+
* @description Used to check if a spending key is valid.
|
|
155
|
+
* @returns 0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
export declare function validateSpendingKey(value: any): ValidationResult;
|
|
159
|
+
export declare function invalidDetail(validation: ValidationResult): string;
|
|
160
|
+
export declare function validateSmartRollupAddress(value: string): ValidationResult;
|