@tezos-x/octez.js-core 0.9.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 ADDED
@@ -0,0 +1,13 @@
1
+ # octez.js Core package
2
+
3
+ **Maintained by [Nomadic Labs](https://www.nomadic-labs.com/).**
4
+
5
+ `@tezos-x/octez.js-core` contains classes and interfaces used across octez.js packages to avoid circular dependencies.
6
+
7
+ ## Additional info
8
+
9
+ See the top-level [https://github.com/trilitech/octez.js](https://github.com/trilitech/octez.js) file for details on reporting issues, contributing and versioning.
10
+
11
+ ## Disclaimer
12
+
13
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,351 @@
1
+ "use strict";
2
+ // ==========================================================================================
3
+ // parent error classes for octez.js
4
+ // ==========================================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PublicKeyNotFoundError = exports.ProhibitedActionError = exports.DeprecationError = exports.InvalidOperationKindError = exports.InvalidOperationHashError = exports.InvalidKeyHashError = exports.InvalidChainIdError = exports.InvalidContractAddressError = exports.InvalidSignatureError = exports.InvalidPublicKeyError = exports.InvalidKeyError = exports.InvalidViewParameterError = exports.InvalidMessageError = exports.InvalidHexStringError = exports.InvalidDerivationPathError = exports.InvalidAmountError = exports.InvalidBlockHashError = exports.InvalidFinalizeUnstakeAmountError = exports.InvalidStakingAddressError = exports.InvalidProofError = exports.InvalidAddressError = exports.PermissionDeniedError = exports.NetworkError = exports.UnsupportedActionError = exports.TezosToolkitConfigError = exports.RpcError = exports.ParameterValidationError = exports.TaquitoError = exports.ValidationResult = void 0;
7
+ var ValidationResult;
8
+ (function (ValidationResult) {
9
+ ValidationResult[ValidationResult["NO_PREFIX_MATCHED"] = 0] = "NO_PREFIX_MATCHED";
10
+ ValidationResult[ValidationResult["INVALID_CHECKSUM"] = 1] = "INVALID_CHECKSUM";
11
+ ValidationResult[ValidationResult["INVALID_LENGTH"] = 2] = "INVALID_LENGTH";
12
+ ValidationResult[ValidationResult["VALID"] = 3] = "VALID";
13
+ ValidationResult[ValidationResult["PREFIX_NOT_ALLOWED"] = 4] = "PREFIX_NOT_ALLOWED";
14
+ ValidationResult[ValidationResult["INVALID_ENCODING"] = 5] = "INVALID_ENCODING";
15
+ ValidationResult[ValidationResult["OTHER"] = 6] = "OTHER";
16
+ })(ValidationResult || (exports.ValidationResult = ValidationResult = {}));
17
+ const resultDesc = {
18
+ [ValidationResult.NO_PREFIX_MATCHED]: 'unsupported Base58 prefix',
19
+ [ValidationResult.INVALID_CHECKSUM]: 'invalid checksum',
20
+ [ValidationResult.INVALID_LENGTH]: 'invalid length',
21
+ [ValidationResult.PREFIX_NOT_ALLOWED]: 'Base58 prefix not allowed in this context',
22
+ [ValidationResult.INVALID_ENCODING]: 'invalid Base58 encoding',
23
+ };
24
+ /**
25
+ * @category Error
26
+ * @description Parent error class all octez.js errors to extend from
27
+ */
28
+ class TaquitoError extends Error {
29
+ }
30
+ exports.TaquitoError = TaquitoError;
31
+ /**
32
+ * @category Error
33
+ * @description Error that indicates invalid user inputs
34
+ */
35
+ class ParameterValidationError extends TaquitoError {
36
+ constructor(message, validationResult, errorDetail) {
37
+ let detail;
38
+ let result;
39
+ let msg;
40
+ if (message !== undefined) {
41
+ if (typeof message === 'string') {
42
+ msg = message;
43
+ if (validationResult !== undefined) {
44
+ if (typeof validationResult === 'string') {
45
+ detail = validationResult;
46
+ }
47
+ else {
48
+ result = validationResult;
49
+ if (errorDetail !== undefined) {
50
+ detail = errorDetail;
51
+ }
52
+ else {
53
+ detail = resultDesc[validationResult];
54
+ }
55
+ }
56
+ }
57
+ }
58
+ else {
59
+ result = message;
60
+ detail = resultDesc[message];
61
+ msg = detail;
62
+ }
63
+ }
64
+ super(msg);
65
+ this.name = this.constructor.name;
66
+ this.result = result;
67
+ this.errorDetail = detail;
68
+ }
69
+ }
70
+ exports.ParameterValidationError = ParameterValidationError;
71
+ /**
72
+ * @category Error
73
+ * @description Error returned by RPC node
74
+ */
75
+ class RpcError extends TaquitoError {
76
+ }
77
+ exports.RpcError = RpcError;
78
+ /**
79
+ * @category Error
80
+ * @description Error that indicates TezosToolKit has not been configured appropriately
81
+ */
82
+ class TezosToolkitConfigError extends TaquitoError {
83
+ }
84
+ exports.TezosToolkitConfigError = TezosToolkitConfigError;
85
+ /**
86
+ * @category Error
87
+ * @description Error that indicates a requested action is not supported by octez.js
88
+ */
89
+ class UnsupportedActionError extends TaquitoError {
90
+ }
91
+ exports.UnsupportedActionError = UnsupportedActionError;
92
+ /**
93
+ * @category Error
94
+ * @description Error during a network operation
95
+ */
96
+ class NetworkError extends TaquitoError {
97
+ }
98
+ exports.NetworkError = NetworkError;
99
+ /**
100
+ * @category Error
101
+ * @description Error that indicates user attempts an action without necessary permissions
102
+ */
103
+ class PermissionDeniedError extends TaquitoError {
104
+ }
105
+ exports.PermissionDeniedError = PermissionDeniedError;
106
+ // ==========================================================================================
107
+ // common error classes for octez.js
108
+ // ==========================================================================================
109
+ /**
110
+ * @category Error
111
+ * @description Error that indicates an invalid originated or implicit address being passed or used
112
+ */
113
+ class InvalidAddressError extends ParameterValidationError {
114
+ constructor(address, errorDetail) {
115
+ super(`Invalid address "${address}"`, errorDetail);
116
+ this.address = address;
117
+ this.name = this.constructor.name;
118
+ }
119
+ }
120
+ exports.InvalidAddressError = InvalidAddressError;
121
+ class InvalidProofError extends ParameterValidationError {
122
+ constructor(proof, errorDetail) {
123
+ super(`Invalid proof "${proof}"`, errorDetail);
124
+ this.proof = proof;
125
+ this.name = this.constructor.name;
126
+ }
127
+ }
128
+ exports.InvalidProofError = InvalidProofError;
129
+ class InvalidStakingAddressError extends ParameterValidationError {
130
+ constructor(address, errorDetail) {
131
+ super(`Invalid staking address "${address}", you can only set destination as your own address`, errorDetail);
132
+ this.address = address;
133
+ this.name = this.constructor.name;
134
+ }
135
+ }
136
+ exports.InvalidStakingAddressError = InvalidStakingAddressError;
137
+ class InvalidFinalizeUnstakeAmountError extends ParameterValidationError {
138
+ constructor(address, errorDetail) {
139
+ super(`The amount can only be 0 when finalizing an unstake`, errorDetail);
140
+ this.address = address;
141
+ this.name = this.constructor.name;
142
+ }
143
+ }
144
+ exports.InvalidFinalizeUnstakeAmountError = InvalidFinalizeUnstakeAmountError;
145
+ /**
146
+ * @category Error
147
+ * @description Error that indicates an invalid block hash being passed or used
148
+ */
149
+ class InvalidBlockHashError extends ParameterValidationError {
150
+ constructor(blockHash, errorDetail) {
151
+ super(`Invalid block hash "${blockHash}"`, errorDetail);
152
+ this.blockHash = blockHash;
153
+ this.name = this.constructor.name;
154
+ }
155
+ }
156
+ exports.InvalidBlockHashError = InvalidBlockHashError;
157
+ /**
158
+ * @category Error
159
+ * @description Error that indicates an invalid amount of tez being passed as a parameter
160
+ */
161
+ class InvalidAmountError extends ParameterValidationError {
162
+ constructor(amount, errorDetail) {
163
+ super(`Invalid amount "${amount}"`, errorDetail);
164
+ this.amount = amount;
165
+ this.name = this.constructor.name;
166
+ }
167
+ }
168
+ exports.InvalidAmountError = InvalidAmountError;
169
+ /**
170
+ * @category Error
171
+ * @description Error that indicates an invalid derivation path being passed or used
172
+ */
173
+ class InvalidDerivationPathError extends ParameterValidationError {
174
+ constructor(derivationPath, errorDetail) {
175
+ super(`Invalid derivation path "${derivationPath}"`, errorDetail);
176
+ this.derivationPath = derivationPath;
177
+ this.name = this.constructor.name;
178
+ }
179
+ }
180
+ exports.InvalidDerivationPathError = InvalidDerivationPathError;
181
+ /**
182
+ * @category Error
183
+ * @description Error that indicates an invalid hex string have been passed or used
184
+ */
185
+ class InvalidHexStringError extends ParameterValidationError {
186
+ constructor(hexString, errorDetail) {
187
+ super(`Invalid hex string "${hexString}"`, errorDetail);
188
+ this.hexString = hexString;
189
+ this.name = this.constructor.name;
190
+ }
191
+ }
192
+ exports.InvalidHexStringError = InvalidHexStringError;
193
+ /**
194
+ * @category Error
195
+ * @description Error that indicates an invalid message being passed or used
196
+ */
197
+ class InvalidMessageError extends ParameterValidationError {
198
+ constructor(msg, errorDetail) {
199
+ super(`Invalid message "${msg}"`, errorDetail);
200
+ this.msg = msg;
201
+ this.name = this.constructor.name;
202
+ }
203
+ }
204
+ exports.InvalidMessageError = InvalidMessageError;
205
+ /**
206
+ * @category Error
207
+ * @description Error that indicates invalid view parameter of a smart contract
208
+ */
209
+ class InvalidViewParameterError extends ParameterValidationError {
210
+ constructor(viewName, sigs, args, cause, errorDetail) {
211
+ const message = `Invalid view arguments ${JSON.stringify(args)} received for name "${viewName}" expecting one of the following signatures ${JSON.stringify(sigs)}.`;
212
+ super(message, errorDetail);
213
+ this.viewName = viewName;
214
+ this.sigs = sigs;
215
+ this.args = args;
216
+ this.cause = cause;
217
+ this.name = this.constructor.name;
218
+ }
219
+ }
220
+ exports.InvalidViewParameterError = InvalidViewParameterError;
221
+ /**
222
+ * @category Error
223
+ * @description Error that indicates an invalid private key being passed or used
224
+ */
225
+ class InvalidKeyError extends ParameterValidationError {
226
+ constructor(errorDetail) {
227
+ super(`Invalid private key`, errorDetail);
228
+ this.name = this.constructor.name;
229
+ }
230
+ }
231
+ exports.InvalidKeyError = InvalidKeyError;
232
+ /**
233
+ * @category Error
234
+ * @description Error that indicates an Invalid Public Key being passed or used
235
+ */
236
+ class InvalidPublicKeyError extends ParameterValidationError {
237
+ constructor(publicKey, errorDetail) {
238
+ const msg = publicKey !== undefined ? `Invalid public key "${publicKey}"` : `Invalid public key`;
239
+ super(msg, errorDetail);
240
+ this.publicKey = publicKey;
241
+ this.name = this.constructor.name;
242
+ }
243
+ }
244
+ exports.InvalidPublicKeyError = InvalidPublicKeyError;
245
+ /**
246
+ * @category Error
247
+ * @description Error that indicates an invalid signature being passed or used
248
+ */
249
+ class InvalidSignatureError extends ParameterValidationError {
250
+ constructor(signature, errorDetail) {
251
+ super(`Invalid signature "${signature}"`, errorDetail);
252
+ this.signature = signature;
253
+ this.name = this.constructor.name;
254
+ }
255
+ }
256
+ exports.InvalidSignatureError = InvalidSignatureError;
257
+ /**
258
+ * @category Error
259
+ * @description Error that indicates an invalid contract address being passed or used
260
+ */
261
+ class InvalidContractAddressError extends ParameterValidationError {
262
+ constructor(contractAddress, errorDetail) {
263
+ super(`Invalid contract address "${contractAddress}"`, errorDetail);
264
+ this.contractAddress = contractAddress;
265
+ this.name = this.constructor.name;
266
+ }
267
+ }
268
+ exports.InvalidContractAddressError = InvalidContractAddressError;
269
+ /**
270
+ * @category Error
271
+ * @description Error that indicates an invalid chain id being passed or used
272
+ */
273
+ class InvalidChainIdError extends ParameterValidationError {
274
+ constructor(chainId, errorDetail) {
275
+ super(`Invalid chain id "${chainId}"`, errorDetail);
276
+ this.chainId = chainId;
277
+ this.name = this.constructor.name;
278
+ }
279
+ }
280
+ exports.InvalidChainIdError = InvalidChainIdError;
281
+ /**
282
+ * @category Error
283
+ * @description Error that indicates an invalid public key hash being passed or used
284
+ */
285
+ class InvalidKeyHashError extends ParameterValidationError {
286
+ constructor(keyHash, errorDetail) {
287
+ super(`Invalid public key hash "${keyHash}"`, errorDetail);
288
+ this.keyHash = keyHash;
289
+ this.name = this.constructor.name;
290
+ }
291
+ }
292
+ exports.InvalidKeyHashError = InvalidKeyHashError;
293
+ /**
294
+ * @category Error
295
+ * @description Error that indicates an invalid operation hash being passed or used
296
+ */
297
+ class InvalidOperationHashError extends ParameterValidationError {
298
+ constructor(operationHash, errorDetail) {
299
+ super(`Invalid operation hash "${operationHash}"`, errorDetail);
300
+ this.operationHash = operationHash;
301
+ this.name = this.constructor.name;
302
+ }
303
+ }
304
+ exports.InvalidOperationHashError = InvalidOperationHashError;
305
+ /**
306
+ * @category Error
307
+ * @description Error that indicates an invalid operation kind being passed or used
308
+ */
309
+ class InvalidOperationKindError extends ParameterValidationError {
310
+ constructor(operationKind, errorDetail) {
311
+ super(`Invalid operation kind "${operationKind}"`, errorDetail);
312
+ this.operationKind = operationKind;
313
+ this.name = this.constructor.name;
314
+ }
315
+ }
316
+ exports.InvalidOperationKindError = InvalidOperationKindError;
317
+ /**
318
+ * @category Error
319
+ * @description General error that indicates something is no longer supported and/or deprecated
320
+ */
321
+ class DeprecationError extends UnsupportedActionError {
322
+ constructor(message) {
323
+ super(message);
324
+ this.name = this.constructor.name;
325
+ }
326
+ }
327
+ exports.DeprecationError = DeprecationError;
328
+ /**
329
+ * @category Error
330
+ * @description General error that indicates an action is prohibited or not allowed
331
+ */
332
+ class ProhibitedActionError extends UnsupportedActionError {
333
+ constructor(message) {
334
+ super(message);
335
+ this.name = this.constructor.name;
336
+ }
337
+ }
338
+ exports.ProhibitedActionError = ProhibitedActionError;
339
+ /**
340
+ * @category Error
341
+ * @description Error that indicates a failure in grabbing the public key
342
+ */
343
+ class PublicKeyNotFoundError extends TaquitoError {
344
+ constructor(pkh, cause) {
345
+ super(`Public key not found of this address "${pkh}" in either wallet or contract API.`);
346
+ this.pkh = pkh;
347
+ this.cause = cause;
348
+ this.name = this.constructor.name;
349
+ }
350
+ }
351
+ exports.PublicKeyNotFoundError = PublicKeyNotFoundError;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * @packageDocumentation
4
+ * @module @tezos-x/octez.js-core
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ __exportStar(require("./errors"), exports);
22
+ __exportStar(require("./signer-interfaces"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = void 0;
4
+ // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
5
+ exports.VERSION = {
6
+ "commitHash": "f798e97ba998acc2cc5310278d812448591bd312",
7
+ "version": "24.0.2"
8
+ };