@depay/web3-wallets-evm 14.7.0 → 14.9.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,16 +60197,17 @@ 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) {
60200
60206
  let connect = (options && options.connect) ? options.connect : ({uri})=>{};
60201
- if(_optionalChain$4([options, 'optionalAccess', _ => _.name])) { this.name = options.name; }
60202
- if(_optionalChain$4([options, 'optionalAccess', _2 => _2.logo])) { this.logo = options.logo; }
60207
+ localStorage[KEY$1] = {};
60208
+ if(_optionalChain$4([options, 'optionalAccess', _ => _.name])) { localStorage[KEY$1].name = this.name = options.name; }
60209
+ if(_optionalChain$4([options, 'optionalAccess', _2 => _2.logo])) { localStorage[KEY$1].logo = this.logo = options.logo; }
60203
60210
  try {
60204
- window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
60205
60211
 
60206
60212
  this.connector = WalletConnectV1.instance;
60207
60213
 
@@ -60210,23 +60216,30 @@ class WalletConnectV1 {
60210
60216
  }
60211
60217
 
60212
60218
  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
+ if(localStorage[KEY$1]) {
60220
+ if(localStorage[KEY$1].name) { this.name = localStorage[KEY$1].name; }
60221
+ if(localStorage[KEY$1].logo) { this.logo = localStorage[KEY$1].logo; }
60222
+ }
60219
60223
 
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;
60224
+ let account = await this.account();
60225
+ this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
60225
60226
 
60226
- return accounts[0]
60227
+ return account
60227
60228
  } else {
60228
- return
60229
+
60230
+ let { accounts, chainId } = await this.connector.connect();
60231
+
60232
+ if(accounts instanceof Array && accounts.length) {
60233
+ setConnectedInstance$2(this);
60234
+ accounts = accounts.map((account)=>ethers.utils.getAddress(account));
60235
+ this.connectedChainId = chainId;
60236
+
60237
+ return accounts[0]
60238
+ } else {
60239
+ return
60240
+ }
60229
60241
  }
60242
+
60230
60243
  } catch (error) {
60231
60244
  console.log('WALLETCONNECT ERROR', error);
60232
60245
  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,16 +1291,17 @@ 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) {
1294
1300
  let connect = (options && options.connect) ? options.connect : ({uri})=>{};
1295
- if(_optionalChain$2([options, 'optionalAccess', _ => _.name])) { this.name = options.name; }
1296
- if(_optionalChain$2([options, 'optionalAccess', _2 => _2.logo])) { this.logo = options.logo; }
1301
+ localStorage[KEY$1] = {};
1302
+ if(_optionalChain$2([options, 'optionalAccess', _ => _.name])) { localStorage[KEY$1].name = this.name = options.name; }
1303
+ if(_optionalChain$2([options, 'optionalAccess', _2 => _2.logo])) { localStorage[KEY$1].logo = this.logo = options.logo; }
1297
1304
  try {
1298
- window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
1299
1305
 
1300
1306
  this.connector = WalletConnectV1.instance;
1301
1307
 
@@ -1304,23 +1310,30 @@ class WalletConnectV1 {
1304
1310
  }
1305
1311
 
1306
1312
  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
+ if(localStorage[KEY$1]) {
1314
+ if(localStorage[KEY$1].name) { this.name = localStorage[KEY$1].name; }
1315
+ if(localStorage[KEY$1].logo) { this.logo = localStorage[KEY$1].logo; }
1316
+ }
1313
1317
 
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;
1318
+ let account = await this.account();
1319
+ this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
1319
1320
 
1320
- return accounts[0]
1321
+ return account
1321
1322
  } else {
1322
- return
1323
+
1324
+ let { accounts, chainId } = await this.connector.connect();
1325
+
1326
+ if(accounts instanceof Array && accounts.length) {
1327
+ setConnectedInstance$2(this);
1328
+ accounts = accounts.map((account)=>ethers.utils.getAddress(account));
1329
+ this.connectedChainId = chainId;
1330
+
1331
+ return accounts[0]
1332
+ } else {
1333
+ return
1334
+ }
1323
1335
  }
1336
+
1324
1337
  } catch (error) {
1325
1338
  console.log('WALLETCONNECT ERROR', error);
1326
1339
  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,16 +60195,17 @@
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) {
60198
60204
  let connect = (options && options.connect) ? options.connect : ({uri})=>{};
60199
- if(_optionalChain$4([options, 'optionalAccess', _ => _.name])) { this.name = options.name; }
60200
- if(_optionalChain$4([options, 'optionalAccess', _2 => _2.logo])) { this.logo = options.logo; }
60205
+ localStorage[KEY$1] = {};
60206
+ if(_optionalChain$4([options, 'optionalAccess', _ => _.name])) { localStorage[KEY$1].name = this.name = options.name; }
60207
+ if(_optionalChain$4([options, 'optionalAccess', _2 => _2.logo])) { localStorage[KEY$1].logo = this.logo = options.logo; }
60201
60208
  try {
60202
- window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
60203
60209
 
60204
60210
  this.connector = WalletConnectV1.instance;
60205
60211
 
@@ -60208,23 +60214,30 @@
60208
60214
  }
60209
60215
 
60210
60216
  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
+ if(localStorage[KEY$1]) {
60218
+ if(localStorage[KEY$1].name) { this.name = localStorage[KEY$1].name; }
60219
+ if(localStorage[KEY$1].logo) { this.logo = localStorage[KEY$1].logo; }
60220
+ }
60217
60221
 
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;
60222
+ let account = await this.account();
60223
+ this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
60223
60224
 
60224
- return accounts[0]
60225
+ return account
60225
60226
  } else {
60226
- return
60227
+
60228
+ let { accounts, chainId } = await this.connector.connect();
60229
+
60230
+ if(accounts instanceof Array && accounts.length) {
60231
+ setConnectedInstance$2(this);
60232
+ accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
60233
+ this.connectedChainId = chainId;
60234
+
60235
+ return accounts[0]
60236
+ } else {
60237
+ return
60238
+ }
60227
60239
  }
60240
+
60228
60241
  } catch (error) {
60229
60242
  console.log('WALLETCONNECT ERROR', error);
60230
60243
  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,16 +1288,17 @@
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) {
1291
1297
  let connect = (options && options.connect) ? options.connect : ({uri})=>{};
1292
- if(_optionalChain$2([options, 'optionalAccess', _ => _.name])) { this.name = options.name; }
1293
- if(_optionalChain$2([options, 'optionalAccess', _2 => _2.logo])) { this.logo = options.logo; }
1298
+ localStorage[KEY$1] = {};
1299
+ if(_optionalChain$2([options, 'optionalAccess', _ => _.name])) { localStorage[KEY$1].name = this.name = options.name; }
1300
+ if(_optionalChain$2([options, 'optionalAccess', _2 => _2.logo])) { localStorage[KEY$1].logo = this.logo = options.logo; }
1294
1301
  try {
1295
- window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
1296
1302
 
1297
1303
  this.connector = WalletConnectV1.instance;
1298
1304
 
@@ -1301,23 +1307,30 @@
1301
1307
  }
1302
1308
 
1303
1309
  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
+ if(localStorage[KEY$1]) {
1311
+ if(localStorage[KEY$1].name) { this.name = localStorage[KEY$1].name; }
1312
+ if(localStorage[KEY$1].logo) { this.logo = localStorage[KEY$1].logo; }
1313
+ }
1310
1314
 
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;
1315
+ let account = await this.account();
1316
+ this.connectedChainId = await this.connector.sendCustomRequest({ method: 'eth_chainId' });
1316
1317
 
1317
- return accounts[0]
1318
+ return account
1318
1319
  } else {
1319
- return
1320
+
1321
+ let { accounts, chainId } = await this.connector.connect();
1322
+
1323
+ if(accounts instanceof Array && accounts.length) {
1324
+ setConnectedInstance$2(this);
1325
+ accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1326
+ this.connectedChainId = chainId;
1327
+
1328
+ return accounts[0]
1329
+ } else {
1330
+ return
1331
+ }
1320
1332
  }
1333
+
1321
1334
  } catch (error) {
1322
1335
  console.log('WALLETCONNECT ERROR', error);
1323
1336
  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.9.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",