@taquito/utils 11.0.2 → 11.2.0-beta-RC.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/README.md +258 -17
- package/dist/lib/constants.js +51 -52
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/errors.js +61 -13
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/taquito-utils.js +55 -51
- package/dist/lib/taquito-utils.js.map +1 -1
- package/dist/lib/validators.js +73 -33
- package/dist/lib/validators.js.map +1 -1
- package/dist/lib/verify-signature.js +29 -45
- package/dist/lib/verify-signature.js.map +1 -1
- package/dist/lib/version.js +2 -4
- package/dist/lib/version.js.map +1 -1
- package/dist/{taquito-utils.es5.js → taquito-utils.es6.js} +250 -191
- package/dist/taquito-utils.es6.js.map +1 -0
- package/dist/taquito-utils.umd.js +266 -195
- package/dist/taquito-utils.umd.js.map +1 -1
- package/dist/types/constants.d.ts +2 -2
- package/dist/types/errors.d.ts +33 -3
- package/dist/types/taquito-utils.d.ts +10 -9
- package/dist/types/validators.d.ts +49 -1
- package/package.json +21 -20
- package/dist/taquito-utils.es5.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,29 +1,270 @@
|
|
|
1
1
|
# Taquito Utils package
|
|
2
|
+
*TypeDoc style documentation is available on-line [here](https://tezostaquito.io/typedoc/modules/_taquito_utils.html)*
|
|
2
3
|
|
|
3
4
|
`@taquito/utils` is an npm package that provides developers with utility functionality for Taquito.
|
|
4
5
|
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
npm i --save @taquito/utils
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Validation functions
|
|
15
|
+
|
|
16
|
+
Taquito provides functions that allow seeing if an address, a chain, a key hash, a contract address, a public key, a signature, a block hash, an operation hash, or a protocol hash is valid based on checksums.
|
|
17
|
+
|
|
18
|
+
The `ValidationResult` returned by these functions is an enum that can take the following values:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
0 = NO_PREFIX_MATCHED,
|
|
22
|
+
1 = INVALID_CHECKSUM,
|
|
23
|
+
2 = INVALID_LENGTH,
|
|
24
|
+
3 = VALID
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Address validation (tz1, tz2, tz3, KT1)**
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { validateAddress } from '@taquito/utils';
|
|
31
|
+
|
|
32
|
+
const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx';
|
|
33
|
+
console.log(validateAddress(pkh));
|
|
34
|
+
// output: 3 which is valid
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Key hash validation**
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { validateKeyHash } from '@taquito/utils';
|
|
41
|
+
|
|
42
|
+
const keyHash = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx';
|
|
43
|
+
console.log(validateKeyHash(keyHash));
|
|
44
|
+
// output: 3 which is valid
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Contract address validation**
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { validateContractAddress } from '@taquito/utils';
|
|
51
|
+
|
|
52
|
+
const contractAddress = 'KT1AfxAKKLnEg6rQ6kHdvCWwagjSaxEwURSJ';
|
|
53
|
+
console.log(validateContractAddress(contractAddress));
|
|
54
|
+
// output: 3 which is valid
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Chain id validation**
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { validateChain } from '@taquito/utils';
|
|
61
|
+
|
|
62
|
+
const chainId = 'NetXdQprcVkpaWU';
|
|
63
|
+
console.log(validateChain(chainId));
|
|
64
|
+
// output: 3 which is valid
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Public key validation**
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { validatePublicKey } from '@taquito/utils';
|
|
71
|
+
|
|
72
|
+
const publicKey = 'edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g';
|
|
73
|
+
console.log(validatePublicKey(publicKey));
|
|
74
|
+
// output: 3 which is valid
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Signature validation**
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { validateSignature } from '@taquito/utils';
|
|
81
|
+
|
|
82
|
+
const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg';
|
|
83
|
+
console.log(validateSignature(signature));
|
|
84
|
+
// output: 3 which is valid
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Block hash validation**
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { validateBlock } from '@taquito/utils';
|
|
91
|
+
|
|
92
|
+
const block ='BLJjnzaPtSsxykZ9pLTFLSfsKuiN3z7SjSPDPWwbE4Q68u5EpBw';
|
|
93
|
+
console.log(validateBlock(block));
|
|
94
|
+
// output: 3 which is valid
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Operation hash validation**
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { validateOperation } from '@taquito/utils';
|
|
101
|
+
|
|
102
|
+
const operation ='ood2Y1FLHH9izvYghVcDGGAkvJFo1CgSEjPfWvGsaz3qypCmeUj';
|
|
103
|
+
console.log(validateOperation(operation));
|
|
104
|
+
// output: 3 which is valid
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Protocol hash validation**
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { validateProtocol } from '@taquito/utils';
|
|
111
|
+
|
|
112
|
+
//valid
|
|
113
|
+
const protocol ='PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx';
|
|
114
|
+
console.log(validateProtocol(protocol));
|
|
115
|
+
// output: 3 which is valid
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Verification of a signature
|
|
119
|
+
|
|
120
|
+
The function takes a message, a public key, and a signature as parameters and returns a boolean indicating if the signature matches.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { verifySignature } from '@taquito/utils';
|
|
124
|
+
|
|
125
|
+
const message = '03d0c10e3ed11d7c6e3357f6ef335bab9e8f2bd54d0ce20c482e241191a6e4b8ce6c01be917311d9ac46959750e405d57e268e2ed9e174a80794fbd504e12a4a000141eb3781afed2f69679ff2bbe1c5375950b0e40d00ff000000005e05050505050507070100000024747a32526773486e74516b72794670707352466261313652546656503539684b72654a4d07070100000024747a315a6672455263414c42776d4171776f6e525859565142445439426a4e6a42484a750001';
|
|
126
|
+
const pk = 'sppk7c7hkPj47yjYFEHX85q46sFJGw6RBrqoVSHwAJAT4e14KJwzoey';
|
|
127
|
+
const sig = 'spsig1cdLkp1RLgUHAp13aRFkZ6MQDPp7xCnjAExGL3MBSdMDmT6JgQSX8cufyDgJRM3sinFtiCzLbsyP6d365EHoNevxhT47nx'
|
|
128
|
+
|
|
129
|
+
const isValid = verifySignature(message, pk, sig);
|
|
130
|
+
console.log(isValid);
|
|
131
|
+
// output: true
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Utility functions
|
|
135
|
+
|
|
136
|
+
**Conversion between hexadecimal and ASCII strings**
|
|
137
|
+
```ts
|
|
138
|
+
import { char2Bytes, bytes2Char } from '@taquito/utils';
|
|
139
|
+
|
|
140
|
+
const url = 'https://storage.googleapis.com/tzip-16/fa2-views.json';
|
|
141
|
+
const hex = '68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f747a69702d31362f6661322d76696577732e6a736f6e';
|
|
142
|
+
|
|
143
|
+
console.log(char2Bytes(url));
|
|
144
|
+
// output: 68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f747a69702d31362f6661322d76696577732e6a736f6e
|
|
145
|
+
|
|
146
|
+
console.log(bytes2Char(hex));
|
|
147
|
+
// output: https://storage.googleapis.com/tzip-16/fa2-views.json
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Conversion between buffer and hexadecimal strings**
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import { buf2hex, hex2buf } from '@taquito/utils';
|
|
154
|
+
|
|
155
|
+
const buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
|
156
|
+
const hex = '627566666572'
|
|
157
|
+
|
|
158
|
+
console.log(buf2hex(buffer));
|
|
159
|
+
// output: 627566666572
|
|
160
|
+
|
|
161
|
+
console.log(hex2buf(hex));
|
|
162
|
+
// output: Uint8Array(6) [ 98, 117, 102, 102, 101, 114 ]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Merge 2 buffers together**
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import { mergebuf } from '@taquito/utils';
|
|
169
|
+
|
|
170
|
+
const buff = new Uint8Array([1,2]);
|
|
171
|
+
const buff2 = new Uint8Array([3,4]);
|
|
172
|
+
|
|
173
|
+
console.log(mergebuf(buff, buff2));
|
|
174
|
+
// output: Uint8Array(4) [ 1, 2, 3, 4 ]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Base58 encode a key hash according to its prefix**
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
import { encodeKeyHash } from '@taquito/utils';
|
|
181
|
+
|
|
182
|
+
console.log(encodeKeyHash('01106d79a502c4135b10e61e92f4c5a72ca740fb87'));
|
|
183
|
+
// output: tz29p6csejX9FcHXgQERr5sXsAinLvxmVerM
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Base58 encode a public key according to its prefix**
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
import { encodeKey } from '@taquito/utils';
|
|
190
|
+
|
|
191
|
+
console.log(encodeKey('0060842d4ba23a9940ef5dcf4404fdaa430cfaaccb5029fad06cb5ea894e4562ae'));
|
|
192
|
+
// output: edpkuNjKKT48xBoT5asPrWdmuM1Yw8D93MwgFgVvtca8jb5pstzaCh
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Base58 encode an address using a predefined prefix**
|
|
5
196
|
```ts
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { encodePubKey } from '@taquito/utils'; // Base58 encode a public key using predefined prefix
|
|
14
|
-
import { b58decode } from '@taquito/utils'; // Base58 decode a string with predefined prefix
|
|
15
|
-
import { b58cdecode } from '@taquito/utils'; // Base58 decode a string and remove the prefix from it
|
|
16
|
-
import { b58cencode } from '@taquito/utils'; // Base58 encode a string or a Uint8Array and append a prefix to it
|
|
17
|
-
import { encodeOpHash } from '@taquito/utils'; // Return the operation hash of a signed operation
|
|
18
|
-
import { encodeExpr } from '@taquito/utils'; // Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and appends the prefix 'expr' to it
|
|
19
|
-
import { getPkhfromPk } from '@taquito/utils'; // Returns Tezos address (PKH) of a given Public Key
|
|
197
|
+
import { encodePubKey } from '@taquito/utils';
|
|
198
|
+
|
|
199
|
+
console.log(encodePubKey('0000e96b9f8b19af9c7ffa0c0480e1977b295850961f'));
|
|
200
|
+
// output: tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM
|
|
201
|
+
|
|
202
|
+
console.log(encodePubKey('01f9b689a478253793bd92357c5e08e5ebcd8db47600'));
|
|
203
|
+
// output: KT1XM8VUFBiM9AC5czWU15fEeE9nmuEYWt3Y
|
|
20
204
|
```
|
|
21
205
|
|
|
22
|
-
|
|
206
|
+
**Base58 decode a string with a predefined prefix**
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
import { b58decode } from '@taquito/utils';
|
|
210
|
+
|
|
211
|
+
console.log(b58decode('tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM'));
|
|
212
|
+
// output: 0000e96b9f8b19af9c7ffa0c0480e1977b295850961f
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Base58 decode a string and remove the prefix from it**
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
import { b58cdecode, prefix, Prefix } from '@taquito/utils';
|
|
219
|
+
|
|
220
|
+
console.log(b58cdecode('tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM', prefix[Prefix.TZ1]));
|
|
221
|
+
// output: <Buffer e9 6b 9f 8b 19 af 9c 7f fa 0c 04 80 e1 97 7b 29 58 50 96 1f>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Base58 encode a string or a Uint8Array and append a prefix to it**
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
import { b58cencode } from '@taquito/utils';
|
|
228
|
+
|
|
229
|
+
console.log(b58cdecode('e96b9f8b19af9c7ffa0c0480e1977b295850961f', prefix[Prefix.TZ1]));
|
|
230
|
+
// output: tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Return the operation hash of a signed operation**
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import { encodeOpHash } from '@taquito/utils';
|
|
237
|
+
|
|
238
|
+
const opBytesSigned = '0f185d8a30061e8134c162dbb7a6c3ab8f5fdb153363ccd6149b49a33481156a6c00b2e19a9e74440d86c59f13dab8a18ff873e889eaa304ab05da13000001f1585a7384f36e45fb43dc37e8ce172bced3e05700ff0000000002002110c033f3a990c2e46a3d6054ecc2f74072aae7a34b5ac4d9ce9edc11c2410a97695682108951786f05b361da03b97245dc9897e1955e08b5b8d9e153b0bdeb0d';
|
|
239
|
+
console.log(encodeOpHash(opBytesSigned));
|
|
240
|
+
// output: opapqvVXmebRTCFd2GQFydr4tJj3V5QocQuTmuhbatcHm4Seo2t
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Generate expression hash**
|
|
244
|
+
|
|
245
|
+
Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and append the prefix 'expr' to it.
|
|
246
|
+
|
|
247
|
+
```ts
|
|
248
|
+
import { encodeExpr } from '@taquito/utils';
|
|
249
|
+
|
|
250
|
+
console.log(encodeExpr('050a000000160000b2e19a9e74440d86c59f13dab8a18ff873e889ea'));
|
|
251
|
+
|
|
252
|
+
// output: exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Obtain the public key hash given a public key**
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
import { getPkhfromPk } from '@taquito/utils';
|
|
259
|
+
|
|
260
|
+
const publicKey = 'sppk7czKu6So3zDWjhBPBv9wgCrBAfbEFoKYzEaKUsjhNr5Ug6E4Sn1';
|
|
261
|
+
console.log(getPkhfromPk(publicKey));
|
|
262
|
+
// output: 'tz2Gsf1Q857wUzkNGzHsJNC98z881UutMwjg
|
|
263
|
+
```
|
|
23
264
|
|
|
24
|
-
##
|
|
265
|
+
## Additional info
|
|
25
266
|
|
|
26
|
-
|
|
267
|
+
See the top-level [https://github.com/ecadlabs/taquito](https://github.com/ecadlabs/taquito) file for details on reporting issues, contributing, and versioning.
|
|
27
268
|
|
|
28
269
|
## Disclaimer
|
|
29
270
|
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.prefixLength = exports.prefix = exports.Prefix = void 0;
|
|
5
4
|
var Prefix;
|
|
@@ -25,7 +24,7 @@ var Prefix;
|
|
|
25
24
|
Prefix["SIG"] = "sig";
|
|
26
25
|
Prefix["NET"] = "Net";
|
|
27
26
|
Prefix["NCE"] = "nce";
|
|
28
|
-
Prefix["B"] = "
|
|
27
|
+
Prefix["B"] = "B";
|
|
29
28
|
Prefix["O"] = "o";
|
|
30
29
|
Prefix["LO"] = "Lo";
|
|
31
30
|
Prefix["LLO"] = "LLo";
|
|
@@ -35,55 +34,55 @@ var Prefix;
|
|
|
35
34
|
Prefix["EXPR"] = "expr";
|
|
36
35
|
Prefix["TZ"] = "TZ";
|
|
37
36
|
})(Prefix = exports.Prefix || (exports.Prefix = {}));
|
|
38
|
-
exports.prefix =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
37
|
+
exports.prefix = {
|
|
38
|
+
[Prefix.TZ1]: new Uint8Array([6, 161, 159]),
|
|
39
|
+
[Prefix.TZ2]: new Uint8Array([6, 161, 161]),
|
|
40
|
+
[Prefix.TZ3]: new Uint8Array([6, 161, 164]),
|
|
41
|
+
[Prefix.KT]: new Uint8Array([2, 90, 121]),
|
|
42
|
+
[Prefix.KT1]: new Uint8Array([2, 90, 121]),
|
|
43
|
+
[Prefix.EDSK]: new Uint8Array([43, 246, 78, 7]),
|
|
44
|
+
[Prefix.EDSK2]: new Uint8Array([13, 15, 58, 7]),
|
|
45
|
+
[Prefix.SPSK]: new Uint8Array([17, 162, 224, 201]),
|
|
46
|
+
[Prefix.P2SK]: new Uint8Array([16, 81, 238, 189]),
|
|
47
|
+
[Prefix.EDPK]: new Uint8Array([13, 15, 37, 217]),
|
|
48
|
+
[Prefix.SPPK]: new Uint8Array([3, 254, 226, 86]),
|
|
49
|
+
[Prefix.P2PK]: new Uint8Array([3, 178, 139, 127]),
|
|
50
|
+
[Prefix.EDESK]: new Uint8Array([7, 90, 60, 179, 41]),
|
|
51
|
+
[Prefix.SPESK]: new Uint8Array([0x09, 0xed, 0xf1, 0xae, 0x96]),
|
|
52
|
+
[Prefix.P2ESK]: new Uint8Array([0x09, 0x30, 0x39, 0x73, 0xab]),
|
|
53
|
+
[Prefix.EDSIG]: new Uint8Array([9, 245, 205, 134, 18]),
|
|
54
|
+
[Prefix.SPSIG]: new Uint8Array([13, 115, 101, 19, 63]),
|
|
55
|
+
[Prefix.P2SIG]: new Uint8Array([54, 240, 44, 52]),
|
|
56
|
+
[Prefix.SIG]: new Uint8Array([4, 130, 43]),
|
|
57
|
+
[Prefix.NET]: new Uint8Array([87, 82, 0]),
|
|
58
|
+
[Prefix.NCE]: new Uint8Array([69, 220, 169]),
|
|
59
|
+
[Prefix.B]: new Uint8Array([1, 52]),
|
|
60
|
+
[Prefix.O]: new Uint8Array([5, 116]),
|
|
61
|
+
[Prefix.LO]: new Uint8Array([133, 233]),
|
|
62
|
+
[Prefix.LLO]: new Uint8Array([29, 159, 109]),
|
|
63
|
+
[Prefix.P]: new Uint8Array([2, 170]),
|
|
64
|
+
[Prefix.CO]: new Uint8Array([79, 179]),
|
|
65
|
+
[Prefix.ID]: new Uint8Array([153, 103]),
|
|
66
|
+
[Prefix.EXPR]: new Uint8Array([13, 44, 64, 27]),
|
|
68
67
|
// Legacy prefix
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
exports.prefixLength =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
68
|
+
[Prefix.TZ]: new Uint8Array([2, 90, 121]),
|
|
69
|
+
};
|
|
70
|
+
exports.prefixLength = {
|
|
71
|
+
[Prefix.TZ1]: 20,
|
|
72
|
+
[Prefix.TZ2]: 20,
|
|
73
|
+
[Prefix.TZ3]: 20,
|
|
74
|
+
[Prefix.KT]: 20,
|
|
75
|
+
[Prefix.KT1]: 20,
|
|
76
|
+
[Prefix.EDPK]: 32,
|
|
77
|
+
[Prefix.SPPK]: 33,
|
|
78
|
+
[Prefix.P2PK]: 33,
|
|
79
|
+
[Prefix.EDSIG]: 64,
|
|
80
|
+
[Prefix.SPSIG]: 64,
|
|
81
|
+
[Prefix.P2SIG]: 64,
|
|
82
|
+
[Prefix.SIG]: 64,
|
|
83
|
+
[Prefix.NET]: 4,
|
|
84
|
+
[Prefix.B]: 32,
|
|
85
|
+
[Prefix.P]: 32,
|
|
86
|
+
[Prefix.O]: 32
|
|
87
|
+
};
|
|
89
88
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,MAqCX;AArCD,WAAY,MAAM;IAChB,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,mBAAS,CAAA;IACT,qBAAW,CAAA;IAEX,yBAAe,CAAA;IACf,uBAAa,CAAA;IACb,uBAAa,CAAA;IAEb,uBAAa,CAAA;IACb,uBAAa,CAAA;IACb,uBAAa,CAAA;IAEb,yBAAe,CAAA;IACf,yBAAe,CAAA;IACf,yBAAe,CAAA;IAEf,uBAAa,CAAA;IACb,yBAAe,CAAA;IACf,yBAAe,CAAA;IACf,yBAAe,CAAA;IACf,qBAAW,CAAA;IAEX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,iBAAO,CAAA;IACP,iBAAO,CAAA;IACP,mBAAS,CAAA;IACT,qBAAW,CAAA;IACX,iBAAO,CAAA;IACP,mBAAS,CAAA;IACT,mBAAS,CAAA;IAET,uBAAa,CA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,GAAG,CAAC,EAAE,EAAE;IAChB,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE;IACf,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE;IAChB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE;IACjB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE;IACjB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE;IACjB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;IAClB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;IAClB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;IAClB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE;IAChB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACf,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;IACd,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;IACd,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;CACf,CAAC"}
|
package/dist/lib/errors.js
CHANGED
|
@@ -1,28 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidMessageError = exports.InvalidSignatureError = exports.InvalidPublicKeyError = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.InvalidOperationHashError = exports.InvalidProtocolHashError = exports.InvalidBlockHashError = exports.InvalidKeyHashError = exports.InvalidAddressError = exports.InvalidContractAddressError = exports.InvalidMessageError = exports.InvalidSignatureError = exports.InvalidPublicKeyError = void 0;
|
|
4
|
+
class InvalidPublicKeyError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
6
7
|
this.message = message;
|
|
7
8
|
this.name = 'InvalidPublicKeyError';
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
}());
|
|
10
|
+
}
|
|
11
11
|
exports.InvalidPublicKeyError = InvalidPublicKeyError;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
class InvalidSignatureError extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
14
15
|
this.message = message;
|
|
15
16
|
this.name = 'InvalidSignatureError';
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
}());
|
|
18
|
+
}
|
|
19
19
|
exports.InvalidSignatureError = InvalidSignatureError;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
class InvalidMessageError extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
22
23
|
this.message = message;
|
|
23
24
|
this.name = 'InvalidMessageError';
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
}());
|
|
26
|
+
}
|
|
27
27
|
exports.InvalidMessageError = InvalidMessageError;
|
|
28
|
+
class InvalidContractAddressError extends Error {
|
|
29
|
+
constructor(message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.message = message;
|
|
32
|
+
this.name = 'InvalidContractAddressError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.InvalidContractAddressError = InvalidContractAddressError;
|
|
36
|
+
class InvalidAddressError extends Error {
|
|
37
|
+
constructor(message) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.message = message;
|
|
40
|
+
this.name = 'InvalidAddressError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.InvalidAddressError = InvalidAddressError;
|
|
44
|
+
class InvalidKeyHashError extends Error {
|
|
45
|
+
constructor(message) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.message = message;
|
|
48
|
+
this.name = 'InvalidKeyHashError';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.InvalidKeyHashError = InvalidKeyHashError;
|
|
52
|
+
class InvalidBlockHashError extends Error {
|
|
53
|
+
constructor(message) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.message = message;
|
|
56
|
+
this.name = 'InvalidBlockHashError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.InvalidBlockHashError = InvalidBlockHashError;
|
|
60
|
+
class InvalidProtocolHashError extends Error {
|
|
61
|
+
constructor(message) {
|
|
62
|
+
super(message);
|
|
63
|
+
this.message = message;
|
|
64
|
+
this.name = 'InvalidProtocolHashError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.InvalidProtocolHashError = InvalidProtocolHashError;
|
|
68
|
+
class InvalidOperationHashError extends Error {
|
|
69
|
+
constructor(message) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.message = message;
|
|
72
|
+
this.name = 'InvalidOperationHashError';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.InvalidOperationHashError = InvalidOperationHashError;
|
|
28
76
|
//# sourceMappingURL=errors.js.map
|
package/dist/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAsB,SAAQ,KAAK;IAE9C,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAA;QADG,YAAO,GAAP,OAAO,CAAQ;QAD3B,SAAI,GAAG,uBAAuB,CAAC;IAGtC,CAAC;CACF;AALD,sDAKC;AAED,MAAa,qBAAsB,SAAQ,KAAK;IAE9C,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAA;QADG,YAAO,GAAP,OAAO,CAAQ;QAD3B,SAAI,GAAG,uBAAuB,CAAC;IAGtC,CAAC;CACF;AALD,sDAKC;AAED,MAAa,mBAAoB,SAAQ,KAAK;IAE5C,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAA;QADG,YAAO,GAAP,OAAO,CAAQ;QAD3B,SAAI,GAAG,qBAAqB,CAAC;IAGpC,CAA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