@injectivelabs/exceptions
Advanced tools
Comparing version 1.0.32 to 1.0.33
@@ -544,2 +544,3 @@ import { ChainAuctionErrorCodes, ChainCosmosErrorCode, ChainExchangeModuleErrorCode, ChainInsuranceErrorCodes } from './types'; | ||
}; | ||
export declare const chainCodeErrorMessagesMap: Record<number, string>; | ||
//# sourceMappingURL=messages.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.chainErrorMessagesMap = void 0; | ||
exports.chainCodeErrorMessagesMap = exports.chainErrorMessagesMap = void 0; | ||
const types_1 = require("./types"); | ||
/* todo: remove this with the next chain upgrade */ | ||
exports.chainErrorMessagesMap = { | ||
@@ -544,2 +545,142 @@ 'insufficient fee': { | ||
}; | ||
exports.chainCodeErrorMessagesMap = { | ||
[types_1.ChainCosmosErrorCode.ErrInsufficientFee]: 'You do not have enough funds to cover the transaction fees.', | ||
[types_1.ChainCosmosErrorCode.ErrInsufficientFunds]: 'You do not have enough funds.', | ||
[types_1.ChainCosmosErrorCode.ErrTxTimeoutHeight]: 'The transaction failed to be included within a block on time.', | ||
[types_1.ChainCosmosErrorCode.ErrTxDecode]: 'There is an issue while parsing the transaction', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidSequence]: 'The sequence number is not valid', | ||
[types_1.ChainCosmosErrorCode.ErrUnauthorized]: 'Unauthorized', | ||
[types_1.ChainCosmosErrorCode.ErrUnknownRequest]: 'The request is not known', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidAddress]: 'The address is not valid', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidPubKey]: 'The public key is not valid', | ||
[types_1.ChainCosmosErrorCode.ErrUnknownAddress]: 'The address is unknown', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidCoins]: 'The coins are not valid', | ||
[types_1.ChainCosmosErrorCode.ErrOutOfGas]: 'The transaction run out of gas', | ||
[types_1.ChainCosmosErrorCode.ErrMemoTooLarge]: 'The memo field in the transaction is too large', | ||
[types_1.ChainCosmosErrorCode.ErrTooManySignatures]: 'The transaction exceeded the maximum number of signatures', | ||
[types_1.ChainCosmosErrorCode.ErrNoSignatures]: 'There are no signatures appended on the transaction', | ||
[types_1.ChainCosmosErrorCode.ErrJSONMarshal]: 'There is an issue while parsing the transaction', | ||
[types_1.ChainCosmosErrorCode.ErrJSONUnmarshal]: 'There is an issue while parsing the transaction', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidRequest]: 'invalid request', | ||
[types_1.ChainCosmosErrorCode.ErrTxInMempoolCache]: 'The transaction is already in the mempool', | ||
[types_1.ChainCosmosErrorCode.ErrMempoolIsFull]: 'The mempool is full', | ||
[types_1.ChainCosmosErrorCode.ErrTxTooLarge]: 'The transaction is too large', | ||
[types_1.ChainCosmosErrorCode.ErrKeyNotFound]: 'The key has not been found', | ||
[types_1.ChainCosmosErrorCode.ErrWrongPassword]: 'invalid account password', | ||
[types_1.ChainCosmosErrorCode.ErrorInvalidSigner]: 'tx intended signer does not match the given signer', | ||
[types_1.ChainCosmosErrorCode.ErrorInvalidGasAdjustment]: 'invalid gas adjustment', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidHeight]: 'The height provided in the transaction is not valid', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidVersion]: 'The version provided in the transaction is not valid', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidChainID]: 'The chainId provided in the transaction is not valid', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidType]: 'The type provided in the transaction is not valid', | ||
[types_1.ChainCosmosErrorCode.ErrUnknownExtensionOptions]: 'The extension options provided in the transaction is unknown', | ||
[types_1.ChainCosmosErrorCode.ErrWrongSequence]: 'The sequence number provided in the transaction is incorrect', | ||
[types_1.ChainCosmosErrorCode.ErrPackAny]: 'failed packing protobuf message to Any', | ||
[types_1.ChainCosmosErrorCode.ErrUnpackAny]: 'failed unpacking protobuf message from Any', | ||
[types_1.ChainCosmosErrorCode.ErrLogic]: 'Internal logic error', | ||
[types_1.ChainCosmosErrorCode.ErrConflict]: 'conflict', | ||
[types_1.ChainCosmosErrorCode.ErrNotSupported]: 'The feature is not supported', | ||
[types_1.ChainCosmosErrorCode.ErrNotFound]: 'not found', | ||
[types_1.ChainCosmosErrorCode.ErrIO]: 'Internal IO error', | ||
[types_1.ChainCosmosErrorCode.ErrAppConfig]: 'error in app.toml', | ||
[types_1.ChainCosmosErrorCode.ErrInvalidGasLimit]: 'The gas limit provided in the transaction is not valid', | ||
// Auction Module Messages | ||
[types_1.ChainAuctionErrorCodes.ErrBidInvalid]: 'The gas limit provided in the transaction is not valid', | ||
[types_1.ChainAuctionErrorCodes.ErrBidRound]: 'The gas limit provided in the transaction is not valid', | ||
// Insurance Module Messages | ||
[types_1.ChainInsuranceErrorCodes.ErrInsuranceFundAlreadyExists]: 'The insurance fund already exists', | ||
[types_1.ChainInsuranceErrorCodes.ErrInsuranceFundNotFound]: 'The insurance fund is not found', | ||
[types_1.ChainInsuranceErrorCodes.ErrRedemptionAlreadyExists]: 'The redemption already exists', | ||
[types_1.ChainInsuranceErrorCodes.ErrInvalidDepositAmount]: 'The deposit amount is not valid', | ||
[types_1.ChainInsuranceErrorCodes.ErrInvalidDepositDenom]: 'The deposit denom is not valid', | ||
[types_1.ChainInsuranceErrorCodes.ErrPayoutTooLarge]: 'The insurance fund payout exceeds the deposits', | ||
[types_1.ChainInsuranceErrorCodes.ErrInvalidTicker]: 'The ticker is not valid', | ||
[types_1.ChainInsuranceErrorCodes.ErrInvalidQuoteDenom]: 'The quote denom is not valid', | ||
[types_1.ChainInsuranceErrorCodes.ErrInvalidOracle]: 'The oracle is not valid', | ||
[types_1.ChainInsuranceErrorCodes.ErrInvalidExpirationTime]: 'The expiration time is not valid', | ||
[types_1.ChainInsuranceErrorCodes.ErrInvalidMarketID]: 'The marketId is not valid', | ||
[types_1.ChainInsuranceErrorCodes.ErrInvalidShareDenom]: 'The share denom is not valid', | ||
// Exchange Module Messages | ||
[types_1.ChainExchangeModuleErrorCode.ErrOrderInvalid]: 'Your order failed to validate', | ||
[types_1.ChainExchangeModuleErrorCode.ErrSpotMarketNotFound]: 'The spot market has not been found', | ||
[types_1.ChainExchangeModuleErrorCode.ErrSpotMarketExists]: 'The spot market already exists', | ||
[types_1.ChainExchangeModuleErrorCode.ErrBadField]: 'There is an issue with your order', | ||
[types_1.ChainExchangeModuleErrorCode.ErrMarketInvalid]: 'The market failed to validate', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInsufficientDeposit]: 'Your trading account has insufficient funds', | ||
[types_1.ChainExchangeModuleErrorCode.ErrUnrecognizedOrderType]: 'The order type is not recognized', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInsufficientPositionQuantity]: 'The position quantity is insufficient for the order', | ||
[types_1.ChainExchangeModuleErrorCode.ErrOrderHashInvalid]: 'The order hash is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrBadSubaccountID]: 'The subaccount id is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidBaseDenom]: '', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidExpiry]: 'The expiry date is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidPrice]: 'The price is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidQuantity]: 'The quantity is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrUnsupportedOracleType]: 'The oracle type is not supported', | ||
[types_1.ChainExchangeModuleErrorCode.ErrOrderDoesntExist]: 'The order does not exist', | ||
[types_1.ChainExchangeModuleErrorCode.ErrOrderbookFillInvalid]: '', | ||
[types_1.ChainExchangeModuleErrorCode.ErrPerpetualMarketExists]: 'The perpetual market already exists', | ||
[types_1.ChainExchangeModuleErrorCode.ErrExpiryFuturesMarketExists]: 'The expiry futures market market already exists', | ||
[types_1.ChainExchangeModuleErrorCode.ErrExpiryFuturesMarketExpired]: 'The expiry futures market has expired', | ||
[types_1.ChainExchangeModuleErrorCode.ErrNoLiquidity]: 'There is not enough liquidity', | ||
[types_1.ChainExchangeModuleErrorCode.ErrSlippageExceedsWorstPrice]: 'There is not enough liquidity', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInsufficientOrderMargin]: 'The order has insufficient margin', | ||
[types_1.ChainExchangeModuleErrorCode.ErrDerivativeMarketNotFound]: 'The derivative market cannot be found', | ||
[types_1.ChainExchangeModuleErrorCode.ErrPositionNotFound]: 'The position cannot be found', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidReduceOnlyPositionDirection]: 'Position direction does not oppose the reduce-only order', | ||
[types_1.ChainExchangeModuleErrorCode.ErrPriceSurpassesBankruptcyPrice]: 'Your order price surpasses bankruptcy price', | ||
[types_1.ChainExchangeModuleErrorCode.ErrPositionNotLiquidable]: 'The position is not liquidable', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidTriggerPrice]: 'Your order trigger price is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidOracleType]: 'The oracle type is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidPriceTickSize]: 'The minimum price tick size is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidQuantityTickSize]: 'The minimum quantity tick size is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidMargin]: "Your order's minimum margin is not valid ", | ||
[types_1.ChainExchangeModuleErrorCode.ErrExceedsOrderSideCount]: 'You cannot have more orders for this market for this direction', | ||
[types_1.ChainExchangeModuleErrorCode.ErrMarketOrderAlreadyExists]: 'You cannot place another market order within this block', | ||
[types_1.ChainExchangeModuleErrorCode.ErrConditionalMarketOrderAlreadyExists]: 'You cannot place another conditional market order', | ||
[types_1.ChainExchangeModuleErrorCode.ErrMarketLaunchProposalAlreadyExists]: 'There is an existing equivalent market launch proposal.', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidMarketStatus]: 'The market status is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrSameDenoms]: 'The base denom and quote denom cannot be same', | ||
[types_1.ChainExchangeModuleErrorCode.ErrSameOracles]: 'The oracle base and the oracle quote cannot be the same', | ||
[types_1.ChainExchangeModuleErrorCode.ErrFeeRatesRelation]: 'The MakerFeeRate does not match TakerFeeRate requirements', | ||
[types_1.ChainExchangeModuleErrorCode.ErrMarginsRelation]: 'The MaintenanceMarginRatio cannot be greater than InitialMarginRatio', | ||
[types_1.ChainExchangeModuleErrorCode.ErrExceedsMaxOracleScaleFactor]: 'The OracleScaleFactor cannot be greater than MaxOracleScaleFactor', | ||
[types_1.ChainExchangeModuleErrorCode.ErrSpotExchangeNotEnabled]: 'Spot exchange is not enabled yet', | ||
[types_1.ChainExchangeModuleErrorCode.ErrDerivativesExchangeNotEnabled]: 'Derivatives exchange is not enabled yet', | ||
[types_1.ChainExchangeModuleErrorCode.ErrOraclePriceDeltaExceedsThreshold]: 'The oracle price delta exceeds threshold', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidHourlyInterestRate]: 'The hourly interest rate is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidHourlyFundingRateCap]: 'The hourly funding rate cap is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidMarketFundingParamUpdate]: 'You can only update funding parameters on perpetual markets.', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidTradingRewardCampaign]: 'The trading reward campaign is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidFeeDiscountSchedule]: 'The fee discount schedule is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidLiquidationOrder]: 'The liquidation order is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrTradingRewardCampaignDistributionError]: 'Unknown error happened for campaign distributions', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidTradingRewardsPendingPointsUpdate]: 'The updated trading reward points is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidBatchMsgUpdate]: 'The MsgBatchUpdate is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrExceedsTopOfBookPrice]: 'The post-only order price exceeds top of the orderbook price', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidOrderTypeForMessage]: 'The order type is not supported for this message', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidDMMSender]: 'The sender must match the DMM address', | ||
[types_1.ChainExchangeModuleErrorCode.ErrAlreadyOptedOutOfRewards]: 'The DMM address already opted out of rewards', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidMarginRatio]: 'The margin ratio is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrBelowMinimalContribution]: 'The provided funds are below minimum', | ||
[types_1.ChainExchangeModuleErrorCode.ErrLowPositionMargin]: 'The position is below initial margin requirement', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidTotalSupply]: 'The pool has non-positive total LP token supply', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidLpTokenBurnAmount]: 'The passed LP token burn amount is greater than total LP token supply', | ||
[types_1.ChainExchangeModuleErrorCode.ErrUnsupportedAction]: 'This action is not supported', | ||
[types_1.ChainExchangeModuleErrorCode.ErrNegativePositionQuantity]: 'The position quantity cannot be negative', | ||
[types_1.ChainExchangeModuleErrorCode.ErrBinaryOptionsMarketExists]: 'The BinaryOptions market already exists', | ||
[types_1.ChainExchangeModuleErrorCode.ErrBinaryOptionsMarketNotFound]: 'The BinaryOptions market cannot be found', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidSettlement]: 'The settlement price is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrAccountDoesntExist]: 'The trading account does not exist', | ||
[types_1.ChainExchangeModuleErrorCode.ErrSenderIsNotAnAdmin]: 'The sender should be the admin of the market', | ||
[types_1.ChainExchangeModuleErrorCode.ErrMarketAlreadyScheduledToSettle]: 'The market is already scheduled to settle ', | ||
[types_1.ChainExchangeModuleErrorCode.ErrGenericMarketNotFound]: 'The market cannot be found', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidDenomDecimal]: 'The denom decimal cannot be below 1 or above max scale factor', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidState]: 'The state is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrTransientOrdersUpToCancelNotSupported]: 'The transient orders up to cancellation not supported', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidTrade]: 'The trade is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrNoMarginLocked]: 'There is no margin locked in the trading account', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidAccessLevel]: 'There is no access to perform action', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidAddress]: 'The address is not valid', | ||
[types_1.ChainExchangeModuleErrorCode.ErrInvalidArgument]: 'The argument is not valid', | ||
}; | ||
//# sourceMappingURL=messages.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
const types_1 = require("../types"); | ||
/* todo: remove this with the next chain upgrade */ | ||
const parseMessage = (message) => { | ||
@@ -20,3 +21,4 @@ const firstParse = message.split('message index: 0:'); | ||
exports.parseMessage = parseMessage; | ||
const mapFailedTransactionMessage = (message) => { | ||
/* todo: remove this with the next chain upgrade */ | ||
const mapMessageByContent = (message) => { | ||
const parsedMessage = (0, exports.parseMessage)(message); | ||
@@ -29,2 +31,32 @@ const messageInMapKey = Object.keys(messages_1.chainErrorMessagesMap).find((key) => parsedMessage.toLowerCase().includes(key.toLowerCase())); | ||
}; | ||
const getABCICode = (message) => { | ||
const chainCodePattern = /{key:"ABCICode" (.*?)}/g; | ||
const numericPattern = /\d+/g; | ||
const chainCodeMsg = message.match(chainCodePattern); | ||
if (!chainCodeMsg || chainCodeMsg.length === 0) { | ||
return; | ||
} | ||
const chainCode = chainCodeMsg[0].match(numericPattern); | ||
if (!chainCode || chainCode.length === 0) { | ||
return; | ||
} | ||
return Number(chainCode[0]); | ||
}; | ||
const mapFailedTransactionMessage = (message) => { | ||
const ABCICode = getABCICode(message); | ||
if (!ABCICode) { | ||
return mapMessageByContent(message); | ||
} | ||
const chainCodeErrorMessage = messages_1.chainCodeErrorMessagesMap[ABCICode]; | ||
if (!chainCodeErrorMessage) { | ||
return { | ||
message: messages_1.chainCodeErrorMessagesMap[types_1.ChainCosmosErrorCode.ErrUnknownRequest], | ||
code: types_1.ChainCosmosErrorCode.ErrUnknownRequest, | ||
}; | ||
} | ||
return { | ||
message: chainCodeErrorMessage, | ||
code: ABCICode, | ||
}; | ||
}; | ||
exports.mapFailedTransactionMessage = mapFailedTransactionMessage; | ||
@@ -31,0 +63,0 @@ const mapMetamaskMessage = (message) => { |
{ | ||
"name": "@injectivelabs/exceptions", | ||
"description": "List of exceptions that can be reused throughout Injective's projects.", | ||
"version": "1.0.32", | ||
"version": "1.0.33", | ||
"license": "Apache-2.0", | ||
@@ -40,3 +40,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "e3150ffbb78703ba3dd641879277ff74bcf0016f" | ||
"gitHead": "89d9e8da85e9a8dd42c90d4d3ae23dab994b7099" | ||
} |
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
176424
2440