UNPKG

@taquito/michelson-encoder

Version:

converts michelson data and types into convenient JS/TS objects

128 lines (127 loc) 4.85 kB
"use strict"; /* eslint-disable @typescript-eslint/no-explicit-any */ Object.defineProperty(exports, "__esModule", { value: true }); exports.MissingArgumentError = exports.StorageEncodingError = exports.BigMapEncodingError = exports.InvalidBigMapDiffError = exports.InvalidBigMapSchemaError = exports.InvalidRpcResponseError = exports.InvalidScriptError = exports.ParameterEncodingError = void 0; const core_1 = require("@taquito/core"); /** * @category Error * @description Error that indicates a failure when encoding (transforming JS parameter into JSON Michelson) the parameter of the view */ class ParameterEncodingError extends core_1.InvalidViewParameterError { constructor(viewName, sigs, args, cause) { super(viewName, sigs, args, cause); this.viewName = viewName; this.sigs = sigs; this.args = args; this.cause = cause; this.name = 'ParameterEncodingError'; this.message = `Could not encode parameter ${JSON.stringify(args)} received for name "${viewName}" expecting one of the following signatures ${JSON.stringify(sigs)}`; } } exports.ParameterEncodingError = ParameterEncodingError; /** * @category Error * @description Error that indicates an invalid on-chain view found on the script */ class InvalidScriptError extends core_1.TaquitoError { constructor(script, reason) { super(); this.script = script; this.reason = reason; this.name = 'InvalidScriptError'; let message = `Invalid on-chain view found in the following script.`; if (reason) { message += ` Reason: ${reason}.`; } message += `Script: ${JSON.stringify(script)}`; this.message = message; } } exports.InvalidScriptError = InvalidScriptError; /** * @category Error * @description Error that indicates an invalid RPC response being passed or used */ class InvalidRpcResponseError extends core_1.TaquitoError { constructor(script, reason) { super(); this.script = script; this.reason = reason; this.name = 'InvalidRpcResponseError'; let message = `Invalid RPC response passed as argument(s).`; if (reason) { message += ` Reason: ${reason}.`; } message += ` Received: ${JSON.stringify(script)}`; this.message = message; } } exports.InvalidRpcResponseError = InvalidRpcResponseError; /** * @category Error * @description Error that indicates an invalid big map schema being passed or used */ class InvalidBigMapSchemaError extends core_1.TaquitoError { constructor(message) { super(message); this.message = message; this.name = 'InvalidBigMapSchemaError'; } } exports.InvalidBigMapSchemaError = InvalidBigMapSchemaError; /** * @category Error * @description Error that indicates an invalid big map diff being passed or used */ class InvalidBigMapDiffError extends core_1.TaquitoError { constructor(message, value) { super(message); this.message = message; this.value = value; this.name = 'InvalidBigMapDiffError'; } } exports.InvalidBigMapDiffError = InvalidBigMapDiffError; /** * @category Error * @description Error that indicates a failure when trying to encode big maps */ class BigMapEncodingError extends core_1.TaquitoError { constructor(obj, details, schema, value) { super(); this.details = details; this.schema = schema; this.value = value; this.name = 'BigMapEncodingError'; this.message = `Unable to encode the big map ${obj}. Schema is: ${JSON.stringify(schema)}. The ${obj} is: ${JSON.stringify(value)}. Error details: ${details}`; } } exports.BigMapEncodingError = BigMapEncodingError; /** * @category Error * @description Error that indicates a failure when trying to encode storage */ class StorageEncodingError extends core_1.TaquitoError { constructor(obj, details, schema, value, semantics) { super(); this.details = details; this.schema = schema; this.value = value; this.semantics = semantics; this.name = 'StorageEncodingError'; this.message = `Unable to encode ${obj}. The schema is: ${JSON.stringify(schema)}, the value is: ${JSON.stringify(value)}.${semantics ? `And the semantic is: ${JSON.stringify(semantics)}` : ''}. Error details: ${details}`; } } exports.StorageEncodingError = StorageEncodingError; /** * @category Error * @description General error that indicates a function not being passed a necessary argument */ class MissingArgumentError extends core_1.TaquitoError { constructor(message) { super(message); this.message = message; this.name = 'MissingArgumentError'; } } exports.MissingArgumentError = MissingArgumentError;