@web3-react/url
Advanced tools
Comparing version 8.0.6-beta.0 to 8.0.7-beta.0
@@ -9,2 +9,3 @@ import type { Eip1193Bridge } from '@ethersproject/experimental'; | ||
provider: Eip1193Bridge | undefined; | ||
private eagerConnection?; | ||
private url; | ||
@@ -16,3 +17,3 @@ /** | ||
constructor(actions: Actions, url: url, connectEagerly?: boolean); | ||
private initialize; | ||
private isomorphicInitialize; | ||
/** {@inheritdoc Connector.activate} */ | ||
@@ -19,0 +20,0 @@ activate(): Promise<void>; |
@@ -16,24 +16,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
*/ | ||
constructor(actions, url, connectEagerly = true) { | ||
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), | ||
]); | ||
if (this.eagerConnection) | ||
return this.eagerConnection; | ||
yield (this.eagerConnection = Promise.all([ | ||
import('@ethersproject/providers').then(({ JsonRpcProvider }) => JsonRpcProvider), | ||
import('@ethersproject/experimental').then(({ Eip1193Bridge }) => Eip1193Bridge), | ||
]).then(([JsonRpcProvider, Eip1193Bridge]) => { | ||
const provider = new JsonRpcProvider(this.url); | ||
this.provider = new Eip1193Bridge(provider.getSigner(), provider); | ||
} | ||
return this.provider | ||
.request({ method: 'eth_chainId' }) | ||
})); | ||
}); | ||
} | ||
/** {@inheritdoc Connector.activate} */ | ||
activate() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.actions.startActivation(); | ||
yield this.isomorphicInitialize(); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
return this.provider.request({ method: 'eth_chainId' }) | ||
.then((chainId) => { | ||
@@ -47,8 +54,2 @@ this.actions.update({ chainId, accounts: [] }); | ||
} | ||
/** {@inheritdoc Connector.activate} */ | ||
activate() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.initialize(); | ||
}); | ||
} | ||
} |
@@ -12,3 +12,3 @@ { | ||
}, | ||
"version": "8.0.6-beta.0", | ||
"version": "8.0.7-beta.0", | ||
"type": "module", | ||
@@ -28,3 +28,3 @@ "files": [ | ||
"prebuild": "rm -rf dist", | ||
"build": "tsc && tsc --project tsconfig.cjs.json && find ./dist/cjs/ -depth -name \"*.js\" -exec sh -c 'mv \"$1\" \"${1%.js}.cjs\"' _ {} \\;", | ||
"build": "tsc && tsc --project tsconfig.cjs.json", | ||
"start": "tsc --watch" | ||
@@ -35,8 +35,8 @@ }, | ||
"@ethersproject/providers": "^5.5.1", | ||
"@web3-react/types": "^8.0.4-beta.0" | ||
"@web3-react/types": "^8.0.5-beta.0" | ||
}, | ||
"devDependencies": { | ||
"@web3-react/store": "^8.0.6-beta.0" | ||
"@web3-react/store": "^8.0.7-beta.0" | ||
}, | ||
"gitHead": "aba55673f396cf8163e7265b9a5bc4c118f2a353" | ||
"gitHead": "5f4424eea3bd54b7a7c1c0e113f024de953b5f4c" | ||
} |
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
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
43137
149
0
1