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

@web3-react/url

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3-react/url - npm Package Compare versions

Comparing version 8.0.16-alpha.0 to 8.0.16-beta.0

README.md

19

dist/index.d.ts

@@ -1,2 +0,2 @@

import type { Eip1193Bridge } from '@ethersproject/experimental';
import type { JsonRpcProvider } from '@ethersproject/providers';
import type { ConnectionInfo } from '@ethersproject/web';

@@ -7,8 +7,17 @@ import type { Actions } from '@web3-react/types';

export declare class Url extends Connector {
provider: Eip1193Bridge | undefined;
private url;
constructor(actions: Actions, url: url, connectEagerly?: boolean);
private initialize;
/** {@inheritdoc Connector.provider} */
readonly provider: undefined;
/** {@inheritdoc Connector.customProvider} */
customProvider: JsonRpcProvider | undefined;
private eagerConnection?;
private readonly url;
/**
* @param url - An RPC url or a JsonRpcProvider.
* @param connectEagerly - A flag indicating whether connection should be initiated when the class is constructed.
*/
constructor(actions: Actions, url: url | JsonRpcProvider, connectEagerly?: boolean);
private isomorphicInitialize;
/** {@inheritdoc Connector.activate} */
activate(): Promise<void>;
}
export {};

@@ -0,1 +1,25 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,29 +34,44 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { Connector } from '@web3-react/types';
export class Url extends Connector {
constructor(actions, url, connectEagerly = true) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Url = void 0;
const types_1 = require("@web3-react/types");
function isUrl(url) {
return typeof url === 'string' || ('url' in url && !('connection' in url));
}
class Url extends types_1.Connector {
/**
* @param url - An RPC url or a JsonRpcProvider.
* @param connectEagerly - A flag indicating whether connection should be initiated when the class is constructed.
*/
constructor(actions, url, connectEagerly = false) {
super(actions);
if (connectEagerly && typeof window === 'undefined') {
throw new Error('connectEagerly = true is invalid for SSR, instead use the activate method in a useEffect');
}
this.url = url;
if (connectEagerly) {
void this.initialize();
}
if (connectEagerly)
void this.activate();
}
initialize() {
isomorphicInitialize() {
return __awaiter(this, void 0, void 0, function* () {
this.actions.startActivation();
// create the provider if necessary
if (!this.provider) {
// instantiate new provider
const [JsonRpcProvider, Eip1193Bridge] = yield Promise.all([
import('@ethersproject/providers').then(({ JsonRpcProvider }) => JsonRpcProvider),
import('@ethersproject/experimental').then(({ Eip1193Bridge }) => Eip1193Bridge),
]);
const provider = new JsonRpcProvider(this.url);
this.provider = new Eip1193Bridge(provider.getSigner(), provider);
}
return this.provider
.request({ method: 'eth_chainId' })
.then((chainId) => {
if (this.eagerConnection)
return this.eagerConnection;
if (!isUrl(this.url))
return this.url;
return (this.eagerConnection = Promise.resolve().then(() => __importStar(require('@ethersproject/providers'))).then(({ JsonRpcProvider }) => {
return new JsonRpcProvider(this.url);
}));
});
}
/** {@inheritdoc Connector.activate} */
activate() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.customProvider)
this.actions.startActivation();
yield this.isomorphicInitialize()
.then((customProvider) => __awaiter(this, void 0, void 0, function* () {
this.customProvider = customProvider;
const { chainId } = yield this.customProvider.getNetwork();
this.actions.update({ chainId, accounts: [] });
})
}))
.catch((error) => {

@@ -43,7 +82,3 @@ this.actions.reportError(error);

}
activate() {
return __awaiter(this, void 0, void 0, function* () {
return this.initialize();
});
}
}
exports.Url = Url;
{
"name": "@web3-react/url",
"keywords": [
"web3-react"
],
"author": "Noah Zinsmeister <noahwz@gmail.com>",
"license": "GPL-3.0-or-later",
"repository": "github:NoahZinsmeister/web3-react",
"publishConfig": {
"access": "public"
},
"version": "8.0.16-alpha.0",
"type": "module",
"version": "8.0.16-beta.0",
"files": [
"dist/*"
],
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/cjs/index.js"
},
"type": "commonjs",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"main": "./dist/cjs/index.js",
"main": "./dist/index.js",
"exports": "./dist/index.js",
"scripts": {
"prebuild": "rm -rf dist",
"build": "tsc && tsc --project tsconfig.cjs.json",
"build": "tsc",
"start": "tsc --watch"
},
"dependencies": {
"@ethersproject/experimental": "^5.4.0",
"@ethersproject/providers": "^5.4.5",
"@web3-react/types": "^8.0.15-alpha.0"
"@ethersproject/providers": "^5",
"@web3-react/types": "^8.0.11-beta.0"
},
"devDependencies": {
"@web3-react/store": "^8.0.15-alpha.0"
"@web3-react/store": "^8.0.16-beta.0"
},
"gitHead": "318fce50fd26cd26fe2d99df1a95b24bdc029ec3"
"gitHead": "5a989c94036fc99e143f70003db07b0af1669aa2"
}
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