@web3-react/url
Advanced tools
Comparing version 8.0.16-alpha.0 to 8.0.16-beta.0
@@ -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" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
2
1
0
2
40597
3
104
1
No
- Removed@ethersproject/experimental@^5.4.0
- Removed@ethersproject/abi@5.7.0(transitive)
- Removed@ethersproject/contracts@5.7.0(transitive)
- Removed@ethersproject/experimental@5.7.0(transitive)
- Removed@ethersproject/hdnode@5.7.0(transitive)
- Removed@ethersproject/json-wallets@5.7.0(transitive)
- Removed@ethersproject/pbkdf2@5.7.0(transitive)
- Removed@ethersproject/solidity@5.7.0(transitive)
- Removed@ethersproject/units@5.7.0(transitive)
- Removed@ethersproject/wallet@5.7.0(transitive)
- Removed@ethersproject/wordlists@5.7.0(transitive)
- Removedaes-js@3.0.0(transitive)
- Removedethers@5.7.2(transitive)
- Removedscrypt-js@3.0.1(transitive)
Updated@ethersproject/providers@^5