@depay/web3-wallets-evm 13.0.0 → 13.1.1

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.
package/README.md CHANGED
@@ -99,6 +99,15 @@ if(foundWallets.length == 1) {
99
99
  }
100
100
  ```
101
101
 
102
+ ### getConnectedWallets
103
+
104
+ `getConnectedWallets`: Returns an array of currently connected wallets.
105
+
106
+ ```javascript
107
+ let wallets = await getConnectedWallets();
108
+ // [<Wallet name='MetaMask'>, <Wallet name='Phantom'>]
109
+ ```
110
+
102
111
  ### Name
103
112
 
104
113
  `name:string`: Returns the name of the wallet.
@@ -864,6 +864,19 @@ const getWallets = ()=>{
864
864
  return availableWallets
865
865
  };
866
866
 
867
+ const getConnectedWallets = async()=>{
868
+
869
+ let connectedWallets = (await Promise.all(
870
+ getWallets().map(async(wallet)=>{
871
+ if(await wallet.account()) {
872
+ return wallet
873
+ }
874
+ })
875
+ )).filter((value)=>!!value);
876
+
877
+ return connectedWallets
878
+ };
879
+
867
880
  const supported = [
868
881
  wallets.MetaMask,
869
882
  wallets.Coinbase,
@@ -871,4 +884,4 @@ const supported = [
871
884
  wallets.WalletLink
872
885
  ];
873
886
 
874
- export { getWallets, supported, wallets };
887
+ export { getConnectedWallets, getWallets, supported, wallets };
package/dist/esm/index.js CHANGED
@@ -444,14 +444,17 @@ class WindowSolana {
444
444
  }
445
445
 
446
446
  async account() {
447
- if(_optionalChain$3([window, 'optionalAccess', _7 => _7.solana, 'optionalAccess', _8 => _8.publicKey])) {return window.solana.publicKey.toString() }
448
- if(_optionalChain$3([window, 'optionalAccess', _9 => _9.solana]) == undefined){ return }
449
- let { publicKey } = await window.solana.connect({ onlyIfTrusted: true });
450
- if(publicKey){ return publicKey.toString() }
447
+ if(_optionalChain$3([window, 'optionalAccess', _7 => _7.solana]) == undefined){ return }
448
+ if(_optionalChain$3([window, 'optionalAccess', _8 => _8.solana, 'optionalAccess', _9 => _9.publicKey])) { return window.solana.publicKey.toString() }
449
+ if(_optionalChain$3([window, 'optionalAccess', _10 => _10.solana, 'optionalAccess', _11 => _11.isBraveWallet]) != true) {
450
+ let publicKey;
451
+ try { ({ publicKey } = await window.solana.connect({ onlyIfTrusted: true })); } catch (e) {}
452
+ if(publicKey){ return publicKey.toString() }
453
+ }
451
454
  }
452
455
 
453
456
  async connect() {
454
- if(!_optionalChain$3([window, 'optionalAccess', _10 => _10.solana])) { return undefined }
457
+ if(!_optionalChain$3([window, 'optionalAccess', _12 => _12.solana])) { return undefined }
455
458
  let { publicKey } = await window.solana.connect();
456
459
  return publicKey.toString()
457
460
  }
@@ -460,7 +463,7 @@ class WindowSolana {
460
463
  let internalCallback;
461
464
  switch (event) {
462
465
  case 'account':
463
- internalCallback = (publicKey) => callback(_optionalChain$3([publicKey, 'optionalAccess', _11 => _11.toString, 'call', _12 => _12()]));
466
+ internalCallback = (publicKey) => callback(_optionalChain$3([publicKey, 'optionalAccess', _13 => _13.toString, 'call', _14 => _14()]));
464
467
  window.solana.on('accountChanged', internalCallback);
465
468
  break
466
469
  }
@@ -1054,6 +1057,19 @@ const getWallets = ()=>{
1054
1057
  return availableWallets
1055
1058
  };
1056
1059
 
1060
+ const getConnectedWallets = async()=>{
1061
+
1062
+ let connectedWallets = (await Promise.all(
1063
+ getWallets().map(async(wallet)=>{
1064
+ if(await wallet.account()) {
1065
+ return wallet
1066
+ }
1067
+ })
1068
+ )).filter((value)=>!!value);
1069
+
1070
+ return connectedWallets
1071
+ };
1072
+
1057
1073
  const supported = [
1058
1074
  wallets.MetaMask,
1059
1075
  wallets.Phantom,
@@ -1062,4 +1078,4 @@ const supported = [
1062
1078
  wallets.WalletLink
1063
1079
  ];
1064
1080
 
1065
- export { getWallets, supported, wallets };
1081
+ export { getConnectedWallets, getWallets, supported, wallets };
@@ -863,6 +863,19 @@
863
863
  return availableWallets
864
864
  };
865
865
 
866
+ const getConnectedWallets = async()=>{
867
+
868
+ let connectedWallets = (await Promise.all(
869
+ getWallets().map(async(wallet)=>{
870
+ if(await wallet.account()) {
871
+ return wallet
872
+ }
873
+ })
874
+ )).filter((value)=>!!value);
875
+
876
+ return connectedWallets
877
+ };
878
+
866
879
  const supported = [
867
880
  wallets.MetaMask,
868
881
  wallets.Coinbase,
@@ -870,6 +883,7 @@
870
883
  wallets.WalletLink
871
884
  ];
872
885
 
886
+ exports.getConnectedWallets = getConnectedWallets;
873
887
  exports.getWallets = getWallets;
874
888
  exports.supported = supported;
875
889
  exports.wallets = wallets;
package/dist/umd/index.js CHANGED
@@ -442,14 +442,17 @@
442
442
  }
443
443
 
444
444
  async account() {
445
- if(_optionalChain$3([window, 'optionalAccess', _7 => _7.solana, 'optionalAccess', _8 => _8.publicKey])) {return window.solana.publicKey.toString() }
446
- if(_optionalChain$3([window, 'optionalAccess', _9 => _9.solana]) == undefined){ return }
447
- let { publicKey } = await window.solana.connect({ onlyIfTrusted: true });
448
- if(publicKey){ return publicKey.toString() }
445
+ if(_optionalChain$3([window, 'optionalAccess', _7 => _7.solana]) == undefined){ return }
446
+ if(_optionalChain$3([window, 'optionalAccess', _8 => _8.solana, 'optionalAccess', _9 => _9.publicKey])) { return window.solana.publicKey.toString() }
447
+ if(_optionalChain$3([window, 'optionalAccess', _10 => _10.solana, 'optionalAccess', _11 => _11.isBraveWallet]) != true) {
448
+ let publicKey;
449
+ try { ({ publicKey } = await window.solana.connect({ onlyIfTrusted: true })); } catch (e) {}
450
+ if(publicKey){ return publicKey.toString() }
451
+ }
449
452
  }
450
453
 
451
454
  async connect() {
452
- if(!_optionalChain$3([window, 'optionalAccess', _10 => _10.solana])) { return undefined }
455
+ if(!_optionalChain$3([window, 'optionalAccess', _12 => _12.solana])) { return undefined }
453
456
  let { publicKey } = await window.solana.connect();
454
457
  return publicKey.toString()
455
458
  }
@@ -458,7 +461,7 @@
458
461
  let internalCallback;
459
462
  switch (event) {
460
463
  case 'account':
461
- internalCallback = (publicKey) => callback(_optionalChain$3([publicKey, 'optionalAccess', _11 => _11.toString, 'call', _12 => _12()]));
464
+ internalCallback = (publicKey) => callback(_optionalChain$3([publicKey, 'optionalAccess', _13 => _13.toString, 'call', _14 => _14()]));
462
465
  window.solana.on('accountChanged', internalCallback);
463
466
  break
464
467
  }
@@ -1052,6 +1055,19 @@
1052
1055
  return availableWallets
1053
1056
  };
1054
1057
 
1058
+ const getConnectedWallets = async()=>{
1059
+
1060
+ let connectedWallets = (await Promise.all(
1061
+ getWallets().map(async(wallet)=>{
1062
+ if(await wallet.account()) {
1063
+ return wallet
1064
+ }
1065
+ })
1066
+ )).filter((value)=>!!value);
1067
+
1068
+ return connectedWallets
1069
+ };
1070
+
1055
1071
  const supported = [
1056
1072
  wallets.MetaMask,
1057
1073
  wallets.Phantom,
@@ -1060,6 +1076,7 @@
1060
1076
  wallets.WalletLink
1061
1077
  ];
1062
1078
 
1079
+ exports.getConnectedWallets = getConnectedWallets;
1063
1080
  exports.getWallets = getWallets;
1064
1081
  exports.supported = supported;
1065
1082
  exports.wallets = wallets;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/web3-wallets-evm",
3
3
  "moduleName": "Web3Wallets",
4
- "version": "13.0.0",
4
+ "version": "13.1.1",
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",