UNPKG

eth-rpc-cache

Version:

A simple cache for Ethereum RPC requests extensible with different caching strategies

35 lines (34 loc) 1.65 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var JsonRpcError = /** @class */ (function (_super) { __extends(JsonRpcError, _super); function JsonRpcError(message, code) { var _this = _super.call(this, message) || this; _this.code = code; _this.code = code; // Set the prototype explicitly. // See https://github.com/microsoft/TypeScript-wiki/blob/81fe7b91664de43c02ea209492ec1cea7f3661d0/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work Object.setPrototypeOf(_this, JsonRpcError.prototype); return _this; } return JsonRpcError; }(Error)); export var errors = { internalServerError: function (err) { return new JsonRpcError((err === null || err === void 0 ? void 0 : err.message) || 'Internal error', -32603); }, methodNotFound: function () { return new JsonRpcError('Method not found', -32601); } };