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

@web3-react/coinbase-wallet

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3-react/coinbase-wallet - npm Package Compare versions

Comparing version 8.0.34-beta.0 to 8.0.35-beta.0

80

dist/index.js

@@ -98,14 +98,11 @@ "use strict";

yield this.isomorphicInitialize();
if (!this.connected)
if (!this.provider || !this.connected)
throw new Error('No existing connection');
return Promise.all([
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.provider.request({ method: 'eth_chainId' }),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.provider.request({ method: 'eth_accounts' }),
]).then(([chainId, accounts]) => {
if (!accounts.length)
throw new Error('No accounts returned');
this.actions.update({ chainId: parseChainId(chainId), accounts });
});
// Wallets may resolve eth_chainId and hang on eth_accounts pending user interaction, which may include changing
// chains; they should be requested serially, with accounts first, so that the chainId can settle.
const accounts = yield this.provider.request({ method: 'eth_accounts' });
if (!accounts.length)
throw new Error('No accounts returned');
const chainId = yield this.provider.request({ method: 'eth_chainId' });
this.actions.update({ chainId: parseChainId(chainId), accounts });
}

@@ -128,2 +125,3 @@ catch (error) {

activate(desiredChainIdOrChainParameters) {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -133,8 +131,6 @@ const desiredChainId = typeof desiredChainIdOrChainParameters === 'number'

: desiredChainIdOrChainParameters === null || desiredChainIdOrChainParameters === void 0 ? void 0 : desiredChainIdOrChainParameters.chainId;
if (this.connected) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (this.provider && this.connected) {
if (!desiredChainId || desiredChainId === parseChainId(this.provider.chainId))
return;
const desiredChainIdHex = `0x${desiredChainId.toString(16)}`;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this.provider.request({

@@ -145,4 +141,5 @@ method: 'wallet_switchEthereumChain',

if (error.code === 4902 && typeof desiredChainIdOrChainParameters !== 'number') {
if (!this.provider)
throw new Error('No provider');
// if we're here, we can try to add a new network
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this.provider.request({

@@ -159,29 +156,28 @@ method: 'wallet_addEthereumChain',

yield this.isomorphicInitialize();
return Promise.all([
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.provider.request({ method: 'eth_chainId' }),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.provider.request({ method: 'eth_requestAccounts' }),
]).then(([chainId, accounts]) => {
var _a;
const receivedChainId = parseChainId(chainId);
if (!desiredChainId || desiredChainId === receivedChainId)
return this.actions.update({ chainId: receivedChainId, accounts });
// if we're here, we can try to switch networks
const desiredChainIdHex = `0x${desiredChainId.toString(16)}`;
return (_a = this.provider) === null || _a === void 0 ? void 0 : _a.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: desiredChainIdHex }],
}).catch((error) => __awaiter(this, void 0, void 0, function* () {
if (error.code === 4902 && typeof desiredChainIdOrChainParameters !== 'number') {
// if we're here, we can try to add a new network
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this.provider.request({
method: 'wallet_addEthereumChain',
params: [Object.assign(Object.assign({}, desiredChainIdOrChainParameters), { chainId: desiredChainIdHex })],
});
}
throw error;
}));
});
if (!this.provider)
throw new Error('No provider');
// Wallets may resolve eth_chainId and hang on eth_accounts pending user interaction, which may include changing
// chains; they should be requested serially, with accounts first, so that the chainId can settle.
const accounts = yield this.provider.request({ method: 'eth_requestAccounts' });
const chainId = yield this.provider.request({ method: 'eth_chainId' });
const receivedChainId = parseChainId(chainId);
if (!desiredChainId || desiredChainId === receivedChainId)
return this.actions.update({ chainId: receivedChainId, accounts });
// if we're here, we can try to switch networks
const desiredChainIdHex = `0x${desiredChainId.toString(16)}`;
return (_a = this.provider) === null || _a === void 0 ? void 0 : _a.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: desiredChainIdHex }],
}).catch((error) => __awaiter(this, void 0, void 0, function* () {
if (error.code === 4902 && typeof desiredChainIdOrChainParameters !== 'number') {
if (!this.provider)
throw new Error('No provider');
// if we're here, we can try to add a new network
return this.provider.request({
method: 'wallet_addEthereumChain',
params: [Object.assign(Object.assign({}, desiredChainIdOrChainParameters), { chainId: desiredChainIdHex })],
});
}
throw error;
}));
}

@@ -188,0 +184,0 @@ catch (error) {

@@ -13,3 +13,3 @@ {

},
"version": "8.0.34-beta.0",
"version": "8.0.35-beta.0",
"files": [

@@ -36,3 +36,3 @@ "dist/*"

},
"gitHead": "22a9b2a2d8cc33c386b839bbe3a247cbc0d9285f"
"gitHead": "88a5e0f9335f6acd9a0ed70c50a29bac7a059b29"
}
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