@mavrykdynamics/taquito
Version:
High level functionality that builds upon the other packages in the Mavryk Typescript Library Suite.
141 lines (140 loc) • 5.17 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidBalanceError = exports.OriginationParameterError = exports.RevealOperationError = exports.InvalidViewSimulationContext = exports.validateAndExtractFailwith = exports.ViewSimulationError = exports.InvalidInitParameter = exports.InvalidCodeParameter = exports.InvalidDelegationSource = exports.InvalidParameterError = void 0;
const taquito_core_1 = require("@mavrykdynamics/taquito-core");
/**
* @category Error
* @description Error that indicates invalid smart contract parameters being passed or used
*/
class InvalidParameterError extends taquito_core_1.ParameterValidationError {
constructor(smartContractMethodName, sigs, invalidParams) {
super();
this.smartContractMethodName = smartContractMethodName;
this.sigs = sigs;
this.invalidParams = invalidParams;
this.name = 'InvalidParameterError';
this.message = `${smartContractMethodName} Received ${invalidParams.length} arguments while expecting one of the following signatures (${JSON.stringify(sigs)})`;
}
}
exports.InvalidParameterError = InvalidParameterError;
/**
* @category Error
* @description Error that indicates an invalid delegation source contract address being passed or used
*/
class InvalidDelegationSource extends taquito_core_1.ParameterValidationError {
constructor(source) {
super();
this.source = source;
this.name = `InvalidDelegationSource`;
this.message = `Since Babylon delegation source can no longer be a contract address ${source}. Please use the smart contract abstraction to set your delegate.`;
}
}
exports.InvalidDelegationSource = InvalidDelegationSource;
/**
* @category Error
* @description Error that indicates an invalid smart contract code parameter being passed or used
*/
class InvalidCodeParameter extends taquito_core_1.ParameterValidationError {
constructor(message, data) {
super();
this.message = message;
this.data = data;
this.name = 'InvalidCodeParameter';
}
}
exports.InvalidCodeParameter = InvalidCodeParameter;
/**
* @category Error
* @description Error that indicates invalid smart contract init parameter being passed or used
*/
class InvalidInitParameter extends taquito_core_1.ParameterValidationError {
constructor(message, data) {
super();
this.message = message;
this.data = data;
this.name = 'InvalidInitParameter';
}
}
exports.InvalidInitParameter = InvalidInitParameter;
/**
* @category Error
* @description Error that indicates a failure when conducting a view simulation
*/
class ViewSimulationError extends taquito_core_1.RpcError {
constructor(message, viewName, failWith, cause) {
super();
this.message = message;
this.viewName = viewName;
this.failWith = failWith;
this.cause = cause;
this.name = 'ViewSimulationError';
}
}
exports.ViewSimulationError = ViewSimulationError;
const validateAndExtractFailwith = (error) => {
if (isJsonString(error.body)) {
const parsedError = JSON.parse(error.body);
if (Array.isArray(parsedError) && 'with' in parsedError[parsedError.length - 1]) {
return parsedError[parsedError.length - 1].with;
}
}
};
exports.validateAndExtractFailwith = validateAndExtractFailwith;
const isJsonString = (str) => {
try {
JSON.parse(str);
}
catch (e) {
return false;
}
return true;
};
/**
* @category Error
* @description Error that indicates invalid or unconfigured context when executing a view
*/
class InvalidViewSimulationContext extends taquito_core_1.ParameterValidationError {
constructor(info) {
super();
this.info = info;
this.name = 'InvalidViewSimulationContext';
this.message = `${info} Please configure the context of the view execution in the executeView method.`;
}
}
exports.InvalidViewSimulationContext = InvalidViewSimulationContext;
/**
* @category Error
* @description Error that indicates a mistake happening during the reveal operation
*/
class RevealOperationError extends taquito_core_1.RpcError {
constructor(message) {
super();
this.message = message;
this.name = 'RevealOperationError';
}
}
exports.RevealOperationError = RevealOperationError;
/**
* @category Error
* @description Error that indicates a mistake in the parameters in the preparation of an Origination operation
*/
class OriginationParameterError extends taquito_core_1.ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name;
}
}
exports.OriginationParameterError = OriginationParameterError;
/**
* @category Error
* @description Error that indicates an invalid balance being passed or used
*/
class InvalidBalanceError extends taquito_core_1.ParameterValidationError {
constructor(message) {
super();
this.message = message;
this.name = 'InvalidBalanceError';
}
}
exports.InvalidBalanceError = InvalidBalanceError;