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
1
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.32-beta.0 to 8.0.33-beta.0

21

dist/index.d.ts

@@ -7,2 +7,11 @@ import type { CoinbaseWalletProvider, CoinbaseWalletSDK } from '@coinbase/wallet-sdk';

};
/**
* @param options - Options to pass to `@coinbase/wallet-sdk`.
* @param onError - Handler to report errors thrown from eventListeners.
*/
export interface CoinbaseWalletConstructorArgs {
actions: Actions;
options: CoinbaseWalletSDKOptions;
onError?: (error: Error) => void;
}
export declare class CoinbaseWallet extends Connector {

@@ -17,13 +26,3 @@ /** {@inheritdoc Connector.provider} */

coinbaseWallet: CoinbaseWalletSDK | undefined;
/**
* @param options - Options to pass to `@coinbase/wallet-sdk`.
* @param connectEagerly - A flag indicating whether connection should be initiated when the class is constructed.
* @param onError - Handler to report errors thrown from eventListeners.
*/
constructor({ actions, options, connectEagerly, onError, }: {
actions: Actions;
options: CoinbaseWalletSDKOptions;
connectEagerly?: boolean;
onError?: (error: Error) => void;
});
constructor({ actions, options, onError }: CoinbaseWalletConstructorArgs);
private get connected();

@@ -30,0 +29,0 @@ private isomorphicInitialize;

@@ -52,15 +52,5 @@ "use strict";

class CoinbaseWallet extends types_1.Connector {
/**
* @param options - Options to pass to `@coinbase/wallet-sdk`.
* @param connectEagerly - A flag indicating whether connection should be initiated when the class is constructed.
* @param onError - Handler to report errors thrown from eventListeners.
*/
constructor({ actions, options, connectEagerly = false, onError, }) {
constructor({ actions, options, onError }) {
super(actions, onError);
if (connectEagerly && this.serverSide) {
throw new Error('connectEagerly = true is invalid for SSR, instead use the connectEagerly method in a useEffect');
}
this.options = options;
if (connectEagerly)
void this.connectEagerly();
}

@@ -75,3 +65,3 @@ // the `connected` property, is bugged, but this works as a hack to check connection status

if (this.eagerConnection)
return this.eagerConnection;
return;
yield (this.eagerConnection = Promise.resolve().then(() => __importStar(require('@coinbase/wallet-sdk'))).then((m) => {

@@ -86,4 +76,4 @@ const _a = this.options, { url } = _a, options = __rest(_a, ["url"]);

var _a;
this.actions.resetState();
(_a = this.onError) === null || _a === void 0 ? void 0 : _a.call(this, error);
this.actions.resetState();
});

@@ -103,4 +93,6 @@ this.provider.on('chainChanged', (chainId) => {

const cancelActivation = this.actions.startActivation();
yield this.isomorphicInitialize();
if (this.connected) {
try {
yield this.isomorphicInitialize();
if (!this.connected)
throw new Error('No existing connection');
return Promise.all([

@@ -111,18 +103,11 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion

this.provider.request({ method: 'eth_accounts' }),
])
.then(([chainId, accounts]) => {
if (accounts.length) {
this.actions.update({ chainId: parseChainId(chainId), accounts });
}
else {
]).then(([chainId, accounts]) => {
if (!accounts.length)
throw new Error('No accounts returned');
}
})
.catch((error) => {
console.debug('Could not connect eagerly', error);
cancelActivation();
this.actions.update({ chainId: parseChainId(chainId), accounts });
});
}
else {
catch (error) {
cancelActivation();
throw error;
}

@@ -154,4 +139,3 @@ });

params: [{ chainId: desiredChainIdHex }],
})
.catch((error) => __awaiter(this, void 0, void 0, function* () {
}).catch((error) => __awaiter(this, void 0, void 0, function* () {
if (error.code === 4902 && typeof desiredChainIdOrChainParameters !== 'number') {

@@ -165,46 +149,40 @@ // if we're here, we can try to add a new network

}
else {
throw error;
}
}))
.catch((error) => {
this.actions.resetState();
throw error;
});
}));
}
this.actions.startActivation();
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 })],
});
}
else {
const cancelActivation = this.actions.startActivation();
try {
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;
}
})).catch((error) => {
this.actions.resetState();
throw error;
}));
});
});
}
catch (error) {
cancelActivation();
throw error;
}
});

@@ -211,0 +189,0 @@ }

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

},
"version": "8.0.32-beta.0",
"version": "8.0.33-beta.0",
"files": [

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

"dependencies": {
"@web3-react/types": "^8.0.18-beta.0"
"@web3-react/types": "^8.0.19-beta.0"
},

@@ -35,5 +35,5 @@ "peerDependencies": {

"devDependencies": {
"@web3-react/store": "^8.0.23-beta.0"
"@web3-react/store": "^8.0.24-beta.0"
},
"gitHead": "b497295f7f4aeecf86845551e8fd0ee53d27d202"
"gitHead": "9a5d6207c54457de7081755d5d69e5bd7c9fda31"
}
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