web3-error-helper
Version:
> 🛠️ Turn confusing Web3 errors into clear, human-friendly messages for developers and users alike.
68 lines (67 loc) • 2.05 kB
JavaScript
/**
* TypeScript types for the web3-error-helper package
*
* This module contains all the core type definitions, enums, and constants
* used throughout the library. It serves as the central type registry that
* ensures type safety and consistency across all modules. Uses modern
* TypeScript features and utility types for enhanced developer experience.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ERROR_TYPE_KEYWORDS = exports.SupportedChain = exports.createErrorPattern = exports.createChainId = void 0;
/**
* Branded types for better type safety
*/
const createChainId = (id) => id;
exports.createChainId = createChainId;
const createErrorPattern = (pattern) => pattern;
exports.createErrorPattern = createErrorPattern;
/**
* Supported blockchain networks
*/
var SupportedChain;
(function (SupportedChain) {
SupportedChain["ETHEREUM"] = "ethereum";
SupportedChain["POLYGON"] = "polygon";
SupportedChain["ARBITRUM"] = "arbitrum";
SupportedChain["OPTIMISM"] = "optimism";
SupportedChain["BSC"] = "bsc";
SupportedChain["AVALANCHE"] = "avalanche";
SupportedChain["FANTOM"] = "fantom";
SupportedChain["BASE"] = "base";
})(SupportedChain || (exports.SupportedChain = SupportedChain = {}));
/**
* Error type detection keywords (ordered by specificity)
*/
exports.ERROR_TYPE_KEYWORDS = {
WALLET: [
'wallet',
'user rejected',
'user denied',
'wallet connection',
'billetera',
'carteira',
'portefeuille',
],
CONTRACT: ['contract', 'execution reverted', 'revert', 'contrato', 'contrat'],
GAS: ['gas', 'insufficient gas', 'out of gas', 'gás', 'gaz'],
TRANSACTION: [
'transaction',
'tx',
'nonce',
'transacción',
'transação',
'transaction',
],
NETWORK: [
'network',
'timeout',
'connection',
'red',
'rede',
'réseau',
'conexión',
'conexão',
'connexion',
],
};
;