Socket
Socket
Sign inDemoInstall

@taquito/michelson-encoder

Package Overview
Dependencies
Maintainers
6
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taquito/michelson-encoder - npm Package Compare versions

Comparing version 17.1.0-beta-RC.0 to 17.1.0-beta-RC.1

dist/lib/schema/errors.js

78

dist/lib/michelson-map.js

@@ -7,2 +7,3 @@ "use strict";

const fast_json_stable_stringify_1 = require("fast-json-stable-stringify");
const core_1 = require("@taquito/core");
/**

@@ -12,6 +13,8 @@ * @category Error

*/
class InvalidMapTypeError extends Error {
constructor(mapType) {
super(`The map type '${mapType}' is invalid`);
class InvalidMapTypeError extends core_1.TaquitoError {
constructor(mapType, reason) {
super();
this.mapType = mapType;
this.reason = reason;
this.message = `The map type '${JSON.stringify(mapType)}' is invalid. Reason: ${reason}.`;
this.name = 'InvalidMapTypeError';

@@ -24,15 +27,36 @@ }

const michelsonMapTypeSymbol = Symbol.for('taquito-michelson-map-type-symbol');
const isMapType = (value) => {
return 'args' in value && Array.isArray(value.args) && value.args.length === 2;
};
/**
*
* @throws {@link InvalidMapTypeError} when the argument passed to mapType is not a valid map type
*/
function validateMapType(value) {
if (!('prim' in value)) {
throw new InvalidMapTypeError(value, `Missing 'prim' field`);
}
if (!['map', 'big_map'].includes(value.prim)) {
throw new InvalidMapTypeError(value, `The prim field should be 'map' or 'big_map'`);
}
if (!('args' in value)) {
throw new InvalidMapTypeError(value, `Missing 'args' field`);
}
if (!Array.isArray(value.args)) {
throw new InvalidMapTypeError(value, `The 'args' field should be an array`);
}
if (value.args.length !== 2) {
throw new InvalidMapTypeError(value, `The 'args' field should have 2 elements`);
}
}
/**
* @category Error
* @description Error that indicates a map type mismatch, where an attempt to set a key or value in a Map doesn't match the defined type of the Map
*/
class MapTypecheckError extends Error {
constructor(value, type, errorType) {
super(`${errorType} not compliant with underlying michelson type`);
class MapTypecheckError extends core_1.TaquitoError {
constructor(value, type, objectType, reason) {
super();
this.value = value;
this.type = type;
this.reason = reason;
this.name = 'MapTypecheckError';
this.message = `The ${objectType} provided: ${JSON.stringify(value)} is not compatible with the expected michelson type: ${JSON.stringify(type)}. Reason: ${JSON.stringify(reason)}.`;
this.name = 'MapTypecheckError';
}

@@ -65,5 +89,3 @@ }

setType(mapType) {
if (!isMapType(mapType)) {
throw new InvalidMapTypeError(mapType.toString());
}
validateMapType(mapType);
this.keySchema = new storage_1.Schema(mapType.args[0]);

@@ -84,22 +106,34 @@ this.valueSchema = new storage_1.Schema(mapType.args[1]);

typecheckKey(key) {
if (this.keySchema) {
return this.keySchema.Typecheck(key);
if (!this.keySchema) {
return;
}
return true;
this.keySchema.Typecheck(key);
}
typecheckValue(value) {
if (this.valueSchema) {
return this.valueSchema.Typecheck(value);
if (!this.valueSchema) {
return;
}
return true;
this.valueSchema.Typecheck(value);
}
/**
* @throws {@link MapTypecheckError} when the argument passed does not match the expected schema for value
*/
assertTypecheckValue(value) {
if (!this.typecheckValue(value)) {
throw new MapTypecheckError(value, this.valueSchema, 'value');
try {
this.typecheckValue(value);
}
catch (e) {
throw new MapTypecheckError(value, this.valueSchema, 'value', e);
}
}
/**
* @throws {@link MapTypecheckError} when the argument passed does not match the expected schema for key
*/
assertTypecheckKey(key) {
if (!this.typecheckKey(key)) {
throw new MapTypecheckError(key, this.keySchema, 'key');
try {
this.typecheckKey(key);
}
catch (e) {
throw new MapTypecheckError(key, this.keySchema, 'key', e);
}
}

@@ -106,0 +140,0 @@ serializeDeterministically(key) {

@@ -8,3 +8,3 @@ "use strict";

const option_1 = require("../tokens/option");
const error_1 = require("./error");
const errors_1 = require("./errors");
/**

@@ -14,15 +14,39 @@ * @warn Our current smart contract abstraction feature is currently in preview. It's API is not final, and it may not cover every use case (yet). We will greatly appreciate any feedback on this feature.

class ParameterSchema {
/**
* @description Return the schema of the parameter of a specific entry point
* @throws {@link InvalidTokenError}
*/
constructor(val) {
this.root = createToken_1.createToken(val, 0);
}
/**
*
* @description Create an instance of ParameterSchema from a contract script
*
* @param val contract script obtained from the RPC
* @returns ParameterSchema
* @throws {InvalidRpcResponseError} If the RPC response is invalid
*/
static fromRPCResponse(val) {
const parameter = val &&
val.script &&
Array.isArray(val.script.code) &&
val.script.code.find((x) => x.prim === 'parameter');
if (!parameter || !Array.isArray(parameter.args)) {
throw new error_1.InvalidRpcResponseError(val.script);
if (!val) {
throw new errors_1.InvalidRpcResponseError(val, 'the RPC response is empty');
}
if (!val.script) {
throw new errors_1.InvalidRpcResponseError(val, 'the RPC response has no script');
}
if (!Array.isArray(val.script.code)) {
throw new errors_1.InvalidRpcResponseError(val, 'The response.script.code should be an array');
}
const parameter = val.script.code.find((x) => 'prim' in x && x.prim === 'parameter');
if (!parameter) {
throw new errors_1.InvalidRpcResponseError(val, `The response.script.code should have an element of type {prim: "parameter"}`);
}
if (!Array.isArray(parameter.args)) {
throw new errors_1.InvalidRpcResponseError(val, `The response.script.code has an element of type {prim: "parameter"}, but its args is not an array`);
}
return new ParameterSchema(parameter.args[0]);
}
/**
* @description Check if the Contract parameter is multiple entry point or not
*/
get isMultipleEntryPoint() {

@@ -32,2 +56,5 @@ return (this.root instanceof or_1.OrToken ||

}
/**
* @description Check if the Contract parameter has an annotation or not
*/
get hasAnnotation() {

@@ -41,5 +68,13 @@ if (this.isMultipleEntryPoint) {

}
/**
* @description Returns the javascript object equivalent of the Micheline value provided
*/
Execute(val, semantics) {
return this.root.Execute(val, semantics);
}
/**
* @description Returns a micheline formatted object for the values provided
* @throws {@link TokenValidationError}
* @throws {@link ParameterEncodingError}
*/
Encode(...args) {

@@ -53,5 +88,10 @@ try {

}
throw new error_1.ParameterEncodingError('Unable to encode parameter', args.toString(), ex);
throw new errors_1.ParameterEncodingError('Unable to encode parameter', this.root, args, ex);
}
}
/**
* @description Returns a micheline formatted object for the javascript object provided
* @throws {@link TokenValidationError}
* @throws {@link ParameterEncodingError}
*/
EncodeObject(value, semantics) {

@@ -65,3 +105,3 @@ try {

}
throw new error_1.ParameterEncodingError('Unable to encode parameter object', value, ex);
throw new errors_1.ParameterEncodingError('Unable to encode parameter object', this.root, value, ex);
}

@@ -68,0 +108,0 @@ }

@@ -13,3 +13,3 @@ "use strict";

const token_1 = require("../tokens/token");
const error_1 = require("./error");
const errors_1 = require("./errors");
const schemaTypeSymbol = Symbol.for('taquito-schema-type-symbol');

@@ -57,3 +57,3 @@ // collapse comb pair

/**
* @warn Our current smart contract abstraction feature is currently in preview. It's API is not final, and it may not cover every use case (yet). We will greatly appreciate any feedback on this feature.
* @warn Our current smart contract abstraction feature is currently in preview. Its API is not final, and it may not cover every use case (yet). We will greatly appreciate any feedback on this feature.
*/

@@ -78,23 +78,22 @@ class Schema {

}
/**
* @throws {@link InvalidRpcResponseError}
*/
static fromRPCResponse(val) {
const storage = val &&
val.script &&
Array.isArray(val.script.code) &&
val.script.code.find((x) => {
if (!Array.isArray(x)) {
const checkExtended = x;
if (checkExtended.prim) {
return checkExtended.prim === 'storage';
}
else {
return false;
}
}
else {
// storage passed along as original storage value
this.fromRPCResponse({ script: { code: x, storage: val.script.storage } });
}
});
if (!val) {
throw new errors_1.InvalidRpcResponseError(val, 'the RPC response is empty');
}
if (!val.script) {
throw new errors_1.InvalidRpcResponseError(val, 'the RPC response has no script');
}
if (!Array.isArray(val.script.code)) {
throw new errors_1.InvalidRpcResponseError(val, 'The response.script.code should be an array');
}
let code = val.script.code;
while (code.length === 1 && Array.isArray(code[0])) {
code = code[0];
}
const storage = code.find((x) => 'prim' in x && x.prim === 'storage');
if (!storage || !Array.isArray(storage.args)) {
throw new error_1.InvalidRpcResponseError(val.script);
throw new errors_1.InvalidRpcResponseError(val, 'The response.script.code has an element of type {prim: "storage"}, but its args is not an array');
}

@@ -121,27 +120,25 @@ return new Schema(storage.args[0]);

if (this.root instanceof bigmap_1.BigMapToken && Number.isInteger(Number(val))) {
return true;
return;
}
if (this.root instanceof ticket_1.TicketToken && val.ticketer && val.value && val.amount) {
return true;
return;
}
if (this.root instanceof ticket_deprecated_1.TicketDeprecatedToken && val.ticketer && val.value && val.amount) {
return true;
return;
}
if (this.root instanceof map_1.MapToken && this.root.ValueSchema instanceof bigmap_1.BigMapToken) {
return true;
return;
}
try {
this.root.EncodeObject(val);
return true;
}
catch (ex) {
return false;
}
this.root.EncodeObject(val);
}
/**
* @throws {@link InvalidBigMapSchemaError}
* @throws {@link InvalidBigMapDiffError}
*/
ExecuteOnBigMapDiff(diff, semantics) {
if (!this.bigMap) {
throw new error_1.InvalidBigMapSchema('Big map schema is undefined');
throw new errors_1.InvalidBigMapSchemaError('Big map schema is undefined');
}
if (!Array.isArray(diff)) {
throw new error_1.InvalidBigMapDiff('Big map diff must be an array');
throw new errors_1.InvalidBigMapDiffError(`Big map diff must be an array, got: ${JSON.stringify(diff)}`, diff);
}

@@ -151,11 +148,18 @@ const eltFormat = diff.map(({ key, value }) => ({ args: [key, value] }));

}
/**
* @throws {@link InvalidBigMapSchemaError}
*/
ExecuteOnBigMapValue(key, semantics) {
if (!this.bigMap) {
throw new error_1.InvalidBigMapSchema('No big map schema');
throw new errors_1.InvalidBigMapSchemaError('Big map schema is undefined');
}
return this.bigMap.ValueSchema.Execute(key, semantics);
}
/**
* @throws {@link InvalidBigMapSchemaError}
* @throws {@link BigMapEncodingError}
*/
EncodeBigMapKey(key) {
if (!this.bigMap) {
throw new error_1.InvalidBigMapSchema('Big map schema is undefined');
throw new errors_1.InvalidBigMapSchemaError('Big map schema is undefined');
}

@@ -166,5 +170,9 @@ try {

catch (ex) {
throw new error_1.BigMapEncodingError('big map key', ex);
throw new errors_1.BigMapEncodingError('key', ex, this.bigMap.KeySchema, key);
}
}
/**
* @throws {@link TokenValidationError}
* @throws {@link StorageEncodingError}
*/
Encode(value, semantics) {

@@ -178,3 +186,3 @@ try {

}
throw new error_1.StorageEncodingError('storage object', ex);
throw new errors_1.StorageEncodingError('storage object', ex, this.root, value, semantics);
}

@@ -198,6 +206,7 @@ }

* @deprecated
* @throws {@link InvalidBigMapSchemaError}
*/
ComputeState(tx, state) {
if (!this.bigMap) {
throw new error_1.InvalidBigMapSchema('Big map schema is undefined');
throw new errors_1.InvalidBigMapSchemaError('Big map schema is undefined');
}

@@ -222,2 +231,5 @@ const bigMap = tx.reduce((prev, current) => {

// TODO check these type casts
/**
* @throws {@link MissingArgumentError}
*/
findValue(schema, storage, valueToFind) {

@@ -231,3 +243,3 @@ if (deepEqual(valueToFind, schema)) {

if (sch.args === undefined || strg.args === undefined) {
throw new error_1.MissingArgumentError('Tokens have no arguments'); // unlikely
throw new errors_1.MissingArgumentError('Tokens have no arguments'); // unlikely
}

@@ -234,0 +246,0 @@ if (sch.args[0])

@@ -5,13 +5,21 @@ "use strict";

const createToken_1 = require("../tokens/createToken");
const error_1 = require("./error");
const errors_1 = require("./errors");
class ViewSchema {
constructor(val) {
if (val.length !== 4 || !('string' in val[0])) {
throw new error_1.InvalidScriptError(`Invalid on-chain view: ${JSON.stringify(val)}`);
/**
* @throws {@link InvalidScriptError}
*/
constructor(viewArgs) {
if (!viewArgs) {
throw new errors_1.InvalidScriptError(viewArgs, 'the args are not defined');
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.viewName = val[0]['string'];
this.viewArgsType = val[1];
this.viewReturnType = val[2];
this.instructions = val[3];
if (viewArgs.length !== 4) {
throw new errors_1.InvalidScriptError(viewArgs, `there should be exactly 4 arguments`);
}
if (!('string' in viewArgs[0]) || !viewArgs[0]['string']) {
throw new errors_1.InvalidScriptError(viewArgs, `The first argument should be a string, representing the view name. It should be in the form: { string: 'viewName' }`);
}
this.viewName = viewArgs[0]['string'];
this.viewArgsType = viewArgs[1];
this.viewReturnType = viewArgs[2];
this.instructions = viewArgs[3];
this.rootArgsType = createToken_1.createToken(this.viewArgsType, 0);

@@ -26,2 +34,3 @@ this.rootReturnType = createToken_1.createToken(this.viewReturnType, 0);

* @returns array of ViewSchema or empty array if there is no view in the contract
* @throws {@link InvalidScriptError}
*/

@@ -36,5 +45,2 @@ static fromRPCResponse(val) {

views.forEach((view) => {
if (!view.args || view.args.length !== 4) {
throw new error_1.InvalidScriptError(`Invalid on-chain view found in the script: ${JSON.stringify(view)}`);
}
allViewSchema.push(new ViewSchema(view.args));

@@ -51,2 +57,3 @@ });

* @returns parameter of the view in Michelson
* @throws {@link ParameterEncodingError}
*/

@@ -58,3 +65,3 @@ encodeViewArgs(args) {

catch (ex) {
throw new error_1.ViewEncodingError(this.viewName, ex);
throw new errors_1.ParameterEncodingError(this.viewName, undefined, args, ex);
}

@@ -61,0 +68,0 @@ }

@@ -22,3 +22,3 @@ "use strict";

__exportStar(require("./schema/event-schema"), exports);
__exportStar(require("./schema/error"), exports);
__exportStar(require("./schema/errors"), exports);
__exportStar(require("./schema/types"), exports);

@@ -25,0 +25,0 @@ __exportStar(require("./errors"), exports);

@@ -53,7 +53,9 @@ "use strict";

}
isValid(value) {
if (michelson_map_1.MichelsonMap.isMichelsonMap(value)) {
return null;
/**
* @throws {@link BigMapValidationError}
*/
validate(value) {
if (!michelson_map_1.MichelsonMap.isMichelsonMap(value)) {
throw new BigMapValidationError(value, this, `Value ${JSON.stringify(value)} is not a MichelsonMap`);
}
return new BigMapValidationError(value, this, 'Value must be a MichelsonMap');
}

@@ -73,8 +75,8 @@ objLitToMichelsonMap(val) {

}
/**
* @throws {@link BigMapValidationError}
*/
Encode(args) {
const val = this.objLitToMichelsonMap(args.pop());
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return Array.from(val.keys())

@@ -89,8 +91,8 @@ .sort((a, b) => this.KeySchema.compare(a, b))

}
/**
* @throws {@link BigMapValidationError}
*/
EncodeObject(args, semantic) {
const val = this.objLitToMichelsonMap(args);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[BigMapToken.prim]) {

@@ -108,2 +110,6 @@ return semantic[BigMapToken.prim](val, this.val);

}
/**
* @throws {@link InvalidMapTypeError} when the argument passed to val is an array but not a valid map type
* @throws {@link BigMapValidationError} when the value is invalid
*/
Execute(val, semantic) {

@@ -110,0 +116,0 @@ if (semantic && semantic[BigMapToken.prim]) {

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a BLS12-381 scalar field Fr
*/
class Bls12381frValidationError extends token_1.TokenValidationError {

@@ -22,9 +26,10 @@ constructor(value, token, message) {

}
isValid(val) {
/**
* @throws {@link Bls12381frValidationError}
*/
validate(val) {
if (/^[0-9a-fA-F]*$/.test(val) && val.length % 2 === 0) {
return null;
return;
}
else {
return new Bls12381frValidationError(val, this, `Invalid bytes: ${val}`);
}
throw new Bls12381frValidationError(val, this, `Invalid bytes: ${JSON.stringify(val)}`);
}

@@ -34,2 +39,5 @@ convertUint8ArrayToHexString(val) {

}
/**
* @throws {@link Bls12381frValidationError}
*/
Encode(args) {

@@ -42,9 +50,9 @@ let val = args.pop();

val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { bytes: val };
}
}
/**
* @throws {@link Bls12381frValidationError}
*/
EncodeObject(val, semantic) {

@@ -59,6 +67,3 @@ if (semantic && semantic[Bls12381frToken.prim]) {

val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { bytes: val };

@@ -65,0 +70,0 @@ }

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a BLS12-381 curve G1
*/
class Bls12381g1ValidationError extends token_1.TokenValidationError {

@@ -22,9 +26,10 @@ constructor(value, token, message) {

}
isValid(val) {
/**
* @throws {@link Bls12381g1ValidationError}
*/
validate(val) {
if (/^[0-9a-fA-F]*$/.test(val) && val.length % 2 === 0) {
return null;
return;
}
else {
return new Bls12381g1ValidationError(val, this, `Invalid bytes: ${val}`);
}
throw new Bls12381g1ValidationError(val, this, `Invalid bytes: ${JSON.stringify(val)}`);
}

@@ -34,17 +39,17 @@ convertUint8ArrayToHexString(val) {

}
/**
* @throws {@link Bls12381g1ValidationError}
*/
Encode(args) {
let val = args.pop();
val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { bytes: val };
}
/**
* @throws {@link Bls12381g1ValidationError}
*/
EncodeObject(val, semantic) {
val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[Bls12381g1Token.prim]) {

@@ -51,0 +56,0 @@ return semantic[Bls12381g1Token.prim](val);

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a BLS12-381 curve G2
*/
class Bls12381g2ValidationError extends token_1.TokenValidationError {

@@ -22,9 +26,10 @@ constructor(value, token, message) {

}
isValid(val) {
/**
* @throws {@link Bls12381g2ValidationError}
*/
validate(val) {
if (/^[0-9a-fA-F]*$/.test(val) && val.length % 2 === 0) {
return null;
return;
}
else {
return new Bls12381g2ValidationError(val, this, `Invalid bytes: ${val}`);
}
throw new Bls12381g2ValidationError(val, this, `Invalid bytes: ${JSON.stringify(val)}`);
}

@@ -34,17 +39,17 @@ convertUint8ArrayToHexString(val) {

}
/**
* @throws {@link Bls12381g2ValidationError}
*/
Encode(args) {
let val = args.pop();
val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { bytes: val };
}
/**
* @throws {@link Bls12381g2ValidationError}
*/
EncodeObject(val, semantic) {
val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[Bls12381g2Token.prim]) {

@@ -51,0 +56,0 @@ return semantic[Bls12381g2Token.prim](val);

@@ -6,2 +6,6 @@ "use strict";

const utils_1 = require("@taquito/utils");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a ChainID
*/
class ChainIDValidationError extends token_1.TokenValidationError {

@@ -23,7 +27,9 @@ constructor(value, token, message) {

}
isValid(value) {
/**
* @throws {@link ChainIDValidationError}
*/
validate(value) {
if (utils_1.validateChain(value) !== utils_1.ValidationResult.VALID) {
return new ChainIDValidationError(value, this, 'ChainID is not valid');
throw new ChainIDValidationError(value, this, `Value ${JSON.stringify(value)} is not a valid ChainID`);
}
return null;
}

@@ -46,15 +52,15 @@ Execute(val) {

}
/**
* @throws {@link ChainIDValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { string: val };
}
/**
* @throws {@link ChainIDValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[ChainIDToken.prim]) {

@@ -61,0 +67,0 @@ return semantic[ChainIDToken.prim](val);

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Chest Key
*/
class ChestKeyValidationError extends token_1.TokenValidationError {

@@ -22,9 +26,10 @@ constructor(value, token, message) {

}
isValid(val) {
/**
* @throws {@link ChestKeyValidationError}
*/
validate(val) {
if (/^[0-9a-fA-F]*$/.test(val) && val.length % 2 === 0) {
return null;
return;
}
else {
return new ChestKeyValidationError(val, this, `Invalid bytes: ${val}`);
}
throw new ChestKeyValidationError(val, this, `Invalid bytes: ${JSON.stringify(val)}`);
}

@@ -34,17 +39,17 @@ convertUint8ArrayToHexString(val) {

}
/**
* @throws {@link ChestKeyValidationError}
*/
Encode(args) {
let val = args.pop();
val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { bytes: val };
}
/**
* @throws {@link ChestKeyValidationError}
*/
EncodeObject(val, semantic) {
val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[ChestKeyToken.prim]) {

@@ -51,0 +56,0 @@ return semantic[ChestKeyToken.prim](val);

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Chest
*/
class ChestValidationError extends token_1.TokenValidationError {

@@ -22,9 +26,10 @@ constructor(value, token, message) {

}
isValid(val) {
if (/^[0-9a-fA-F]*$/.test(val) && val.length % 2 === 0) {
return null;
/**
* @throws {@link ChestKeyValidationError}
*/
validate(val) {
if (/^[0-9a-fA-F]*$/.test(val) && val.length % 2 == 0) {
return;
}
else {
return new ChestValidationError(val, this, `Invalid bytes: ${val}`);
}
throw new ChestValidationError(val, this, `Invalid bytes: ${JSON.stringify(val)}`);
}

@@ -34,17 +39,17 @@ convertUint8ArrayToHexString(val) {

}
/**
* @throws {@link ChestKeyValidationError}
*/
Encode(args) {
let val = args.pop();
val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { bytes: val };
}
/**
* @throws {@link ChestKeyValidationError}
*/
EncodeObject(val, semantic) {
val = this.convertUint8ArrayToHexString(val);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[ChestToken.prim]) {

@@ -51,0 +56,0 @@ return semantic[ChestToken.prim](val);

@@ -6,2 +6,6 @@ "use strict";

const utils_1 = require("@taquito/utils");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing an Address
*/
class AddressValidationError extends token_1.TokenValidationError {

@@ -30,21 +34,23 @@ constructor(value, token, message) {

}
isValid(value) {
/**
* @throws {@link AddressValidationError}
*/
validate(value) {
if (utils_1.validateAddress(value) !== utils_1.ValidationResult.VALID) {
return new AddressValidationError(value, this, `Address is not valid: ${value}`);
throw new AddressValidationError(value, this, `Address is not valid: ${JSON.stringify(value)}`);
}
return null;
}
/**
* @throws {@link AddressValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { string: val };
}
/**
* @throws {@link AddressValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[AddressToken.prim]) {

@@ -55,2 +61,5 @@ return semantic[AddressToken.prim](val);

}
/**
* @throws {@link AddressValidationError}
*/
Execute(val) {

@@ -61,3 +70,3 @@ if (val.string) {

if (!val.bytes) {
throw new AddressValidationError(val, this, `cannot be missing both string and bytes: ${val}`);
throw new AddressValidationError(val, this, `cannot be missing both string and bytes: ${JSON.stringify(val)}`);
}

@@ -79,2 +88,5 @@ return utils_1.encodePubKey(val.bytes);

}
/**
* @throws {@link AddressValidationError}
*/
ToKey({ bytes, string }) {

@@ -85,3 +97,3 @@ if (string) {

if (!bytes) {
throw new AddressValidationError({ bytes, string }, this, `cannot be missing both string and bytes ${{ string, bytes }}`);
throw new AddressValidationError({ bytes, string }, this, `cannot be missing both string and bytes ${JSON.stringify({ string, bytes })}`);
}

@@ -88,0 +100,0 @@ return utils_1.encodePubKey(bytes);

@@ -6,2 +6,6 @@ "use strict";

const utils_1 = require("@taquito/utils");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Bytes
*/
class BytesValidationError extends token_1.TokenValidationError {

@@ -29,9 +33,10 @@ constructor(value, token, message) {

}
isValid(val) {
/**
* @throws {@link BytesValidationError}
*/
validate(val) {
if (typeof val === 'string' && /^[0-9a-fA-F]*$/.test(val) && val.length % 2 === 0) {
return null;
return;
}
else {
return new BytesValidationError(val, this, `Invalid bytes: ${val}`);
}
throw new BytesValidationError(val, this, `Invalid bytes: ${val}`);
}

@@ -41,11 +46,14 @@ convertUint8ArrayToHexString(val) {

}
/**
* @throws {@link BytesValidationError}
*/
Encode(args) {
let val = args.pop();
val = utils_1.stripHexPrefix(this.convertUint8ArrayToHexString(val));
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { bytes: String(val).toString() };
}
/**
* @throws {@link BytesValidationError}
*/
EncodeObject(val, semantic) {

@@ -56,6 +64,3 @@ val = this.convertUint8ArrayToHexString(val);

}
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[BytesToken.prim]) {

@@ -62,0 +67,0 @@ return semantic[BytesToken.prim](val);

@@ -6,2 +6,6 @@ "use strict";

const bignumber_js_1 = require("bignumber.js");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Int
*/
class IntValidationError extends token_1.TokenValidationError {

@@ -39,24 +43,24 @@ constructor(value, token, message) {

}
isValid(val) {
/**
* @throws {@link IntValidationError}
*/
validate(val) {
const bigNumber = new bignumber_js_1.default(val);
if (bigNumber.isNaN()) {
return new IntValidationError(val, this, `Value is not a number: ${val}`);
throw new IntValidationError(val, this, `Value is not a number: ${JSON.stringify(val)}`);
}
else {
return null;
}
}
/**
* @throws {@link IntValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { int: new bignumber_js_1.default(val).toFixed() };
}
/**
* @throws {@link IntValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[IntToken.prim]) {

@@ -63,0 +67,0 @@ return semantic[IntToken.prim](val);

@@ -6,2 +6,6 @@ "use strict";

const utils_1 = require("@taquito/utils");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Key Hash
*/
class KeyHashValidationError extends token_1.TokenValidationError {

@@ -29,21 +33,23 @@ constructor(value, token, message) {

}
isValid(value) {
/**
* @throws {@link KeyHashValidationError}
*/
validate(value) {
if (utils_1.validateKeyHash(value) !== utils_1.ValidationResult.VALID) {
return new KeyHashValidationError(value, this, `KeyHash is not valid: ${value}`);
throw new KeyHashValidationError(value, this, `KeyHash is not valid: ${JSON.stringify(value)}`);
}
return null;
}
/**
* @throws {@link KeyHashValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { string: val };
}
/**
* @throws {@link KeyHashValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[KeyHashToken.prim]) {

@@ -50,0 +56,0 @@ return semantic[KeyHashToken.prim](val);

@@ -6,2 +6,6 @@ "use strict";

const bignumber_js_1 = require("bignumber.js");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Mutez
*/
class MutezValidationError extends token_1.TokenValidationError {

@@ -39,24 +43,24 @@ constructor(value, token, message) {

}
isValid(val) {
/**
* @throws {@link MutezValidationError}
*/
validate(val) {
const bigNumber = new bignumber_js_1.default(val);
if (bigNumber.isNaN()) {
return new MutezValidationError(val, this, `Value is not a number: ${val}`);
throw new MutezValidationError(val, this, `Value is not a number: ${val}`);
}
else {
return null;
}
}
/**
* @throws {@link MutezValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { int: String(val).toString() };
}
/**
* @throws {@link MutezValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[MutezToken.prim]) {

@@ -63,0 +67,0 @@ return semantic[MutezToken.prim](val);

@@ -6,2 +6,6 @@ "use strict";

const bignumber_js_1 = require("bignumber.js");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Nat
*/
class NatValidationError extends token_1.TokenValidationError {

@@ -26,27 +30,27 @@ constructor(value, token, message) {

}
/**
* @throws {@link NatValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { int: new bignumber_js_1.default(val).toFixed() };
}
isValid(val) {
/**
* @throws {@link NatValidationError}
*/
validate(val) {
const bigNumber = new bignumber_js_1.default(val);
if (bigNumber.isNaN()) {
return new NatValidationError(val, this, `Value is not a number: ${val}`);
throw new NatValidationError(val, this, `Value is not a number: ${JSON.stringify(val)}`);
}
else if (bigNumber.isNegative()) {
return new NatValidationError(val, this, `Value cannot be negative: ${val}`);
if (bigNumber.isNegative()) {
throw new NatValidationError(val, this, `Value cannot be negative: ${JSON.stringify(val)}`);
}
else {
return null;
}
}
/**
* @throws {@link NatValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[NatToken.prim]) {

@@ -53,0 +57,0 @@ return semantic[NatToken.prim](val);

@@ -6,2 +6,6 @@ "use strict";

const token_1 = require("../token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Tx Rollup L2 Address
*/
class TxRollupL2AddressValidationError extends token_1.TokenValidationError {

@@ -30,20 +34,26 @@ constructor(value, token, message) {

}
isValid(value) {
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
validate(value) {
if (utils_1.validateAddress(value) !== utils_1.ValidationResult.VALID) {
throw new TxRollupL2AddressValidationError(value, this, `tx_rollup_l2_address is not valid: ${value}`);
throw new TxRollupL2AddressValidationError(value, this, `tx_rollup_l2_address is not valid: ${JSON.stringify(value)}`);
}
return null;
}
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
Encode(args) {
const val = args.pop();
if (!val) {
throw new TxRollupL2AddressValidationError(val, this, `arg missing to encode: this -> "${val}"`);
throw new TxRollupL2AddressValidationError(val, this, `arg missing to encode: this -> "${JSON.stringify(val)}"`);
}
// no need to test since method throws
this.isValid(val);
this.validate(val);
return { string: val };
}
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
EncodeObject(val, semantic) {
// no need to test since method throws
this.isValid(val);
this.validate(val);
if (semantic && semantic[TxRollupL2AddressToken.prim]) {

@@ -54,2 +64,5 @@ return semantic[TxRollupL2AddressToken.prim](val);

}
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
Execute(val) {

@@ -73,2 +86,5 @@ if (val.string) {

}
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
ToKey({ bytes, string }) {

@@ -79,3 +95,3 @@ if (string) {

if (!bytes) {
throw new TxRollupL2AddressValidationError(bytes, this, `value cannot be missing string and byte value. must have one: bytes = ${bytes}`);
throw new TxRollupL2AddressValidationError(bytes, this, `value cannot be missing string and byte value. must have one: bytes = ${JSON.stringify(bytes)}`);
}

@@ -82,0 +98,0 @@ return utils_1.encodeL2Address(bytes);

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding a Global Constant
*/
class GlobalConstantEncodingError extends token_1.TokenValidationError {

@@ -15,2 +19,6 @@ constructor(value, token, message) {

exports.GlobalConstantEncodingError = GlobalConstantEncodingError;
/**
* @category Error
* @description Error that indicates a failure happening when parsing executing a Global Constant
*/
class GlobalConstantDecodingError extends token_1.TokenValidationError {

@@ -32,2 +40,5 @@ constructor(value, token, message) {

}
/**
* @throws {@link GlobalConstantDecodingError}
*/
Execute(val, semantic) {

@@ -41,5 +52,11 @@ if (semantic && semantic[GlobalConstantToken.prim]) {

}
/**
* @throws {@link GlobalConstantEncodingError}
*/
Encode(args) {
throw new GlobalConstantEncodingError(args, this, `Unable to encode a script containing global constants. Please provide an expanded script to the Michelson-Encoder. The following global constant hash was encountered: ${this.val.args[0]['string']}.`);
}
/**
* @throws {@link GlobalConstantEncodingError}
*/
EncodeObject(val, semantic) {

@@ -46,0 +63,0 @@ if (semantic && semantic[GlobalConstantToken.prim]) {

@@ -6,2 +6,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Contract
*/
class ContractValidationError extends token_1.TokenValidationError {

@@ -23,9 +27,15 @@ constructor(value, token, message) {

}
isValid(value) {
/**
* @throws {@link ContractValidationError}
*/
validate(value) {
// tz1,tz2 and tz3 seems to be valid contract values (for Unit contract)
if (utils_1.validateAddress(value) !== utils_1.ValidationResult.VALID) {
return new ContractValidationError(value, this, 'Contract address is not valid');
throw new ContractValidationError(value, this, `Value ${JSON.stringify(value)} is not a valid contract address.`);
}
return null;
}
/**
* @throws {@link ContractValidationError}
*/
Execute(val) {

@@ -36,19 +46,19 @@ if (val.string) {

if (!val.bytes) {
throw new ContractValidationError(val, this, 'must contain bytes or string');
throw new ContractValidationError(val, this, `Value ${JSON.stringify(val)} is not a valid contract address. must contain bytes or string.`);
}
return utils_1.encodePubKey(val.bytes);
}
/**
* @throws {@link ContractValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { string: val };
}
/**
* @throws {@link ContractValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[ContractToken.prim]) {

@@ -55,0 +65,0 @@ return semantic[ContractToken.prim](val);

@@ -6,2 +6,3 @@ "use strict";

const pair_1 = require("./pair");
const core_1 = require("@taquito/core");
/**

@@ -11,3 +12,3 @@ * @category Error

*/
class InvalidTokenError extends Error {
class InvalidTokenError extends core_1.TaquitoError {
constructor(message, data) {

@@ -21,2 +22,7 @@ super(message);

exports.InvalidTokenError = InvalidTokenError;
/**
*
* @description Create a token from a value
* @throws {@link InvalidTokenError} If the value passed is not supported by the Michelson Encoder
*/
function createToken(val, idx) {

@@ -28,3 +34,3 @@ if (Array.isArray(val)) {

if (!t) {
throw new InvalidTokenError('Malformed data expected a value with a valid prim property', val);
throw new InvalidTokenError(`Malformed data: ${JSON.stringify(val)}. Expected a value with a valid prim property`, val);
}

@@ -31,0 +37,0 @@ return new t(val, idx, createToken);

@@ -7,2 +7,6 @@ "use strict";

const publicKeyPrefixLength = 4;
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Key
*/
class KeyValidationError extends token_1.TokenValidationError {

@@ -30,21 +34,23 @@ constructor(value, token, message) {

}
isValid(value) {
/**
* @throws {@link KeyValidationError}
*/
validate(value) {
if (utils_1.validatePublicKey(value) !== utils_1.ValidationResult.VALID) {
return new KeyValidationError(value, this, 'Key is not valid');
throw new KeyValidationError(value, this, 'Key is not valid');
}
return null;
}
/**
* @throws {@link KeyValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { string: val };
}
/**
* @throws {@link KeyValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[KeyToken.prim]) {

@@ -51,0 +57,0 @@ return semantic[KeyToken.prim](val);

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a List
*/
class ListValidationError extends token_1.TokenValidationError {

@@ -25,14 +29,16 @@ constructor(value, token, message) {

}
isValid(value) {
if (Array.isArray(value)) {
return null;
/**
* @throws {@link ListValidationError}
*/
validate(value) {
if (!Array.isArray(value)) {
throw new ListValidationError(value, this, `Value ${JSON.stringify(value)} is not a valid array`);
}
return new ListValidationError(value, this, 'Value must be an array');
}
/**
* @throws {@link ListValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
const schema = this.createToken(this.val.args[0], 0);

@@ -43,8 +49,8 @@ return val.reduce((prev, current) => {

}
/**
* @throws {@link ListValidationError}
*/
Execute(val, semantics) {
const schema = this.createToken(this.val.args[0], 0);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return val.reduce((prev, current) => {

@@ -54,8 +60,8 @@ return [...prev, schema.Execute(current, semantics)];

}
/**
* @throws {@link ListValidationError}
*/
EncodeObject(args, semantic) {
const schema = this.createToken(this.val.args[0], 0);
const err = this.isValid(args);
if (err) {
throw err;
}
this.validate(args);
if (semantic && semantic[ListToken.prim]) {

@@ -62,0 +68,0 @@ return semantic[ListToken.prim](args);

@@ -6,2 +6,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Map
*/
class MapValidationError extends token_1.TokenValidationError {

@@ -29,7 +33,9 @@ constructor(value, token, message) {

}
isValid(value) {
if (michelson_map_1.MichelsonMap.isMichelsonMap(value)) {
return null;
/**
* @throws {@link MapValidationError}
*/
validate(value) {
if (!michelson_map_1.MichelsonMap.isMichelsonMap(value)) {
throw new MapValidationError(value, this, `Value ${JSON.stringify(value)} is not a valid MichelsonMap`);
}
return new MapValidationError(value, this, 'Value must be a MichelsonMap');
}

@@ -56,8 +62,8 @@ Execute(val, semantics) {

}
/**
* @throws {@link MapValidationError}
*/
Encode(args) {
const val = this.objLitToMichelsonMap(args.pop());
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return Array.from(val.keys())

@@ -72,8 +78,8 @@ .sort((a, b) => this.KeySchema.compare(a, b))

}
/**
* @throws {@link MapValidationError}
*/
EncodeObject(args, semantic) {
const val = this.objLitToMichelsonMap(args);
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[MapToken.prim]) {

@@ -80,0 +86,0 @@ return semantic[MapToken.prim](val);

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Never Token
*/
class NeverTokenError extends token_1.TokenValidationError {

@@ -22,6 +26,12 @@ constructor(value, token, message) {

}
/**
* @throws {@link NeverTokenError}
*/
Encode(args) {
const val = args.pop();
throw new NeverTokenError(val, this, 'Assigning a value to the type never is forbidden.');
throw new NeverTokenError(val, this, `Assigning a value to the type never is forbidden. Trying to assign ${JSON.stringify(val)}.`);
}
/**
* @throws {@link NeverTokenError}
*/
EncodeObject(val, semantic) {

@@ -31,6 +41,9 @@ if (semantic && semantic[NeverToken.prim]) {

}
throw new NeverTokenError(val, this, 'Assigning a value to the type never is forbidden.');
throw new NeverTokenError(val, this, `Assigning a value to the type never is forbidden. Trying to assign ${JSON.stringify(val)}.`);
}
/**
* @throws {@link NeverTokenError}
*/
Execute(val) {
throw new NeverTokenError(val, this, 'There is no literal value for the type never.');
throw new NeverTokenError(val, this, `There is no literal value for the type never. Trying to execute ${JSON.stringify(val)}.`);
}

@@ -37,0 +50,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrToken = exports.OrTokenDecodingError = void 0;
const core_1 = require("@taquito/core");
const token_1 = require("./token");

@@ -9,3 +10,3 @@ /**

*/
class OrTokenDecodingError extends Error {
class OrTokenDecodingError extends core_1.TaquitoError {
constructor(message) {

@@ -113,2 +114,5 @@ super(message);

}
/**
* @throws {@link OrTokenDecodingError}
*/
Execute(val, semantics) {

@@ -140,3 +144,3 @@ const leftToken = this.createToken(this.val.args[0], this.idx);

else {
throw new OrTokenDecodingError(`Was expecting Left or Right prim but got: ${val.prim}`);
throw new OrTokenDecodingError(`Was expecting Left or Right prim but got: ${JSON.stringify(val.prim)}`);
}

@@ -143,0 +147,0 @@ }

@@ -6,2 +6,3 @@ "use strict";

const or_1 = require("./or");
const core_1 = require("@taquito/core");
/**

@@ -11,3 +12,3 @@ * @category Error

*/
class TokenArgumentValidationError extends Error {
class TokenArgumentValidationError extends core_1.TaquitoError {
constructor(message) {

@@ -24,8 +25,9 @@ super(message);

*/
class TokenComparisonError extends Error {
class TokenComparisonError extends core_1.TaquitoError {
constructor(val1, val2) {
super(`Tokens ${val1} and ${val2} are not comparable`);
super();
this.val1 = val1;
this.val2 = val2;
this.name = 'TokenComparisonError';
this.message = `Tokens ${JSON.stringify(val1)} and ${JSON.stringify(val2)} are not comparable`;
}

@@ -35,2 +37,5 @@ }

// collapse comb pair
/**
* @throws {@link TokenArgumentValidationError}
*/
function collapse(val, prim = PairToken.prim) {

@@ -44,3 +49,3 @@ if (Array.isArray(val)) {

if (val.args === undefined) {
throw new TokenArgumentValidationError('Encountered an invalid PairToken with no arguments, a pair must have two or more arguments');
throw new TokenArgumentValidationError(`The value ${JSON.stringify(val)} is an invalid PairToken with no arguments, a pair must have two or more arguments.`);
}

@@ -200,2 +205,5 @@ if (val.args.length > 2) {

}
/**
* @throws {@link TokenComparisonError}
*/
compare(val1, val2) {

@@ -202,0 +210,0 @@ const [leftToken, rightToken] = this.tokens();

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Sapling State
*/
class SaplingStateValidationError extends token_1.TokenValidationError {

@@ -25,2 +29,5 @@ constructor(value, token, message) {

}
/**
* @throws {@link SaplingStateValidationError}
*/
Execute(val, semantic) {

@@ -37,2 +44,5 @@ if (semantic && semantic[SaplingStateToken.prim]) {

}
/**
* @throws {@link SaplingStateValidationError}
*/
Encode(args) {

@@ -44,5 +54,8 @@ const val = args.pop();

else {
throw new SaplingStateValidationError(val, this, `Invalid sapling_state. Received: ${val} while expecting: {}`);
throw new SaplingStateValidationError(val, this, `Invalid sapling_state. Received: ${JSON.stringify(val)} while expecting: {}`);
}
}
/**
* @throws {@link SaplingStateValidationError}
*/
EncodeObject(val, semantic) {

@@ -56,3 +69,3 @@ if (semantic && semantic[SaplingStateToken.prim]) {

else {
throw new SaplingStateValidationError(val, this, `Invalid sapling_state. Received: ${val} while expecting: {}`);
throw new SaplingStateValidationError(val, this, `Invalid sapling_state. Received: ${JSON.stringify(val)} while expecting: {}`);
}

@@ -59,0 +72,0 @@ }

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Sapling Transaction Deprecated
*/
class SaplingTransactionDeprecatedValidationError extends token_1.TokenValidationError {

@@ -22,5 +26,11 @@ constructor(value, token, message) {

}
/**
* @throws {@link SaplingTransactionDeprecatedValidationError}
*/
Execute(_val) {
throw new SaplingTransactionDeprecatedValidationError(_val, this, 'There is no literal value for the sapling_transaction_deprecated type.');
throw new SaplingTransactionDeprecatedValidationError(_val, this, `There is no literal value for the sapling_transaction_deprecated type. Got: ${JSON.stringify(_val)}.`);
}
/**
* @throws {@link SaplingTransactionDeprecatedValidationError}
*/
validateBytes(val) {

@@ -32,3 +42,3 @@ const bytes = /^(0x|0X)?([0-9a-fA-F]*$)/.exec(val);

else {
throw new SaplingTransactionDeprecatedValidationError(val, this, `Invalid bytes: ${val}`);
throw new SaplingTransactionDeprecatedValidationError(val, this, `Invalid bytes: ${JSON.stringify(val)}`);
}

@@ -35,0 +45,0 @@ }

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Sapling Transaction
*/
class SaplingTransactionValidationError extends token_1.TokenValidationError {

@@ -22,5 +26,11 @@ constructor(value, token, message) {

}
/**
* @throws {@link SaplingTransactionValidationError}
*/
Execute(_val) {
throw new SaplingTransactionValidationError(_val, this, 'There is no literal value for the sapling_transaction type.');
throw new SaplingTransactionValidationError(_val, this, `There is no literal value for the sapling_transaction type. Got: ${JSON.stringify(_val)}.`);
}
/**
* @throws {@link SaplingTransactionValidationError}
*/
validateBytes(val) {

@@ -32,3 +42,3 @@ const bytes = /^(0x|0X)?([0-9a-fA-F]*$)/.exec(val);

else {
throw new SaplingTransactionValidationError(val, this, `Invalid bytes: ${val}`);
throw new SaplingTransactionValidationError(val, this, `Invalid bytes: ${JSON.stringify(val)}`);
}

@@ -35,0 +45,0 @@ }

@@ -5,2 +5,6 @@ "use strict";

const token_1 = require("./token");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Set
*/
class SetValidationError extends token_1.TokenValidationError {

@@ -25,14 +29,16 @@ constructor(value, token, message) {

}
isValid(value) {
if (Array.isArray(value)) {
return null;
/**
* @throws {@link SetValidationError}
*/
validate(value) {
if (!Array.isArray(value)) {
throw new SetValidationError(value, this, `Value ${JSON.stringify(value)} is not an array`);
}
return new SetValidationError(value, this, 'Value must be an array');
}
/**
* @throws {@link SetValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return val

@@ -49,7 +55,7 @@ .sort((a, b) => this.KeySchema.compare(a, b))

}
/**
* @throws {@link SetValidationError}
*/
EncodeObject(args, semantic) {
const err = this.isValid(args);
if (err) {
throw err;
}
this.validate(args);
if (semantic && semantic[SetToken.prim]) {

@@ -56,0 +62,0 @@ return semantic[SetToken.prim](args);

@@ -6,2 +6,6 @@ "use strict";

const utils_1 = require("@taquito/utils");
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Signature
*/
class SignatureValidationError extends token_1.TokenValidationError {

@@ -30,21 +34,23 @@ constructor(value, token, message) {

}
isValid(value) {
/**
* @throws {@link SignatureValidationError}
*/
validate(value) {
if (utils_1.validateSignature(value) !== utils_1.ValidationResult.VALID) {
return new SignatureValidationError(value, this, 'Signature is not valid');
throw new SignatureValidationError(value, this, 'Signature is not valid');
}
return null;
}
/**
* @throws {@link SignatureValidationError}
*/
Encode(args) {
const val = args.pop();
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
return { string: val };
}
/**
* @throws {@link SignatureValidationError}
*/
EncodeObject(val, semantic) {
const err = this.isValid(val);
if (err) {
throw err;
}
this.validate(val);
if (semantic && semantic[SignatureToken.prim]) {

@@ -51,0 +57,0 @@ return semantic[SignatureToken.prim](val);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TicketDeprecatedToken = exports.EncodeTicketDeprecatedError = void 0;
const core_1 = require("@taquito/core");
const int_1 = require("./comparable/int");

@@ -11,6 +12,7 @@ const contract_1 = require("./contract");

*/
class EncodeTicketDeprecatedError extends Error {
class EncodeTicketDeprecatedError extends core_1.TaquitoError {
constructor() {
super('Ticket_deprecated cannot be sent to the blockchain; they are created on-chain');
super();
this.name = 'TicketDeprecatedEncodeError';
this.message = 'Ticket_deprecated cannot be sent to the blockchain; they are created on-chain';
}

@@ -31,5 +33,11 @@ }

}
/**
* @throws {@link EncodeTicketDeprecatedError}
*/
Encode(_args) {
throw new EncodeTicketDeprecatedError();
}
/**
* @throws {@link EncodeTicketDeprecatedError}
*/
EncodeObject(args, semantic) {

@@ -36,0 +44,0 @@ if (semantic && semantic[TicketDeprecatedToken.prim]) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TicketToken = exports.EncodeTicketError = void 0;
const core_1 = require("@taquito/core");
const int_1 = require("./comparable/int");

@@ -11,6 +12,7 @@ const contract_1 = require("./contract");

*/
class EncodeTicketError extends Error {
class EncodeTicketError extends core_1.TaquitoError {
constructor() {
super('Tickets cannot be sent to the blockchain; they are created on-chain');
super();
this.name = 'TicketEncodeError';
this.message = 'Tickets cannot be sent to the blockchain; they are created on-chain';
}

@@ -31,5 +33,11 @@ }

}
/**
* @throws {@link EncodeTicketError}
*/
Encode(_args) {
throw new EncodeTicketError();
}
/**
* @throws {@link EncodeTicketError}
*/
EncodeObject(args, semantic) {

@@ -36,0 +44,0 @@ if (semantic && semantic[TicketToken.prim]) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ComparableToken = exports.Token = exports.TokenValidationError = void 0;
const core_1 = require("@taquito/core");
/**

@@ -8,3 +9,3 @@ * @category Error

*/
class TokenValidationError extends Error {
class TokenValidationError extends core_1.TaquitoError {
constructor(value, token, baseMessage) {

@@ -14,3 +15,3 @@ super();

this.token = token;
this.name = 'ValidationError';
this.name = 'TokenValidationError';
const annot = this.token.annot();

@@ -17,0 +18,0 @@ const annotText = annot ? `[${annot}] ` : '';

@@ -6,5 +6,5 @@ "use strict";

exports.VERSION = {
"commitHash": "5e47743ada31a9c8118f836c31b50a94d97255a6",
"version": "17.1.0-beta-RC.0"
"commitHash": "35185f70bf071114f22f169d2e1f7f8747ced2d0",
"version": "17.1.0-beta-RC.1"
};
//# sourceMappingURL=version.js.map
import { MichelsonV1Expression } from '@taquito/rpc';
import { TaquitoError } from '@taquito/core';
/**

@@ -6,6 +7,6 @@ * @category Error

*/
export declare class InvalidMapTypeError extends Error {
mapType: string;
name: string;
constructor(mapType: string);
export declare class InvalidMapTypeError extends TaquitoError {
readonly mapType: any;
readonly reason: string;
constructor(mapType: any, reason: string);
}

@@ -18,7 +19,8 @@ declare const michelsonMapTypeSymbol: unique symbol;

*/
export declare class MapTypecheckError extends Error {
export declare class MapTypecheckError extends TaquitoError {
readonly value: any;
readonly type: any;
readonly reason: any;
name: string;
constructor(value: any, type: any, errorType: 'key' | 'value');
constructor(value: any, type: any, objectType: 'key' | 'value', reason: any);
}

@@ -48,3 +50,9 @@ /**

private typecheckValue;
/**
* @throws {@link MapTypecheckError} when the argument passed does not match the expected schema for value
*/
private assertTypecheckValue;
/**
* @throws {@link MapTypecheckError} when the argument passed does not match the expected schema for key
*/
private assertTypecheckKey;

@@ -51,0 +59,0 @@ private serializeDeterministically;

@@ -9,10 +9,41 @@ import { Semantic, SemanticEncoding } from '../tokens/token';

private root;
/**
*
* @description Create an instance of ParameterSchema from a contract script
*
* @param val contract script obtained from the RPC
* @returns ParameterSchema
* @throws {InvalidRpcResponseError} If the RPC response is invalid
*/
static fromRPCResponse(val: {
script: ScriptResponse;
}): ParameterSchema;
/**
* @description Check if the Contract parameter is multiple entry point or not
*/
get isMultipleEntryPoint(): boolean;
/**
* @description Check if the Contract parameter has an annotation or not
*/
get hasAnnotation(): boolean;
/**
* @description Return the schema of the parameter of a specific entry point
* @throws {@link InvalidTokenError}
*/
constructor(val: MichelsonV1Expression);
/**
* @description Returns the javascript object equivalent of the Micheline value provided
*/
Execute(val: any, semantics?: Semantic): any;
/**
* @description Returns a micheline formatted object for the values provided
* @throws {@link TokenValidationError}
* @throws {@link ParameterEncodingError}
*/
Encode(...args: any[]): any;
/**
* @description Returns a micheline formatted object for the javascript object provided
* @throws {@link TokenValidationError}
* @throws {@link ParameterEncodingError}
*/
EncodeObject(value?: any, semantics?: SemanticEncoding): any;

@@ -19,0 +50,0 @@ /**

@@ -8,3 +8,3 @@ import { MichelsonV1Expression, ScriptResponse } from '@taquito/rpc';

/**
* @warn Our current smart contract abstraction feature is currently in preview. It's API is not final, and it may not cover every use case (yet). We will greatly appreciate any feedback on this feature.
* @warn Our current smart contract abstraction feature is currently in preview. Its API is not final, and it may not cover every use case (yet). We will greatly appreciate any feedback on this feature.
*/

@@ -17,2 +17,5 @@ export declare class Schema {

private bigMap?;
/**
* @throws {@link InvalidRpcResponseError}
*/
static fromRPCResponse(val: {

@@ -25,5 +28,16 @@ script: ScriptResponse;

Execute(val: any, semantics?: Semantic): any;
Typecheck(val: any): boolean;
Typecheck(val: any): void;
/**
* @throws {@link InvalidBigMapSchemaError}
* @throws {@link InvalidBigMapDiffError}
*/
ExecuteOnBigMapDiff(diff: any[], semantics?: Semantic): any;
/**
* @throws {@link InvalidBigMapSchemaError}
*/
ExecuteOnBigMapValue(key: any, semantics?: Semantic): any;
/**
* @throws {@link InvalidBigMapSchemaError}
* @throws {@link BigMapEncodingError}
*/
EncodeBigMapKey(key: BigMapKeyType): {

@@ -38,2 +52,6 @@ key: {

};
/**
* @throws {@link TokenValidationError}
* @throws {@link StorageEncodingError}
*/
Encode(value?: any, semantics?: SemanticEncoding): any;

@@ -52,2 +70,3 @@ /**

* @deprecated
* @throws {@link InvalidBigMapSchemaError}
*/

@@ -65,2 +84,5 @@ ComputeState(tx: RpcTransaction[], state: any): any;

FindFirstInTopLevelPair<T extends MichelsonV1Expression>(storage: any, valueType: any): T | undefined;
/**
* @throws {@link MissingArgumentError}
*/
private findValue;

@@ -67,0 +89,0 @@ /**

@@ -16,2 +16,3 @@ import { MichelsonV1Expression, MichelsonV1ExpressionExtended, ScriptResponse } from '@taquito/rpc';

* @returns array of ViewSchema or empty array if there is no view in the contract
* @throws {@link InvalidScriptError}
*/

@@ -21,4 +22,7 @@ static fromRPCResponse(val: {

}): ViewSchema[];
constructor(val: MichelsonV1Expression[]);
/**
* @throws {@link InvalidScriptError}
*/
constructor(viewArgs: MichelsonV1Expression[] | undefined);
/**
*

@@ -29,2 +33,3 @@ * @description Transform the view parameter into Michelson

* @returns parameter of the view in Michelson
* @throws {@link ParameterEncodingError}
*/

@@ -31,0 +36,0 @@ encodeViewArgs(args: any): any;

@@ -9,3 +9,3 @@ /**

export * from './schema/event-schema';
export * from './schema/error';
export * from './schema/errors';
export * from './schema/types';

@@ -12,0 +12,0 @@ export { Semantic, SemanticEncoding, BigMapKeyType } from './tokens/token';

@@ -40,6 +40,19 @@ import { BigMapTokenSchema } from '../schema/types';

generateSchema(): BigMapTokenSchema;
private isValid;
/**
* @throws {@link BigMapValidationError}
*/
private validate;
private objLitToMichelsonMap;
/**
* @throws {@link BigMapValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link BigMapValidationError}
*/
EncodeObject(args: any, semantic?: SemanticEncoding): any;
/**
* @throws {@link InvalidMapTypeError} when the argument passed to val is an array but not a valid map type
* @throws {@link BigMapValidationError} when the value is invalid
*/
Execute(val: any[] | {

@@ -46,0 +59,0 @@ int: string;

import { BaseTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a BLS12-381 scalar field Fr
*/
export declare class Bls12381frValidationError extends TokenValidationError {

@@ -23,4 +27,10 @@ value: any;

}, idx: number, fac: TokenFactory);
private isValid;
/**
* @throws {@link Bls12381frValidationError}
*/
private validate;
private convertUint8ArrayToHexString;
/**
* @throws {@link Bls12381frValidationError}
*/
Encode(args: any[]): {

@@ -33,2 +43,5 @@ int: string;

};
/**
* @throws {@link Bls12381frValidationError}
*/
EncodeObject(val: string | Uint8Array | number, semantic?: SemanticEncoding): import("@taquito/rpc").MichelsonV1ExpressionExtended | import("@taquito/rpc").MichelsonV1ExpressionBase | import("@taquito/rpc").MichelsonV1Expression[] | {

@@ -35,0 +48,0 @@ bytes: string | number | Uint8Array;

import { BaseTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a BLS12-381 curve G1
*/
export declare class Bls12381g1ValidationError extends TokenValidationError {

@@ -23,7 +27,16 @@ value: any;

}, idx: number, fac: TokenFactory);
private isValid;
/**
* @throws {@link Bls12381g1ValidationError}
*/
private validate;
private convertUint8ArrayToHexString;
/**
* @throws {@link Bls12381g1ValidationError}
*/
Encode(args: any[]): {
bytes: any;
};
/**
* @throws {@link Bls12381g1ValidationError}
*/
EncodeObject(val: string | Uint8Array, semantic?: SemanticEncoding): import("@taquito/rpc").MichelsonV1ExpressionExtended | import("@taquito/rpc").MichelsonV1ExpressionBase | import("@taquito/rpc").MichelsonV1Expression[] | {

@@ -30,0 +43,0 @@ bytes: string | Uint8Array;

import { BaseTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a BLS12-381 curve G2
*/
export declare class Bls12381g2ValidationError extends TokenValidationError {

@@ -23,7 +27,16 @@ value: any;

}, idx: number, fac: TokenFactory);
private isValid;
/**
* @throws {@link Bls12381g2ValidationError}
*/
private validate;
private convertUint8ArrayToHexString;
/**
* @throws {@link Bls12381g2ValidationError}
*/
Encode(args: any[]): {
bytes: any;
};
/**
* @throws {@link Bls12381g2ValidationError}
*/
EncodeObject(val: string | Uint8Array, semantic?: SemanticEncoding): import("@taquito/rpc").MichelsonV1ExpressionExtended | import("@taquito/rpc").MichelsonV1ExpressionBase | import("@taquito/rpc").MichelsonV1Expression[] | {

@@ -30,0 +43,0 @@ bytes: string | Uint8Array;

import { Token, TokenFactory, ComparableToken, TokenValidationError, SemanticEncoding } from './token';
import { BaseTokenSchema } from '../schema/types';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a ChainID
*/
export declare class ChainIDValidationError extends TokenValidationError {

@@ -23,3 +27,6 @@ value: any;

}, idx: number, fac: TokenFactory);
private isValid;
/**
* @throws {@link ChainIDValidationError}
*/
private validate;
Execute(val: any): string;

@@ -32,3 +39,9 @@ /**

generateSchema(): BaseTokenSchema;
/**
* @throws {@link ChainIDValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link ChainIDValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -35,0 +48,0 @@ ToKey({ string }: any): any;

import { BaseTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Chest Key
*/
export declare class ChestKeyValidationError extends TokenValidationError {

@@ -23,7 +27,16 @@ value: any;

}, idx: number, fac: TokenFactory);
private isValid;
/**
* @throws {@link ChestKeyValidationError}
*/
private validate;
private convertUint8ArrayToHexString;
/**
* @throws {@link ChestKeyValidationError}
*/
Encode(args: any[]): {
bytes: any;
};
/**
* @throws {@link ChestKeyValidationError}
*/
EncodeObject(val: string | Uint8Array, semantic?: SemanticEncoding): import("@taquito/rpc").MichelsonV1ExpressionExtended | import("@taquito/rpc").MichelsonV1ExpressionBase | import("@taquito/rpc").MichelsonV1Expression[] | {

@@ -30,0 +43,0 @@ bytes: string | Uint8Array;

import { BaseTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Chest
*/
export declare class ChestValidationError extends TokenValidationError {

@@ -23,7 +27,16 @@ value: any;

}, idx: number, fac: TokenFactory);
private isValid;
/**
* @throws {@link ChestKeyValidationError}
*/
private validate;
private convertUint8ArrayToHexString;
/**
* @throws {@link ChestKeyValidationError}
*/
Encode(args: any[]): {
bytes: any;
};
/**
* @throws {@link ChestKeyValidationError}
*/
EncodeObject(val: string | Uint8Array, semantic?: SemanticEncoding): import("@taquito/rpc").MichelsonV1ExpressionExtended | import("@taquito/rpc").MichelsonV1ExpressionBase | import("@taquito/rpc").MichelsonV1Expression[] | {

@@ -30,0 +43,0 @@ bytes: string | Uint8Array;

import { Token, TokenFactory, ComparableToken, TokenValidationError, SemanticEncoding } from '../token';
import { BaseTokenSchema } from '../../schema/types';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing an Address
*/
export declare class AddressValidationError extends TokenValidationError {

@@ -31,5 +35,17 @@ value: any;

};
private isValid;
/**
* @throws {@link AddressValidationError}
*/
private validate;
/**
* @throws {@link AddressValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link AddressValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;
/**
* @throws {@link AddressValidationError}
*/
Execute(val: {

@@ -45,2 +61,5 @@ bytes: string;

generateSchema(): BaseTokenSchema;
/**
* @throws {@link AddressValidationError}
*/
ToKey({ bytes, string }: any): any;

@@ -47,0 +66,0 @@ compare(address1: string, address2: string): number;

import { BaseTokenSchema } from '../../schema/types';
import { TokenFactory, ComparableToken, TokenValidationError, Token, SemanticEncoding } from '../token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Bytes
*/
export declare class BytesValidationError extends TokenValidationError {

@@ -31,5 +35,14 @@ value: any;

};
private isValid;
/**
* @throws {@link BytesValidationError}
*/
private validate;
private convertUint8ArrayToHexString;
/**
* @throws {@link BytesValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link BytesValidationError}
*/
EncodeObject(val: string | Uint8Array, semantic?: SemanticEncoding): import("@taquito/rpc").MichelsonV1Expression;

@@ -36,0 +49,0 @@ Execute(val: any): string;

import { Token, TokenFactory, ComparableToken, TokenValidationError, SemanticEncoding } from '../token';
import { BaseTokenSchema } from '../../schema/types';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Int
*/
export declare class IntValidationError extends TokenValidationError {

@@ -34,4 +38,13 @@ value: any;

generateSchema(): BaseTokenSchema;
private isValid;
/**
* @throws {@link IntValidationError}
*/
private validate;
/**
* @throws {@link IntValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link IntValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -38,0 +51,0 @@ ToBigMapKey(val: string | number): {

import { Token, TokenFactory, ComparableToken, TokenValidationError, SemanticEncoding } from '../token';
import { BaseTokenSchema } from '../../schema/types';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Key Hash
*/
export declare class KeyHashValidationError extends TokenValidationError {

@@ -27,4 +31,13 @@ value: any;

}): string | undefined;
private isValid;
/**
* @throws {@link KeyHashValidationError}
*/
private validate;
/**
* @throws {@link KeyHashValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link KeyHashValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -31,0 +44,0 @@ /**

import { Token, TokenFactory, ComparableToken, TokenValidationError, SemanticEncoding } from '../token';
import BigNumber from 'bignumber.js';
import { BaseTokenSchema } from '../../schema/types';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Mutez
*/
export declare class MutezValidationError extends TokenValidationError {

@@ -31,4 +35,13 @@ value: any;

generateSchema(): BaseTokenSchema;
private isValid;
/**
* @throws {@link MutezValidationError}
*/
private validate;
/**
* @throws {@link MutezValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link MutezValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -35,0 +48,0 @@ ToBigMapKey(val: string | number): {

import { Token, TokenFactory, ComparableToken, TokenValidationError, SemanticEncoding } from '../token';
import BigNumber from 'bignumber.js';
import { BaseTokenSchema } from '../../schema/types';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing Nat
*/
export declare class NatValidationError extends TokenValidationError {

@@ -27,4 +31,13 @@ value: any;

};
/**
* @throws {@link NatValidationError}
*/
Encode(args: any[]): any;
private isValid;
/**
* @throws {@link NatValidationError}
*/
private validate;
/**
* @throws {@link NatValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -31,0 +44,0 @@ /**

import { BaseTokenSchema } from '../../schema/types';
import { ComparableToken, SemanticEncoding, Token, TokenFactory, TokenValidationError } from '../token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Tx Rollup L2 Address
*/
export declare class TxRollupL2AddressValidationError extends TokenValidationError {

@@ -31,5 +35,17 @@ value: unknown;

};
private isValid;
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
private validate;
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
Encode(args: string[]): any;
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
Execute(val: {

@@ -41,2 +57,5 @@ bytes?: string;

generateSchema(): BaseTokenSchema;
/**
* @throws {@link TxRollupL2AddressValidationError}
*/
ToKey({ bytes, string }: {

@@ -43,0 +62,0 @@ bytes?: string;

import { ConstantTokenSchema } from '../schema/types';
import { Semantic, SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding a Global Constant
*/
export declare class GlobalConstantEncodingError extends TokenValidationError {

@@ -9,2 +13,6 @@ value: any;

}
/**
* @category Error
* @description Error that indicates a failure happening when parsing executing a Global Constant
*/
export declare class GlobalConstantDecodingError extends TokenValidationError {

@@ -30,4 +38,13 @@ value: any;

}, idx: number, fac: TokenFactory);
/**
* @throws {@link GlobalConstantDecodingError}
*/
Execute(val: any, semantic?: Semantic): any;
/**
* @throws {@link GlobalConstantEncodingError}
*/
Encode(args: any[]): any;
/**
* @throws {@link GlobalConstantEncodingError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -34,0 +51,0 @@ /**

import { ContractTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Contract
*/
export declare class ContractValidationError extends TokenValidationError {

@@ -23,3 +27,9 @@ value: any;

}, idx: number, fac: TokenFactory);
private isValid;
/**
* @throws {@link ContractValidationError}
*/
private validate;
/**
* @throws {@link ContractValidationError}
*/
Execute(val: {

@@ -29,3 +39,9 @@ bytes: string;

}): string;
/**
* @throws {@link ContractValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link ContractValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -32,0 +48,0 @@ /**

import { Token } from './token';
import { TaquitoError } from '@taquito/core';
/**

@@ -6,3 +7,3 @@ * @category Error

*/
export declare class InvalidTokenError extends Error {
export declare class InvalidTokenError extends TaquitoError {
message: string;

@@ -13,2 +14,7 @@ data: any;

}
/**
*
* @description Create a token from a value
* @throws {@link InvalidTokenError} If the value passed is not supported by the Michelson Encoder
*/
export declare function createToken(val: any, idx: number): Token;
import { ComparableToken, SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
import { BaseTokenSchema } from '../schema/types';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Key
*/
export declare class KeyValidationError extends TokenValidationError {

@@ -27,4 +31,13 @@ value: any;

}): string | undefined;
private isValid;
/**
* @throws {@link KeyValidationError}
*/
private validate;
/**
* @throws {@link KeyValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link KeyValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -31,0 +44,0 @@ /**

import { ListTokenSchema } from '../schema/types';
import { Token, TokenFactory, Semantic, TokenValidationError, SemanticEncoding } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a List
*/
export declare class ListValidationError extends TokenValidationError {

@@ -24,5 +28,17 @@ value: any;

get valueSchema(): Token;
private isValid;
/**
* @throws {@link ListValidationError}
*/
private validate;
/**
* @throws {@link ListValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link ListValidationError}
*/
Execute(val: any, semantics?: Semantic): any;
/**
* @throws {@link ListValidationError}
*/
EncodeObject(args: any, semantic?: SemanticEncoding): any;

@@ -29,0 +45,0 @@ /**

import { MapTokenSchema } from '../schema/types';
import { ComparableToken, Semantic, SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Map
*/
export declare class MapValidationError extends TokenValidationError {

@@ -25,3 +29,6 @@ value: any;

get KeySchema(): ComparableToken;
private isValid;
/**
* @throws {@link MapValidationError}
*/
validate(value: any): void;
Execute(val: any[], semantics?: Semantic): {

@@ -31,3 +38,9 @@ [key: string]: any;

private objLitToMichelsonMap;
/**
* @throws {@link MapValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link MapValidationError}
*/
EncodeObject(args: any, semantic?: SemanticEncoding): any;

@@ -34,0 +47,0 @@ /**

import { BaseTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Never Token
*/
export declare class NeverTokenError extends TokenValidationError {

@@ -23,4 +27,13 @@ value: any;

}, idx: number, fac: TokenFactory);
/**
* @throws {@link NeverTokenError}
*/
Encode(args: any[]): any;
/**
* @throws {@link NeverTokenError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;
/**
* @throws {@link NeverTokenError}
*/
Execute(val: any): void;

@@ -27,0 +40,0 @@ /**

@@ -0,1 +1,2 @@

import { TaquitoError } from '@taquito/core';
import { OrTokenSchema } from '../schema/types';

@@ -7,3 +8,3 @@ import { Token, TokenFactory, Semantic, ComparableToken, SemanticEncoding } from './token';

*/
export declare class OrTokenDecodingError extends Error {
export declare class OrTokenDecodingError extends TaquitoError {
message: string;

@@ -30,2 +31,5 @@ name: string;

EncodeObject(args: any, semantic?: SemanticEncoding): any;
/**
* @throws {@link OrTokenDecodingError}
*/
Execute(val: any, semantics?: Semantic): any;

@@ -32,0 +36,0 @@ private traversal;

import { Token, TokenFactory, Semantic, ComparableToken, SemanticEncoding } from './token';
import { PairTokenSchema } from '../schema/types';
import { MichelsonV1Expression, MichelsonV1ExpressionExtended } from '@taquito/rpc';
import { TaquitoError } from '@taquito/core';
/**

@@ -8,3 +9,3 @@ * @category Error

*/
export declare class TokenArgumentValidationError extends Error {
export declare class TokenArgumentValidationError extends TaquitoError {
message: string;

@@ -18,3 +19,3 @@ name: string;

*/
export declare class TokenComparisonError extends Error {
export declare class TokenComparisonError extends TaquitoError {
val1: string;

@@ -50,4 +51,7 @@ val2: string;

generateSchema(): PairTokenSchema;
/**
* @throws {@link TokenComparisonError}
*/
compare(val1: any, val2: any): number;
findAndReturnTokens(tokenToFind: string, tokens: Token[]): Token[];
}
import { SaplingStateTokenSchema } from '../schema/types';
import { Semantic, SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Sapling State
*/
export declare class SaplingStateValidationError extends TokenValidationError {

@@ -24,6 +28,15 @@ value: any;

private isValid;
/**
* @throws {@link SaplingStateValidationError}
*/
Execute(val: {
int: string;
}, semantic?: Semantic): any;
/**
* @throws {@link SaplingStateValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link SaplingStateValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -30,0 +43,0 @@ /**

import { SaplingTransactionDeprecatedTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Sapling Transaction Deprecated
*/
export declare class SaplingTransactionDeprecatedValidationError extends TokenValidationError {

@@ -23,3 +27,9 @@ value: any;

}, idx: number, fac: TokenFactory);
/**
* @throws {@link SaplingTransactionDeprecatedValidationError}
*/
Execute(_val: any): void;
/**
* @throws {@link SaplingTransactionDeprecatedValidationError}
*/
private validateBytes;

@@ -26,0 +36,0 @@ private convertUint8ArrayToHexString;

import { SaplingTransactionTokenSchema } from '../schema/types';
import { SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Sapling Transaction
*/
export declare class SaplingTransactionValidationError extends TokenValidationError {

@@ -23,3 +27,9 @@ value: any;

}, idx: number, fac: TokenFactory);
/**
* @throws {@link SaplingTransactionValidationError}
*/
Execute(_val: any): void;
/**
* @throws {@link SaplingTransactionValidationError}
*/
private validateBytes;

@@ -26,0 +36,0 @@ private convertUint8ArrayToHexString;

import { SetTokenSchema } from '../schema/types';
import { Token, TokenFactory, Semantic, TokenValidationError, ComparableToken, SemanticEncoding } from './token';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Set
*/
export declare class SetValidationError extends TokenValidationError {

@@ -24,5 +28,14 @@ value: any;

get KeySchema(): ComparableToken;
private isValid;
/**
* @throws {@link SetValidationError}
*/
private validate;
/**
* @throws {@link SetValidationError}
*/
Encode(args: any[]): any;
Execute(val: any, semantics?: Semantic): any;
/**
* @throws {@link SetValidationError}
*/
EncodeObject(args: any, semantic?: SemanticEncoding): any;

@@ -29,0 +42,0 @@ /**

import { ComparableToken, SemanticEncoding, Token, TokenFactory, TokenValidationError } from './token';
import { BaseTokenSchema } from '../schema/types';
/**
* @category Error
* @description Error that indicates a failure happening when parsing encoding/executing a Signature
*/
export declare class SignatureValidationError extends TokenValidationError {

@@ -26,4 +30,13 @@ value: any;

}): string;
private isValid;
/**
* @throws {@link SignatureValidationError}
*/
private validate;
/**
* @throws {@link SignatureValidationError}
*/
Encode(args: any[]): any;
/**
* @throws {@link SignatureValidationError}
*/
EncodeObject(val: any, semantic?: SemanticEncoding): any;

@@ -30,0 +43,0 @@ /**

@@ -0,1 +1,2 @@

import { TaquitoError } from '@taquito/core';
import { TicketDeprecatedTokenSchema } from '../schema/types';

@@ -7,3 +8,3 @@ import { Token, TokenFactory, Semantic, SemanticEncoding } from './token';

*/
export declare class EncodeTicketDeprecatedError extends Error {
export declare class EncodeTicketDeprecatedError extends TaquitoError {
name: string;

@@ -27,3 +28,9 @@ constructor();

get valueToken(): Token;
/**
* @throws {@link EncodeTicketDeprecatedError}
*/
Encode(_args: any[]): any;
/**
* @throws {@link EncodeTicketDeprecatedError}
*/
EncodeObject(args: any, semantic?: SemanticEncoding): any;

@@ -30,0 +37,0 @@ Execute(val: any, semantics?: Semantic): any;

@@ -0,1 +1,2 @@

import { TaquitoError } from '@taquito/core';
import { TicketTokenSchema } from '../schema/types';

@@ -7,3 +8,3 @@ import { Token, TokenFactory, Semantic, SemanticEncoding } from './token';

*/
export declare class EncodeTicketError extends Error {
export declare class EncodeTicketError extends TaquitoError {
name: string;

@@ -27,3 +28,9 @@ constructor();

get valueToken(): Token;
/**
* @throws {@link EncodeTicketError}
*/
Encode(_args: any[]): any;
/**
* @throws {@link EncodeTicketError}
*/
EncodeObject(args: any, semantic?: SemanticEncoding): any;

@@ -30,0 +37,0 @@ Execute(val: any, semantics?: Semantic): any;

import { MichelsonV1Expression, MichelsonV1ExpressionExtended } from '@taquito/rpc';
import { TokenSchema } from '../schema/types';
import { TaquitoError } from '@taquito/core';
/**

@@ -7,5 +8,5 @@ * @category Error

*/
export declare abstract class TokenValidationError extends Error {
value: any;
token: Token;
export declare abstract class TokenValidationError extends TaquitoError {
readonly value: any;
readonly token: Token;
name: string;

@@ -12,0 +13,0 @@ constructor(value: any, token: Token, baseMessage: string);

{
"name": "@taquito/michelson-encoder",
"version": "17.1.0-beta-RC.0",
"version": "17.1.0-beta-RC.1",
"description": "converts michelson data and types into convenient JS/TS objects",

@@ -71,4 +71,4 @@ "keywords": [

"dependencies": {
"@taquito/rpc": "^17.1.0-beta-RC.0",
"@taquito/utils": "^17.1.0-beta-RC.0",
"@taquito/rpc": "^17.1.0-beta-RC.1",
"@taquito/utils": "^17.1.0-beta-RC.1",
"bignumber.js": "^9.1.0",

@@ -105,3 +105,3 @@ "fast-json-stable-stringify": "^2.1.0"

},
"gitHead": "37b7cea2af882794ddd67b1228df808888af9fc4"
"gitHead": "c0494008115163a124fa466444585d7f3f1de48c"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc