@depay/web3-wallets-evm 15.0.1 → 15.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60127,13 +60127,14 @@ let currentPlainInstance;
60127
60127
  const getPlainInstance = ()=>{
60128
60128
  if(currentPlainInstance) { return currentPlainInstance }
60129
60129
  currentPlainInstance = getWalletConnectInstance(()=>{});
60130
+ return currentPlainInstance
60130
60131
  };
60131
60132
 
60132
60133
  const isConnected = async()=>{
60133
60134
  let connector = getPlainInstance();
60134
- let account;
60135
- try { account = await connector.sendCustomRequest({ method: 'eth_chainId' }); } catch (e) {}
60136
- return !!account
60135
+ let accounts;
60136
+ try { accounts = await connector.sendCustomRequest({ method: 'eth_accounts' }); } catch (error) { console.log(error); }
60137
+ return accounts && accounts.length
60137
60138
  };
60138
60139
 
60139
60140
  const getConnectedInstance$1 = async()=>{
@@ -60179,27 +60180,18 @@ class WalletConnectV1 {
60179
60180
  };
60180
60181
  }
60181
60182
 
60183
+ disconnect() {
60184
+ setConnectedInstance$1(undefined);
60185
+ localStorage[KEY+'_name'] = undefined;
60186
+ localStorage[KEY+'_logo'] = undefined;
60187
+ currentPlainInstance = undefined;
60188
+ }
60189
+
60182
60190
  newWalletConnectInstance(connect) {
60183
60191
  let instance = getWalletConnectInstance(connect);
60184
60192
 
60185
- instance.on("connect", (error, payload) => {
60186
- if (error) { throw error }
60187
- const { accounts, chainId } = payload.params[0];
60188
- this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
60189
- this.connectedChainId = chainId;
60190
- });
60191
-
60192
- instance.on("session_update", (error, payload) => {
60193
- if (error) { throw error }
60194
- const { accounts, chainId } = payload.params[0];
60195
- this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
60196
- this.connectedChainId = chainId;
60197
- });
60198
-
60199
60193
  instance.on("disconnect", (error, payload) => {
60200
- setConnectedInstance$1(undefined);
60201
- localStorage[KEY+'_name'] = undefined;
60202
- localStorage[KEY+'_logo'] = undefined;
60194
+ this.disconnect();
60203
60195
  if (error) { throw error }
60204
60196
  });
60205
60197
 
@@ -60227,12 +60219,15 @@ class WalletConnectV1 {
60227
60219
  this.connector = this.newWalletConnectInstance(connect);
60228
60220
  }
60229
60221
 
60230
- if(this.connector.connected) {
60231
-
60232
- let account = await this.account();
60233
- this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
60222
+ if(options && options.reconnect) {
60223
+ if(this.connector) {
60224
+ await this.connector.killSession();
60225
+ this.disconnect();
60226
+ }
60227
+ }
60234
60228
 
60235
- return account
60229
+ if((await isConnected())) {
60230
+ return await this.account()
60236
60231
  } else {
60237
60232
 
60238
60233
  let { accounts, chainId } = await this.connector.connect();
@@ -60243,7 +60238,6 @@ class WalletConnectV1 {
60243
60238
  if(accounts instanceof Array && accounts.length) {
60244
60239
  setConnectedInstance$1(this);
60245
60240
  accounts = accounts.map((account)=>ethers.utils.getAddress(account));
60246
- this.connectedChainId = chainId;
60247
60241
 
60248
60242
  return accounts[0]
60249
60243
  } else {
package/dist/esm/index.js CHANGED
@@ -1221,13 +1221,14 @@ let currentPlainInstance;
1221
1221
  const getPlainInstance = ()=>{
1222
1222
  if(currentPlainInstance) { return currentPlainInstance }
1223
1223
  currentPlainInstance = getWalletConnectInstance(()=>{});
1224
+ return currentPlainInstance
1224
1225
  };
1225
1226
 
1226
1227
  const isConnected = async()=>{
1227
1228
  let connector = getPlainInstance();
1228
- let account;
1229
- try { account = await connector.sendCustomRequest({ method: 'eth_chainId' }); } catch (e) {}
1230
- return !!account
1229
+ let accounts;
1230
+ try { accounts = await connector.sendCustomRequest({ method: 'eth_accounts' }); } catch (error) { console.log(error); }
1231
+ return accounts && accounts.length
1231
1232
  };
1232
1233
 
1233
1234
  const getConnectedInstance$1 = async()=>{
@@ -1273,27 +1274,18 @@ class WalletConnectV1 {
1273
1274
  };
1274
1275
  }
1275
1276
 
1277
+ disconnect() {
1278
+ setConnectedInstance$1(undefined);
1279
+ localStorage[KEY+'_name'] = undefined;
1280
+ localStorage[KEY+'_logo'] = undefined;
1281
+ currentPlainInstance = undefined;
1282
+ }
1283
+
1276
1284
  newWalletConnectInstance(connect) {
1277
1285
  let instance = getWalletConnectInstance(connect);
1278
1286
 
1279
- instance.on("connect", (error, payload) => {
1280
- if (error) { throw error }
1281
- const { accounts, chainId } = payload.params[0];
1282
- this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
1283
- this.connectedChainId = chainId;
1284
- });
1285
-
1286
- instance.on("session_update", (error, payload) => {
1287
- if (error) { throw error }
1288
- const { accounts, chainId } = payload.params[0];
1289
- this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
1290
- this.connectedChainId = chainId;
1291
- });
1292
-
1293
1287
  instance.on("disconnect", (error, payload) => {
1294
- setConnectedInstance$1(undefined);
1295
- localStorage[KEY+'_name'] = undefined;
1296
- localStorage[KEY+'_logo'] = undefined;
1288
+ this.disconnect();
1297
1289
  if (error) { throw error }
1298
1290
  });
1299
1291
 
@@ -1321,12 +1313,15 @@ class WalletConnectV1 {
1321
1313
  this.connector = this.newWalletConnectInstance(connect);
1322
1314
  }
1323
1315
 
1324
- if(this.connector.connected) {
1325
-
1326
- let account = await this.account();
1327
- this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
1316
+ if(options && options.reconnect) {
1317
+ if(this.connector) {
1318
+ await this.connector.killSession();
1319
+ this.disconnect();
1320
+ }
1321
+ }
1328
1322
 
1329
- return account
1323
+ if((await isConnected())) {
1324
+ return await this.account()
1330
1325
  } else {
1331
1326
 
1332
1327
  let { accounts, chainId } = await this.connector.connect();
@@ -1337,7 +1332,6 @@ class WalletConnectV1 {
1337
1332
  if(accounts instanceof Array && accounts.length) {
1338
1333
  setConnectedInstance$1(this);
1339
1334
  accounts = accounts.map((account)=>ethers.utils.getAddress(account));
1340
- this.connectedChainId = chainId;
1341
1335
 
1342
1336
  return accounts[0]
1343
1337
  } else {
@@ -60126,13 +60126,14 @@
60126
60126
  const getPlainInstance = ()=>{
60127
60127
  if(currentPlainInstance) { return currentPlainInstance }
60128
60128
  currentPlainInstance = getWalletConnectInstance(()=>{});
60129
+ return currentPlainInstance
60129
60130
  };
60130
60131
 
60131
60132
  const isConnected = async()=>{
60132
60133
  let connector = getPlainInstance();
60133
- let account;
60134
- try { account = await connector.sendCustomRequest({ method: 'eth_chainId' }); } catch (e) {}
60135
- return !!account
60134
+ let accounts;
60135
+ try { accounts = await connector.sendCustomRequest({ method: 'eth_accounts' }); } catch (error) { console.log(error); }
60136
+ return accounts && accounts.length
60136
60137
  };
60137
60138
 
60138
60139
  const getConnectedInstance$1 = async()=>{
@@ -60178,27 +60179,18 @@
60178
60179
  };
60179
60180
  }
60180
60181
 
60182
+ disconnect() {
60183
+ setConnectedInstance$1(undefined);
60184
+ localStorage[KEY+'_name'] = undefined;
60185
+ localStorage[KEY+'_logo'] = undefined;
60186
+ currentPlainInstance = undefined;
60187
+ }
60188
+
60181
60189
  newWalletConnectInstance(connect) {
60182
60190
  let instance = getWalletConnectInstance(connect);
60183
60191
 
60184
- instance.on("connect", (error, payload) => {
60185
- if (error) { throw error }
60186
- const { accounts, chainId } = payload.params[0];
60187
- this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
60188
- this.connectedChainId = chainId;
60189
- });
60190
-
60191
- instance.on("session_update", (error, payload) => {
60192
- if (error) { throw error }
60193
- const { accounts, chainId } = payload.params[0];
60194
- this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
60195
- this.connectedChainId = chainId;
60196
- });
60197
-
60198
60192
  instance.on("disconnect", (error, payload) => {
60199
- setConnectedInstance$1(undefined);
60200
- localStorage[KEY+'_name'] = undefined;
60201
- localStorage[KEY+'_logo'] = undefined;
60193
+ this.disconnect();
60202
60194
  if (error) { throw error }
60203
60195
  });
60204
60196
 
@@ -60226,12 +60218,15 @@
60226
60218
  this.connector = this.newWalletConnectInstance(connect);
60227
60219
  }
60228
60220
 
60229
- if(this.connector.connected) {
60230
-
60231
- let account = await this.account();
60232
- this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
60221
+ if(options && options.reconnect) {
60222
+ if(this.connector) {
60223
+ await this.connector.killSession();
60224
+ this.disconnect();
60225
+ }
60226
+ }
60233
60227
 
60234
- return account
60228
+ if((await isConnected())) {
60229
+ return await this.account()
60235
60230
  } else {
60236
60231
 
60237
60232
  let { accounts, chainId } = await this.connector.connect();
@@ -60242,7 +60237,6 @@
60242
60237
  if(accounts instanceof Array && accounts.length) {
60243
60238
  setConnectedInstance$1(this);
60244
60239
  accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
60245
- this.connectedChainId = chainId;
60246
60240
 
60247
60241
  return accounts[0]
60248
60242
  } else {
package/dist/umd/index.js CHANGED
@@ -1219,13 +1219,14 @@
1219
1219
  const getPlainInstance = ()=>{
1220
1220
  if(currentPlainInstance) { return currentPlainInstance }
1221
1221
  currentPlainInstance = getWalletConnectInstance(()=>{});
1222
+ return currentPlainInstance
1222
1223
  };
1223
1224
 
1224
1225
  const isConnected = async()=>{
1225
1226
  let connector = getPlainInstance();
1226
- let account;
1227
- try { account = await connector.sendCustomRequest({ method: 'eth_chainId' }); } catch (e) {}
1228
- return !!account
1227
+ let accounts;
1228
+ try { accounts = await connector.sendCustomRequest({ method: 'eth_accounts' }); } catch (error) { console.log(error); }
1229
+ return accounts && accounts.length
1229
1230
  };
1230
1231
 
1231
1232
  const getConnectedInstance$1 = async()=>{
@@ -1271,27 +1272,18 @@
1271
1272
  };
1272
1273
  }
1273
1274
 
1275
+ disconnect() {
1276
+ setConnectedInstance$1(undefined);
1277
+ localStorage[KEY+'_name'] = undefined;
1278
+ localStorage[KEY+'_logo'] = undefined;
1279
+ currentPlainInstance = undefined;
1280
+ }
1281
+
1274
1282
  newWalletConnectInstance(connect) {
1275
1283
  let instance = getWalletConnectInstance(connect);
1276
1284
 
1277
- instance.on("connect", (error, payload) => {
1278
- if (error) { throw error }
1279
- const { accounts, chainId } = payload.params[0];
1280
- this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1281
- this.connectedChainId = chainId;
1282
- });
1283
-
1284
- instance.on("session_update", (error, payload) => {
1285
- if (error) { throw error }
1286
- const { accounts, chainId } = payload.params[0];
1287
- this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1288
- this.connectedChainId = chainId;
1289
- });
1290
-
1291
1285
  instance.on("disconnect", (error, payload) => {
1292
- setConnectedInstance$1(undefined);
1293
- localStorage[KEY+'_name'] = undefined;
1294
- localStorage[KEY+'_logo'] = undefined;
1286
+ this.disconnect();
1295
1287
  if (error) { throw error }
1296
1288
  });
1297
1289
 
@@ -1319,12 +1311,15 @@
1319
1311
  this.connector = this.newWalletConnectInstance(connect);
1320
1312
  }
1321
1313
 
1322
- if(this.connector.connected) {
1323
-
1324
- let account = await this.account();
1325
- this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
1314
+ if(options && options.reconnect) {
1315
+ if(this.connector) {
1316
+ await this.connector.killSession();
1317
+ this.disconnect();
1318
+ }
1319
+ }
1326
1320
 
1327
- return account
1321
+ if((await isConnected())) {
1322
+ return await this.account()
1328
1323
  } else {
1329
1324
 
1330
1325
  let { accounts, chainId } = await this.connector.connect();
@@ -1335,7 +1330,6 @@
1335
1330
  if(accounts instanceof Array && accounts.length) {
1336
1331
  setConnectedInstance$1(this);
1337
1332
  accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1338
- this.connectedChainId = chainId;
1339
1333
 
1340
1334
  return accounts[0]
1341
1335
  } else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/web3-wallets-evm",
3
3
  "moduleName": "Web3Wallets",
4
- "version": "15.0.1",
4
+ "version": "15.1.0",
5
5
  "description": "One-Stop-Shop JavaScript library to integrate various web3 crypto wallets and multiple blockchains at once with a single interface.",
6
6
  "main": "dist/umd/index.evm.js",
7
7
  "module": "dist/esm/index.evm.js",