Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@polymarket/multi-endpoint-provider

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polymarket/multi-endpoint-provider - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

lib.esm/types.d.ts

3

lib.esm/index.d.ts
import { JsonRpcMultiProvider } from "./JsonRpcMultiProvider";
import { Web3MultiProvider, JsonRpcFetchFunc } from "./Web3MultiProvider";
import { MultiError, HandleErrorFunc, ProviderOptions } from "./types";
export { JsonRpcMultiProvider, Web3MultiProvider };
export type { JsonRpcFetchFunc };
export type { JsonRpcFetchFunc, MultiError, HandleErrorFunc, ProviderOptions };
import { JsonRpcMultiProvider } from "./JsonRpcMultiProvider";
import { Web3MultiProvider } from "./Web3MultiProvider";
import { MultiError } from "./types";
export { JsonRpcMultiProvider, Web3MultiProvider };
import { JsonRpcProvider } from "@ethersproject/providers";
import { Networkish } from "@ethersproject/networks";
import { MultiError } from "./MultiError";
export declare const getError: (errors: string[]) => MultiError;
import { HandleErrorFunc, ProviderOptions } from "./types";
export declare class JsonRpcMultiProvider extends JsonRpcProvider {
readonly rpcUrls: string[];
constructor(rpcUrls: string[], network?: Networkish);
readonly handleRequestError: HandleErrorFunc;
constructor(rpcUrls: string[], options?: ProviderOptions);
send(method: string, params: Array<any>): Promise<any>;
_send(method: string, params: Array<any>): Promise<any>;
}

@@ -13,4 +13,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { deepCopy, defineReadOnly } from "@ethersproject/properties";
import { MultiError } from "./MultiError";
export const getError = (errors) => new MultiError(`Rpc requests unsuccessful.\n${errors.map(err => ` ${err}`).join("\n")}`, errors);
import { getError } from "./utils";
function getResult(payload) {

@@ -27,4 +26,5 @@ if (payload.error) {

export class JsonRpcMultiProvider extends JsonRpcProvider {
constructor(rpcUrls, network) {
super(rpcUrls[0], network);
constructor(rpcUrls, options) {
super(rpcUrls[0], options === null || options === void 0 ? void 0 : options.network);
defineReadOnly(this, "handleRequestError", options === null || options === void 0 ? void 0 : options.handleRequestError);
defineReadOnly(this, "rpcUrls", rpcUrls);

@@ -80,2 +80,4 @@ }

});
if (this.handleRequestError)
this.handleRequestError(error, i);
const errMessage = (error.message || error).toString();

@@ -82,0 +84,0 @@ errors.push(errMessage);

@@ -1,4 +0,4 @@

import { Networkish } from "@ethersproject/networks";
import { ExternalProvider } from "@ethersproject/providers";
import { JsonRpcMultiProvider } from "./JsonRpcMultiProvider";
import { HandleErrorFunc, ProviderOptions } from "./types";
export declare type JsonRpcFetchFunc = (method: string, params?: Array<any>) => Promise<any>;

@@ -8,5 +8,6 @@ export declare class Web3MultiProvider extends JsonRpcMultiProvider {

readonly jsonRpcFetchFuncs: JsonRpcFetchFunc[];
constructor(providers: (ExternalProvider | JsonRpcFetchFunc)[], network?: Networkish);
readonly handleRequestError: HandleErrorFunc;
constructor(providers: (ExternalProvider | JsonRpcFetchFunc)[], options?: ProviderOptions);
send(method: string, params: Array<any>): Promise<any>;
_send(method: string, params: Array<any>): Promise<any>;
}

@@ -16,3 +16,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { Logger } from "@ethersproject/logger";
import { JsonRpcMultiProvider, getError } from "./JsonRpcMultiProvider";
import { JsonRpcMultiProvider } from "./JsonRpcMultiProvider";
import { getError } from "./utils";
const logger = new Logger("providers/5.1.2");

@@ -104,3 +105,3 @@ let _nextId = 1;

export class Web3MultiProvider extends JsonRpcMultiProvider {
constructor(providers, network) {
constructor(providers, options) {
logger.checkNew(new.target, Web3MultiProvider);

@@ -120,5 +121,6 @@ if (providers == null) {

}
super(paths, network);
super(paths, options);
defineReadOnly(this, "jsonRpcFetchFuncs", jsonRpcFetchFuncs);
defineReadOnly(this, "providers", subproviders);
defineReadOnly(this, "handleRequestError", options === null || options === void 0 ? void 0 : options.handleRequestError);
}

@@ -139,2 +141,4 @@ send(method, params) {

catch (error) {
if (this.handleRequestError)
this.handleRequestError(error, i);
const errMessage = (error.message || error).toString();

@@ -141,0 +145,0 @@ errors.push(errMessage);

import { JsonRpcMultiProvider } from "./JsonRpcMultiProvider";
import { Web3MultiProvider, JsonRpcFetchFunc } from "./Web3MultiProvider";
import { MultiError, HandleErrorFunc, ProviderOptions } from "./types";
export { JsonRpcMultiProvider, Web3MultiProvider };
export type { JsonRpcFetchFunc };
export type { JsonRpcFetchFunc, MultiError, HandleErrorFunc, ProviderOptions };

@@ -8,1 +8,2 @@ "use strict";

Object.defineProperty(exports, "Web3MultiProvider", { enumerable: true, get: function () { return Web3MultiProvider_1.Web3MultiProvider; } });
var types_1 = require("./types");
import { JsonRpcProvider } from "@ethersproject/providers";
import { Networkish } from "@ethersproject/networks";
import { MultiError } from "./MultiError";
export declare const getError: (errors: string[]) => MultiError;
import { HandleErrorFunc, ProviderOptions } from "./types";
export declare class JsonRpcMultiProvider extends JsonRpcProvider {
readonly rpcUrls: string[];
constructor(rpcUrls: string[], network?: Networkish);
readonly handleRequestError: HandleErrorFunc;
constructor(rpcUrls: string[], options?: ProviderOptions);
send(method: string, params: Array<any>): Promise<any>;
_send(method: string, params: Array<any>): Promise<any>;
}

@@ -52,11 +52,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonRpcMultiProvider = exports.getError = void 0;
exports.JsonRpcMultiProvider = void 0;
var providers_1 = require("@ethersproject/providers");
var web_1 = require("@ethersproject/web");
var properties_1 = require("@ethersproject/properties");
var MultiError_1 = require("./MultiError");
var getError = function (errors) {
return new MultiError_1.MultiError("Rpc requests unsuccessful.\n" + errors.map(function (err) { return " " + err; }).join("\n"), errors);
};
exports.getError = getError;
var utils_1 = require("./utils");
function getResult(payload) {

@@ -74,4 +70,5 @@ if (payload.error) {

__extends(JsonRpcMultiProvider, _super);
function JsonRpcMultiProvider(rpcUrls, network) {
var _this = _super.call(this, rpcUrls[0], network) || this;
function JsonRpcMultiProvider(rpcUrls, options) {
var _this = _super.call(this, rpcUrls[0], options === null || options === void 0 ? void 0 : options.network) || this;
properties_1.defineReadOnly(_this, "handleRequestError", options === null || options === void 0 ? void 0 : options.handleRequestError);
properties_1.defineReadOnly(_this, "rpcUrls", rpcUrls);

@@ -139,2 +136,4 @@ return _this;

});
if (this.handleRequestError)
this.handleRequestError(error_1, i);
errMessage = (error_1.message || error_1).toString();

@@ -147,3 +146,3 @@ errors.push(errMessage);

case 6:
error = exports.getError(errors);
error = utils_1.getError(errors);
throw error;

@@ -150,0 +149,0 @@ }

@@ -1,4 +0,4 @@

import { Networkish } from "@ethersproject/networks";
import { ExternalProvider } from "@ethersproject/providers";
import { JsonRpcMultiProvider } from "./JsonRpcMultiProvider";
import { HandleErrorFunc, ProviderOptions } from "./types";
export declare type JsonRpcFetchFunc = (method: string, params?: Array<any>) => Promise<any>;

@@ -8,5 +8,6 @@ export declare class Web3MultiProvider extends JsonRpcMultiProvider {

readonly jsonRpcFetchFuncs: JsonRpcFetchFunc[];
constructor(providers: (ExternalProvider | JsonRpcFetchFunc)[], network?: Networkish);
readonly handleRequestError: HandleErrorFunc;
constructor(providers: (ExternalProvider | JsonRpcFetchFunc)[], options?: ProviderOptions);
send(method: string, params: Array<any>): Promise<any>;
_send(method: string, params: Array<any>): Promise<any>;
}

@@ -60,2 +60,3 @@ "use strict";

var JsonRpcMultiProvider_1 = require("./JsonRpcMultiProvider");
var utils_1 = require("./utils");
var logger = new logger_1.Logger("providers/5.1.2");

@@ -148,3 +149,3 @@ var _nextId = 1;

__extends(Web3MultiProvider, _super);
function Web3MultiProvider(providers, network) {
function Web3MultiProvider(providers, options) {
var _newTarget = this.constructor;

@@ -166,5 +167,6 @@ var _this = this;

}
_this = _super.call(this, paths, network) || this;
_this = _super.call(this, paths, options) || this;
properties_1.defineReadOnly(_this, "jsonRpcFetchFuncs", jsonRpcFetchFuncs);
properties_1.defineReadOnly(_this, "providers", subproviders);
properties_1.defineReadOnly(_this, "handleRequestError", options === null || options === void 0 ? void 0 : options.handleRequestError);
return _this;

@@ -196,2 +198,4 @@ }

error_2 = _a.sent();
if (this.handleRequestError)
this.handleRequestError(error_2, i);
errMessage = (error_2.message || error_2).toString();

@@ -204,3 +208,3 @@ errors.push(errMessage);

case 6:
error = JsonRpcMultiProvider_1.getError(errors);
error = utils_1.getError(errors);
throw error;

@@ -207,0 +211,0 @@ }

{
"name": "@polymarket/multi-endpoint-provider",
"version": "0.0.3",
"version": "0.1.0",
"description": "ethers.js Providers that try backup rpc endpoints when requests fail",

@@ -36,2 +36,3 @@ "author": "Sam Hatem <sam.hatem17@gmail.com>",

"lint-staged": "^10.5.3",
"lodash": "^4.17.21",
"npm-run-all": "^4.1.5",

@@ -61,3 +62,6 @@ "prettier": "^2.2.1",

"start": "run-p start:*"
},
"resolutions": {
"lodash": "4.17.21"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc