@depay/web3-wallets-evm 15.0.2 → 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.
@@ -60180,27 +60180,18 @@ class WalletConnectV1 {
60180
60180
  };
60181
60181
  }
60182
60182
 
60183
+ disconnect() {
60184
+ setConnectedInstance$1(undefined);
60185
+ localStorage[KEY+'_name'] = undefined;
60186
+ localStorage[KEY+'_logo'] = undefined;
60187
+ currentPlainInstance = undefined;
60188
+ }
60189
+
60183
60190
  newWalletConnectInstance(connect) {
60184
60191
  let instance = getWalletConnectInstance(connect);
60185
60192
 
60186
- instance.on("connect", (error, payload) => {
60187
- if (error) { throw error }
60188
- const { accounts, chainId } = payload.params[0];
60189
- this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
60190
- this.connectedChainId = chainId;
60191
- });
60192
-
60193
- instance.on("session_update", (error, payload) => {
60194
- if (error) { throw error }
60195
- const { accounts, chainId } = payload.params[0];
60196
- this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
60197
- this.connectedChainId = chainId;
60198
- });
60199
-
60200
60193
  instance.on("disconnect", (error, payload) => {
60201
- setConnectedInstance$1(undefined);
60202
- localStorage[KEY+'_name'] = undefined;
60203
- localStorage[KEY+'_logo'] = undefined;
60194
+ this.disconnect();
60204
60195
  if (error) { throw error }
60205
60196
  });
60206
60197
 
@@ -60228,12 +60219,15 @@ class WalletConnectV1 {
60228
60219
  this.connector = this.newWalletConnectInstance(connect);
60229
60220
  }
60230
60221
 
60231
- if(this.connector.connected) {
60232
-
60233
- let account = await this.account();
60234
- 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
+ }
60235
60228
 
60236
- return account
60229
+ if((await isConnected())) {
60230
+ return await this.account()
60237
60231
  } else {
60238
60232
 
60239
60233
  let { accounts, chainId } = await this.connector.connect();
@@ -60244,7 +60238,6 @@ class WalletConnectV1 {
60244
60238
  if(accounts instanceof Array && accounts.length) {
60245
60239
  setConnectedInstance$1(this);
60246
60240
  accounts = accounts.map((account)=>ethers.utils.getAddress(account));
60247
- this.connectedChainId = chainId;
60248
60241
 
60249
60242
  return accounts[0]
60250
60243
  } else {
package/dist/esm/index.js CHANGED
@@ -1274,27 +1274,18 @@ class WalletConnectV1 {
1274
1274
  };
1275
1275
  }
1276
1276
 
1277
+ disconnect() {
1278
+ setConnectedInstance$1(undefined);
1279
+ localStorage[KEY+'_name'] = undefined;
1280
+ localStorage[KEY+'_logo'] = undefined;
1281
+ currentPlainInstance = undefined;
1282
+ }
1283
+
1277
1284
  newWalletConnectInstance(connect) {
1278
1285
  let instance = getWalletConnectInstance(connect);
1279
1286
 
1280
- instance.on("connect", (error, payload) => {
1281
- if (error) { throw error }
1282
- const { accounts, chainId } = payload.params[0];
1283
- this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
1284
- this.connectedChainId = chainId;
1285
- });
1286
-
1287
- instance.on("session_update", (error, payload) => {
1288
- if (error) { throw error }
1289
- const { accounts, chainId } = payload.params[0];
1290
- this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
1291
- this.connectedChainId = chainId;
1292
- });
1293
-
1294
1287
  instance.on("disconnect", (error, payload) => {
1295
- setConnectedInstance$1(undefined);
1296
- localStorage[KEY+'_name'] = undefined;
1297
- localStorage[KEY+'_logo'] = undefined;
1288
+ this.disconnect();
1298
1289
  if (error) { throw error }
1299
1290
  });
1300
1291
 
@@ -1322,12 +1313,15 @@ class WalletConnectV1 {
1322
1313
  this.connector = this.newWalletConnectInstance(connect);
1323
1314
  }
1324
1315
 
1325
- if(this.connector.connected) {
1326
-
1327
- let account = await this.account();
1328
- 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
+ }
1329
1322
 
1330
- return account
1323
+ if((await isConnected())) {
1324
+ return await this.account()
1331
1325
  } else {
1332
1326
 
1333
1327
  let { accounts, chainId } = await this.connector.connect();
@@ -1338,7 +1332,6 @@ class WalletConnectV1 {
1338
1332
  if(accounts instanceof Array && accounts.length) {
1339
1333
  setConnectedInstance$1(this);
1340
1334
  accounts = accounts.map((account)=>ethers.utils.getAddress(account));
1341
- this.connectedChainId = chainId;
1342
1335
 
1343
1336
  return accounts[0]
1344
1337
  } else {
@@ -60179,27 +60179,18 @@
60179
60179
  };
60180
60180
  }
60181
60181
 
60182
+ disconnect() {
60183
+ setConnectedInstance$1(undefined);
60184
+ localStorage[KEY+'_name'] = undefined;
60185
+ localStorage[KEY+'_logo'] = undefined;
60186
+ currentPlainInstance = undefined;
60187
+ }
60188
+
60182
60189
  newWalletConnectInstance(connect) {
60183
60190
  let instance = getWalletConnectInstance(connect);
60184
60191
 
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.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.ethers.utils.getAddress(account));
60196
- this.connectedChainId = chainId;
60197
- });
60198
-
60199
60192
  instance.on("disconnect", (error, payload) => {
60200
- setConnectedInstance$1(undefined);
60201
- localStorage[KEY+'_name'] = undefined;
60202
- localStorage[KEY+'_logo'] = undefined;
60193
+ this.disconnect();
60203
60194
  if (error) { throw error }
60204
60195
  });
60205
60196
 
@@ -60227,12 +60218,15 @@
60227
60218
  this.connector = this.newWalletConnectInstance(connect);
60228
60219
  }
60229
60220
 
60230
- if(this.connector.connected) {
60231
-
60232
- let account = await this.account();
60233
- 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
+ }
60234
60227
 
60235
- return account
60228
+ if((await isConnected())) {
60229
+ return await this.account()
60236
60230
  } else {
60237
60231
 
60238
60232
  let { accounts, chainId } = await this.connector.connect();
@@ -60243,7 +60237,6 @@
60243
60237
  if(accounts instanceof Array && accounts.length) {
60244
60238
  setConnectedInstance$1(this);
60245
60239
  accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
60246
- this.connectedChainId = chainId;
60247
60240
 
60248
60241
  return accounts[0]
60249
60242
  } else {
package/dist/umd/index.js CHANGED
@@ -1272,27 +1272,18 @@
1272
1272
  };
1273
1273
  }
1274
1274
 
1275
+ disconnect() {
1276
+ setConnectedInstance$1(undefined);
1277
+ localStorage[KEY+'_name'] = undefined;
1278
+ localStorage[KEY+'_logo'] = undefined;
1279
+ currentPlainInstance = undefined;
1280
+ }
1281
+
1275
1282
  newWalletConnectInstance(connect) {
1276
1283
  let instance = getWalletConnectInstance(connect);
1277
1284
 
1278
- instance.on("connect", (error, payload) => {
1279
- if (error) { throw error }
1280
- const { accounts, chainId } = payload.params[0];
1281
- this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1282
- this.connectedChainId = chainId;
1283
- });
1284
-
1285
- instance.on("session_update", (error, payload) => {
1286
- if (error) { throw error }
1287
- const { accounts, chainId } = payload.params[0];
1288
- this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1289
- this.connectedChainId = chainId;
1290
- });
1291
-
1292
1285
  instance.on("disconnect", (error, payload) => {
1293
- setConnectedInstance$1(undefined);
1294
- localStorage[KEY+'_name'] = undefined;
1295
- localStorage[KEY+'_logo'] = undefined;
1286
+ this.disconnect();
1296
1287
  if (error) { throw error }
1297
1288
  });
1298
1289
 
@@ -1320,12 +1311,15 @@
1320
1311
  this.connector = this.newWalletConnectInstance(connect);
1321
1312
  }
1322
1313
 
1323
- if(this.connector.connected) {
1324
-
1325
- let account = await this.account();
1326
- 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
+ }
1327
1320
 
1328
- return account
1321
+ if((await isConnected())) {
1322
+ return await this.account()
1329
1323
  } else {
1330
1324
 
1331
1325
  let { accounts, chainId } = await this.connector.connect();
@@ -1336,7 +1330,6 @@
1336
1330
  if(accounts instanceof Array && accounts.length) {
1337
1331
  setConnectedInstance$1(this);
1338
1332
  accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1339
- this.connectedChainId = chainId;
1340
1333
 
1341
1334
  return accounts[0]
1342
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.2",
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",