UNPKG

@saberhq/sail

Version:

Account caching and batched loading for React-based Solana applications.

40 lines 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.categorizeTransactionError = exports.TransactionErrorType = void 0; var TransactionErrorType; (function (TransactionErrorType) { TransactionErrorType["NotConfirmed"] = "not-confirmed"; TransactionErrorType["Cancelled"] = "cancelled"; TransactionErrorType["NodeBehind"] = "node-behind"; TransactionErrorType["SignatureRequestDenied"] = "signature-request-denied"; TransactionErrorType["InsufficientSOL"] = "insufficient-sol"; TransactionErrorType["BlockhashNotFound"] = "blockhash-not-found"; })(TransactionErrorType = exports.TransactionErrorType || (exports.TransactionErrorType = {})); /** * Categorizes an error coming from the Solana Web3 SDK. * @param msg * @returns */ const categorizeTransactionError = (msg) => { if (msg.startsWith("Transaction was not confirmed in")) { return TransactionErrorType.NotConfirmed; } if (msg.startsWith("Transaction cancelled")) { return TransactionErrorType.Cancelled; } if (msg.startsWith("failed to send transaction: Node is behind by")) { return TransactionErrorType.NodeBehind; } if (msg === "Signature request denied") { return TransactionErrorType.SignatureRequestDenied; } if (msg === "Insufficient SOL balance") { return TransactionErrorType.InsufficientSOL; } if (msg.endsWith("Blockhash not found")) { return TransactionErrorType.BlockhashNotFound; } return null; }; exports.categorizeTransactionError = categorizeTransactionError; //# sourceMappingURL=categorizeTransactionError.js.map