@depay/web3-wallets-evm 14.7.0 → 14.8.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.
@@ -60131,6 +60131,16 @@ const setConnectedInstance$2 = (value)=>{
60131
60131
  window[KEY$1] = value;
60132
60132
  };
60133
60133
 
60134
+ const getWalletConnectInstance = (connect)=>{
60135
+ return new WalletConnectClient({
60136
+ bridge: "https://walletconnect.depay.com",
60137
+ qrcodeModal: {
60138
+ open: async(uri)=>connect({ uri }),
60139
+ close: ()=>{},
60140
+ }
60141
+ })
60142
+ };
60143
+
60134
60144
  class WalletConnectV1 {
60135
60145
 
60136
60146
  static __initStatic() {this.info = {
@@ -60139,8 +60149,9 @@ class WalletConnectV1 {
60139
60149
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
60140
60150
  };}
60141
60151
 
60142
- static __initStatic2() {this.isAvailable = ()=>{
60143
- return getConnectedInstance$2() != undefined
60152
+ static __initStatic2() {this.isAvailable = ()=>{
60153
+ let connector = getWalletConnectInstance(()=>{});
60154
+ return getConnectedInstance$2() != undefined || connector.connected
60144
60155
  };}
60145
60156
 
60146
60157
  constructor() {
@@ -60156,13 +60167,7 @@ class WalletConnectV1 {
60156
60167
  }
60157
60168
 
60158
60169
  newWalletConnectInstance(connect) {
60159
- let instance = new WalletConnectClient({
60160
- bridge: "https://walletconnect.depay.com",
60161
- qrcodeModal: {
60162
- open: async(uri)=>connect({ uri }),
60163
- close: ()=>{},
60164
- }
60165
- });
60170
+ let instance = getWalletConnectInstance(connect);
60166
60171
 
60167
60172
  instance.on("connect", (error, payload) => {
60168
60173
  if (error) { throw error }
@@ -60192,8 +60197,9 @@ class WalletConnectV1 {
60192
60197
  }
60193
60198
 
60194
60199
  async account() {
60195
- if(this.connectedAccounts == undefined) { return }
60196
- return this.connectedAccounts[0]
60200
+ if(!this.connector){ return }
60201
+ let accounts = await this.connector.sendCustomRequest({ method: 'eth_accounts' });
60202
+ if(accounts && accounts.length) { return ethers.utils.getAddress(accounts[0]) }
60197
60203
  }
60198
60204
 
60199
60205
  async connect(options) {
@@ -60201,7 +60207,6 @@ class WalletConnectV1 {
60201
60207
  if(_optionalChain$4([options, 'optionalAccess', _ => _.name])) { this.name = options.name; }
60202
60208
  if(_optionalChain$4([options, 'optionalAccess', _2 => _2.logo])) { this.logo = options.logo; }
60203
60209
  try {
60204
- window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
60205
60210
 
60206
60211
  this.connector = WalletConnectV1.instance;
60207
60212
 
@@ -60210,23 +60215,26 @@ class WalletConnectV1 {
60210
60215
  }
60211
60216
 
60212
60217
  if(this.connector.connected) {
60213
- await this.connector.killSession();
60214
- setConnectedInstance$2(undefined);
60215
- this.connector = this.newWalletConnectInstance(connect);
60216
- }
60217
-
60218
- let { accounts, chainId } = await this.connector.connect();
60219
60218
 
60220
- if(accounts instanceof Array && accounts.length) {
60221
- setConnectedInstance$2(this);
60222
- accounts = accounts.map((account)=>ethers.utils.getAddress(account));
60223
- this.connectedAccounts = accounts;
60224
- this.connectedChainId = chainId;
60219
+ let account = await this.account();
60220
+ this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
60225
60221
 
60226
- return accounts[0]
60222
+ return account
60227
60223
  } else {
60228
- return
60224
+
60225
+ let { accounts, chainId } = await this.connector.connect();
60226
+
60227
+ if(accounts instanceof Array && accounts.length) {
60228
+ setConnectedInstance$2(this);
60229
+ accounts = accounts.map((account)=>ethers.utils.getAddress(account));
60230
+ this.connectedChainId = chainId;
60231
+
60232
+ return accounts[0]
60233
+ } else {
60234
+ return
60235
+ }
60229
60236
  }
60237
+
60230
60238
  } catch (error) {
60231
60239
  console.log('WALLETCONNECT ERROR', error);
60232
60240
  return undefined
package/dist/esm/index.js CHANGED
@@ -1225,6 +1225,16 @@ const setConnectedInstance$2 = (value)=>{
1225
1225
  window[KEY$1] = value;
1226
1226
  };
1227
1227
 
1228
+ const getWalletConnectInstance = (connect)=>{
1229
+ return new WalletConnectClient({
1230
+ bridge: "https://walletconnect.depay.com",
1231
+ qrcodeModal: {
1232
+ open: async(uri)=>connect({ uri }),
1233
+ close: ()=>{},
1234
+ }
1235
+ })
1236
+ };
1237
+
1228
1238
  class WalletConnectV1 {
1229
1239
 
1230
1240
  static __initStatic() {this.info = {
@@ -1233,8 +1243,9 @@ class WalletConnectV1 {
1233
1243
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
1234
1244
  };}
1235
1245
 
1236
- static __initStatic2() {this.isAvailable = ()=>{
1237
- return getConnectedInstance$2() != undefined
1246
+ static __initStatic2() {this.isAvailable = ()=>{
1247
+ let connector = getWalletConnectInstance(()=>{});
1248
+ return getConnectedInstance$2() != undefined || connector.connected
1238
1249
  };}
1239
1250
 
1240
1251
  constructor() {
@@ -1250,13 +1261,7 @@ class WalletConnectV1 {
1250
1261
  }
1251
1262
 
1252
1263
  newWalletConnectInstance(connect) {
1253
- let instance = new WalletConnectClient({
1254
- bridge: "https://walletconnect.depay.com",
1255
- qrcodeModal: {
1256
- open: async(uri)=>connect({ uri }),
1257
- close: ()=>{},
1258
- }
1259
- });
1264
+ let instance = getWalletConnectInstance(connect);
1260
1265
 
1261
1266
  instance.on("connect", (error, payload) => {
1262
1267
  if (error) { throw error }
@@ -1286,8 +1291,9 @@ class WalletConnectV1 {
1286
1291
  }
1287
1292
 
1288
1293
  async account() {
1289
- if(this.connectedAccounts == undefined) { return }
1290
- return this.connectedAccounts[0]
1294
+ if(!this.connector){ return }
1295
+ let accounts = await this.connector.sendCustomRequest({ method: 'eth_accounts' });
1296
+ if(accounts && accounts.length) { return ethers.utils.getAddress(accounts[0]) }
1291
1297
  }
1292
1298
 
1293
1299
  async connect(options) {
@@ -1295,7 +1301,6 @@ class WalletConnectV1 {
1295
1301
  if(_optionalChain$2([options, 'optionalAccess', _ => _.name])) { this.name = options.name; }
1296
1302
  if(_optionalChain$2([options, 'optionalAccess', _2 => _2.logo])) { this.logo = options.logo; }
1297
1303
  try {
1298
- window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
1299
1304
 
1300
1305
  this.connector = WalletConnectV1.instance;
1301
1306
 
@@ -1304,23 +1309,26 @@ class WalletConnectV1 {
1304
1309
  }
1305
1310
 
1306
1311
  if(this.connector.connected) {
1307
- await this.connector.killSession();
1308
- setConnectedInstance$2(undefined);
1309
- this.connector = this.newWalletConnectInstance(connect);
1310
- }
1311
-
1312
- let { accounts, chainId } = await this.connector.connect();
1313
1312
 
1314
- if(accounts instanceof Array && accounts.length) {
1315
- setConnectedInstance$2(this);
1316
- accounts = accounts.map((account)=>ethers.utils.getAddress(account));
1317
- this.connectedAccounts = accounts;
1318
- this.connectedChainId = chainId;
1313
+ let account = await this.account();
1314
+ this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
1319
1315
 
1320
- return accounts[0]
1316
+ return account
1321
1317
  } else {
1322
- return
1318
+
1319
+ let { accounts, chainId } = await this.connector.connect();
1320
+
1321
+ if(accounts instanceof Array && accounts.length) {
1322
+ setConnectedInstance$2(this);
1323
+ accounts = accounts.map((account)=>ethers.utils.getAddress(account));
1324
+ this.connectedChainId = chainId;
1325
+
1326
+ return accounts[0]
1327
+ } else {
1328
+ return
1329
+ }
1323
1330
  }
1331
+
1324
1332
  } catch (error) {
1325
1333
  console.log('WALLETCONNECT ERROR', error);
1326
1334
  return undefined
@@ -60129,6 +60129,16 @@
60129
60129
  window[KEY$1] = value;
60130
60130
  };
60131
60131
 
60132
+ const getWalletConnectInstance = (connect)=>{
60133
+ return new walletconnectV1.WalletConnectClient({
60134
+ bridge: "https://walletconnect.depay.com",
60135
+ qrcodeModal: {
60136
+ open: async(uri)=>connect({ uri }),
60137
+ close: ()=>{},
60138
+ }
60139
+ })
60140
+ };
60141
+
60132
60142
  class WalletConnectV1 {
60133
60143
 
60134
60144
  static __initStatic() {this.info = {
@@ -60137,8 +60147,9 @@
60137
60147
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
60138
60148
  };}
60139
60149
 
60140
- static __initStatic2() {this.isAvailable = ()=>{
60141
- return getConnectedInstance$2() != undefined
60150
+ static __initStatic2() {this.isAvailable = ()=>{
60151
+ let connector = getWalletConnectInstance(()=>{});
60152
+ return getConnectedInstance$2() != undefined || connector.connected
60142
60153
  };}
60143
60154
 
60144
60155
  constructor() {
@@ -60154,13 +60165,7 @@
60154
60165
  }
60155
60166
 
60156
60167
  newWalletConnectInstance(connect) {
60157
- let instance = new walletconnectV1.WalletConnectClient({
60158
- bridge: "https://walletconnect.depay.com",
60159
- qrcodeModal: {
60160
- open: async(uri)=>connect({ uri }),
60161
- close: ()=>{},
60162
- }
60163
- });
60168
+ let instance = getWalletConnectInstance(connect);
60164
60169
 
60165
60170
  instance.on("connect", (error, payload) => {
60166
60171
  if (error) { throw error }
@@ -60190,8 +60195,9 @@
60190
60195
  }
60191
60196
 
60192
60197
  async account() {
60193
- if(this.connectedAccounts == undefined) { return }
60194
- return this.connectedAccounts[0]
60198
+ if(!this.connector){ return }
60199
+ let accounts = await this.connector.sendCustomRequest({ method: 'eth_accounts' });
60200
+ if(accounts && accounts.length) { return ethers.ethers.utils.getAddress(accounts[0]) }
60195
60201
  }
60196
60202
 
60197
60203
  async connect(options) {
@@ -60199,7 +60205,6 @@
60199
60205
  if(_optionalChain$4([options, 'optionalAccess', _ => _.name])) { this.name = options.name; }
60200
60206
  if(_optionalChain$4([options, 'optionalAccess', _2 => _2.logo])) { this.logo = options.logo; }
60201
60207
  try {
60202
- window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
60203
60208
 
60204
60209
  this.connector = WalletConnectV1.instance;
60205
60210
 
@@ -60208,23 +60213,26 @@
60208
60213
  }
60209
60214
 
60210
60215
  if(this.connector.connected) {
60211
- await this.connector.killSession();
60212
- setConnectedInstance$2(undefined);
60213
- this.connector = this.newWalletConnectInstance(connect);
60214
- }
60215
-
60216
- let { accounts, chainId } = await this.connector.connect();
60217
60216
 
60218
- if(accounts instanceof Array && accounts.length) {
60219
- setConnectedInstance$2(this);
60220
- accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
60221
- this.connectedAccounts = accounts;
60222
- this.connectedChainId = chainId;
60217
+ let account = await this.account();
60218
+ this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
60223
60219
 
60224
- return accounts[0]
60220
+ return account
60225
60221
  } else {
60226
- return
60222
+
60223
+ let { accounts, chainId } = await this.connector.connect();
60224
+
60225
+ if(accounts instanceof Array && accounts.length) {
60226
+ setConnectedInstance$2(this);
60227
+ accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
60228
+ this.connectedChainId = chainId;
60229
+
60230
+ return accounts[0]
60231
+ } else {
60232
+ return
60233
+ }
60227
60234
  }
60235
+
60228
60236
  } catch (error) {
60229
60237
  console.log('WALLETCONNECT ERROR', error);
60230
60238
  return undefined
package/dist/umd/index.js CHANGED
@@ -1222,6 +1222,16 @@
1222
1222
  window[KEY$1] = value;
1223
1223
  };
1224
1224
 
1225
+ const getWalletConnectInstance = (connect)=>{
1226
+ return new walletconnectV1.WalletConnectClient({
1227
+ bridge: "https://walletconnect.depay.com",
1228
+ qrcodeModal: {
1229
+ open: async(uri)=>connect({ uri }),
1230
+ close: ()=>{},
1231
+ }
1232
+ })
1233
+ };
1234
+
1225
1235
  class WalletConnectV1 {
1226
1236
 
1227
1237
  static __initStatic() {this.info = {
@@ -1230,8 +1240,9 @@
1230
1240
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
1231
1241
  };}
1232
1242
 
1233
- static __initStatic2() {this.isAvailable = ()=>{
1234
- return getConnectedInstance$2() != undefined
1243
+ static __initStatic2() {this.isAvailable = ()=>{
1244
+ let connector = getWalletConnectInstance(()=>{});
1245
+ return getConnectedInstance$2() != undefined || connector.connected
1235
1246
  };}
1236
1247
 
1237
1248
  constructor() {
@@ -1247,13 +1258,7 @@
1247
1258
  }
1248
1259
 
1249
1260
  newWalletConnectInstance(connect) {
1250
- let instance = new walletconnectV1.WalletConnectClient({
1251
- bridge: "https://walletconnect.depay.com",
1252
- qrcodeModal: {
1253
- open: async(uri)=>connect({ uri }),
1254
- close: ()=>{},
1255
- }
1256
- });
1261
+ let instance = getWalletConnectInstance(connect);
1257
1262
 
1258
1263
  instance.on("connect", (error, payload) => {
1259
1264
  if (error) { throw error }
@@ -1283,8 +1288,9 @@
1283
1288
  }
1284
1289
 
1285
1290
  async account() {
1286
- if(this.connectedAccounts == undefined) { return }
1287
- return this.connectedAccounts[0]
1291
+ if(!this.connector){ return }
1292
+ let accounts = await this.connector.sendCustomRequest({ method: 'eth_accounts' });
1293
+ if(accounts && accounts.length) { return ethers.ethers.utils.getAddress(accounts[0]) }
1288
1294
  }
1289
1295
 
1290
1296
  async connect(options) {
@@ -1292,7 +1298,6 @@
1292
1298
  if(_optionalChain$2([options, 'optionalAccess', _ => _.name])) { this.name = options.name; }
1293
1299
  if(_optionalChain$2([options, 'optionalAccess', _2 => _2.logo])) { this.logo = options.logo; }
1294
1300
  try {
1295
- window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
1296
1301
 
1297
1302
  this.connector = WalletConnectV1.instance;
1298
1303
 
@@ -1301,23 +1306,26 @@
1301
1306
  }
1302
1307
 
1303
1308
  if(this.connector.connected) {
1304
- await this.connector.killSession();
1305
- setConnectedInstance$2(undefined);
1306
- this.connector = this.newWalletConnectInstance(connect);
1307
- }
1308
-
1309
- let { accounts, chainId } = await this.connector.connect();
1310
1309
 
1311
- if(accounts instanceof Array && accounts.length) {
1312
- setConnectedInstance$2(this);
1313
- accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1314
- this.connectedAccounts = accounts;
1315
- this.connectedChainId = chainId;
1310
+ let account = await this.account();
1311
+ this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
1316
1312
 
1317
- return accounts[0]
1313
+ return account
1318
1314
  } else {
1319
- return
1315
+
1316
+ let { accounts, chainId } = await this.connector.connect();
1317
+
1318
+ if(accounts instanceof Array && accounts.length) {
1319
+ setConnectedInstance$2(this);
1320
+ accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1321
+ this.connectedChainId = chainId;
1322
+
1323
+ return accounts[0]
1324
+ } else {
1325
+ return
1326
+ }
1320
1327
  }
1328
+
1321
1329
  } catch (error) {
1322
1330
  console.log('WALLETCONNECT ERROR', error);
1323
1331
  return undefined
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/web3-wallets-evm",
3
3
  "moduleName": "Web3Wallets",
4
- "version": "14.7.0",
4
+ "version": "14.8.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",