@depay/web3-wallets-evm 16.0.1 → 16.0.3

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.
@@ -44549,7 +44549,6 @@ const CONFIGURATIONS = {
44549
44549
  methods: [
44550
44550
  "eth_sendTransaction",
44551
44551
  "personal_sign",
44552
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
44553
44552
  "eth_signTypedData",
44554
44553
  "eth_signTypedData_v4",
44555
44554
  "wallet_switchEthereumChain"
@@ -44578,7 +44577,6 @@ const CONFIGURATIONS = {
44578
44577
  "eth_signTypedData",
44579
44578
  ]
44580
44579
  },
44581
-
44582
44580
  };
44583
44581
 
44584
44582
  const DEFAULT_CONFIGURATION = {
@@ -44690,51 +44688,13 @@ class WalletConnectV2 {
44690
44688
  }
44691
44689
  }
44692
44690
 
44693
- async getAllAvailableBlockchains() {
44694
- let timeTillResponse = new Date();
44695
- await Promise.race([...
44696
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
44697
- return new Promise((resolve)=>{
44698
- try {
44699
- this.signClient.request({
44700
- topic: this.session.topic,
44701
- chainId: chainIdentifier,
44702
- request:{
44703
- method: 'eth_chainId',
44704
- }
44705
- }).then(resolve);
44706
- } catch (e) {}
44707
- })
44708
- }),
44709
- new Promise(resolve=>setTimeout(resolve, 6000))
44710
- ]);
44711
- timeTillResponse = new Date() - timeTillResponse;
44712
-
44713
- let blockchains = [];
44714
- await Promise.race([
44715
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
44716
- try {
44717
- return this.signClient.request({
44718
- topic: this.session.topic,
44719
- chainId: chainIdentifier,
44720
- request:{
44721
- method: 'eth_chainId',
44722
- }
44723
- }).then(()=> blockchains.push(Blockchains.findByNetworkId(chainIdentifier.split(':')[1]).name))
44724
- } catch (e2) {}
44725
- })),
44726
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
44727
- ]);
44728
- return blockchains
44729
- }
44730
-
44731
44691
  async setSessionBlockchains() {
44732
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')])) {
44733
- this.blockchains = await this.getAllAvailableBlockchains();
44692
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
44693
+ this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
44734
44694
  } else if(this.session.namespaces.eip155.chains) {
44735
- this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
44695
+ this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
44736
44696
  } else if(this.session.namespaces.eip155.accounts) {
44737
- this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains, 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(accountIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
44697
+ this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains, 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(accountIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
44738
44698
  }
44739
44699
  }
44740
44700
 
@@ -44744,13 +44704,13 @@ class WalletConnectV2 {
44744
44704
 
44745
44705
  try {
44746
44706
 
44747
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
44707
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
44748
44708
 
44749
44709
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
44750
44710
  this.signClient = await getSignClient();
44751
44711
 
44752
44712
  this.signClient.on("session_delete", (session)=> {
44753
- if(_optionalChain$1([session, 'optionalAccess', _38 => _38.topic]) === _optionalChain$1([this, 'access', _39 => _39.session, 'optionalAccess', _40 => _40.topic])) {
44713
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
44754
44714
  localStorage[KEY+':name'] = undefined;
44755
44715
  localStorage[KEY+':logo'] = undefined;
44756
44716
  this.signClient = undefined;
@@ -44759,14 +44719,14 @@ class WalletConnectV2 {
44759
44719
  });
44760
44720
 
44761
44721
  this.signClient.on("session_update", async(session)=> {
44762
- if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
44722
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
44763
44723
  this.session = this.signClient.session.get(session.topic);
44764
44724
  await this.setSessionBlockchains();
44765
44725
  }
44766
44726
  });
44767
44727
 
44768
44728
  this.signClient.on("session_event", (event)=> {
44769
- if(_optionalChain$1([event, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {}
44729
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
44770
44730
  });
44771
44731
 
44772
44732
  const connectWallet = async()=>{
@@ -44777,24 +44737,24 @@ class WalletConnectV2 {
44777
44737
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
44778
44738
  };
44779
44739
 
44780
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
44740
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
44781
44741
  if(lastSession) {
44782
44742
  this.session = lastSession;
44783
44743
  } else {
44784
44744
  await connectWallet();
44785
44745
  }
44786
44746
 
44787
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
44747
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
44788
44748
  if(meta && meta.name) {
44789
44749
  this.name = meta.name;
44790
44750
  localStorage[KEY+':name'] = meta.name;
44791
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
44751
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
44792
44752
  this.logo = meta.icons[0];
44793
44753
  localStorage[KEY+':logo'] = this.logo;
44794
44754
  }
44795
44755
  }
44796
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
44797
- if(_optionalChain$1([options, 'optionalAccess', _54 => _54.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
44756
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
44757
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
44798
44758
 
44799
44759
  await this.setSessionBlockchains();
44800
44760
 
@@ -44851,7 +44811,7 @@ class WalletConnectV2 {
44851
44811
  switch (event) {
44852
44812
  case 'account':
44853
44813
  internalCallback = async(event)=> {
44854
- if(_optionalChain$1([event, 'optionalAccess', _55 => _55.topic]) === _optionalChain$1([this, 'access', _56 => _56.session, 'optionalAccess', _57 => _57.topic]) && event.params.event.name === 'accountsChanged') {
44814
+ if(_optionalChain$1([event, 'optionalAccess', _58 => _58.topic]) === _optionalChain$1([this, 'access', _59 => _59.session, 'optionalAccess', _60 => _60.topic]) && event.params.event.name === 'accountsChanged') {
44855
44815
  callback(await this.account());
44856
44816
  }
44857
44817
  };
package/dist/esm/index.js CHANGED
@@ -1586,7 +1586,6 @@ const CONFIGURATIONS = {
1586
1586
  methods: [
1587
1587
  "eth_sendTransaction",
1588
1588
  "personal_sign",
1589
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
1590
1589
  "eth_signTypedData",
1591
1590
  "eth_signTypedData_v4",
1592
1591
  "wallet_switchEthereumChain"
@@ -1615,7 +1614,6 @@ const CONFIGURATIONS = {
1615
1614
  "eth_signTypedData",
1616
1615
  ]
1617
1616
  },
1618
-
1619
1617
  };
1620
1618
 
1621
1619
  const DEFAULT_CONFIGURATION = {
@@ -1727,51 +1725,13 @@ class WalletConnectV2 {
1727
1725
  }
1728
1726
  }
1729
1727
 
1730
- async getAllAvailableBlockchains() {
1731
- let timeTillResponse = new Date();
1732
- await Promise.race([...
1733
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
1734
- return new Promise((resolve)=>{
1735
- try {
1736
- this.signClient.request({
1737
- topic: this.session.topic,
1738
- chainId: chainIdentifier,
1739
- request:{
1740
- method: 'eth_chainId',
1741
- }
1742
- }).then(resolve);
1743
- } catch (e) {}
1744
- })
1745
- }),
1746
- new Promise(resolve=>setTimeout(resolve, 6000))
1747
- ]);
1748
- timeTillResponse = new Date() - timeTillResponse;
1749
-
1750
- let blockchains = [];
1751
- await Promise.race([
1752
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
1753
- try {
1754
- return this.signClient.request({
1755
- topic: this.session.topic,
1756
- chainId: chainIdentifier,
1757
- request:{
1758
- method: 'eth_chainId',
1759
- }
1760
- }).then(()=> blockchains.push(Blockchains.findByNetworkId(chainIdentifier.split(':')[1]).name))
1761
- } catch (e2) {}
1762
- })),
1763
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
1764
- ]);
1765
- return blockchains
1766
- }
1767
-
1768
1728
  async setSessionBlockchains() {
1769
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')])) {
1770
- this.blockchains = await this.getAllAvailableBlockchains();
1729
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
1730
+ this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
1771
1731
  } else if(this.session.namespaces.eip155.chains) {
1772
- this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
1732
+ this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
1773
1733
  } else if(this.session.namespaces.eip155.accounts) {
1774
- this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains, 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(accountIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
1734
+ this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains, 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(accountIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
1775
1735
  }
1776
1736
  }
1777
1737
 
@@ -1781,13 +1741,13 @@ class WalletConnectV2 {
1781
1741
 
1782
1742
  try {
1783
1743
 
1784
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
1744
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
1785
1745
 
1786
1746
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
1787
1747
  this.signClient = await getSignClient();
1788
1748
 
1789
1749
  this.signClient.on("session_delete", (session)=> {
1790
- if(_optionalChain$1([session, 'optionalAccess', _38 => _38.topic]) === _optionalChain$1([this, 'access', _39 => _39.session, 'optionalAccess', _40 => _40.topic])) {
1750
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
1791
1751
  localStorage[KEY+':name'] = undefined;
1792
1752
  localStorage[KEY+':logo'] = undefined;
1793
1753
  this.signClient = undefined;
@@ -1796,14 +1756,14 @@ class WalletConnectV2 {
1796
1756
  });
1797
1757
 
1798
1758
  this.signClient.on("session_update", async(session)=> {
1799
- if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
1759
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
1800
1760
  this.session = this.signClient.session.get(session.topic);
1801
1761
  await this.setSessionBlockchains();
1802
1762
  }
1803
1763
  });
1804
1764
 
1805
1765
  this.signClient.on("session_event", (event)=> {
1806
- if(_optionalChain$1([event, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {}
1766
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
1807
1767
  });
1808
1768
 
1809
1769
  const connectWallet = async()=>{
@@ -1814,24 +1774,24 @@ class WalletConnectV2 {
1814
1774
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
1815
1775
  };
1816
1776
 
1817
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
1777
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
1818
1778
  if(lastSession) {
1819
1779
  this.session = lastSession;
1820
1780
  } else {
1821
1781
  await connectWallet();
1822
1782
  }
1823
1783
 
1824
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
1784
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
1825
1785
  if(meta && meta.name) {
1826
1786
  this.name = meta.name;
1827
1787
  localStorage[KEY+':name'] = meta.name;
1828
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
1788
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
1829
1789
  this.logo = meta.icons[0];
1830
1790
  localStorage[KEY+':logo'] = this.logo;
1831
1791
  }
1832
1792
  }
1833
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
1834
- if(_optionalChain$1([options, 'optionalAccess', _54 => _54.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
1793
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
1794
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
1835
1795
 
1836
1796
  await this.setSessionBlockchains();
1837
1797
 
@@ -1888,7 +1848,7 @@ class WalletConnectV2 {
1888
1848
  switch (event) {
1889
1849
  case 'account':
1890
1850
  internalCallback = async(event)=> {
1891
- if(_optionalChain$1([event, 'optionalAccess', _55 => _55.topic]) === _optionalChain$1([this, 'access', _56 => _56.session, 'optionalAccess', _57 => _57.topic]) && event.params.event.name === 'accountsChanged') {
1851
+ if(_optionalChain$1([event, 'optionalAccess', _58 => _58.topic]) === _optionalChain$1([this, 'access', _59 => _59.session, 'optionalAccess', _60 => _60.topic]) && event.params.event.name === 'accountsChanged') {
1892
1852
  callback(await this.account());
1893
1853
  }
1894
1854
  };
@@ -2422,7 +2422,6 @@ const CONFIGURATIONS = {
2422
2422
  methods: [
2423
2423
  "eth_sendTransaction",
2424
2424
  "personal_sign",
2425
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
2426
2425
  "eth_signTypedData",
2427
2426
  "eth_signTypedData_v4",
2428
2427
  "wallet_switchEthereumChain"
@@ -2451,7 +2450,6 @@ const CONFIGURATIONS = {
2451
2450
  "eth_signTypedData",
2452
2451
  ]
2453
2452
  },
2454
-
2455
2453
  };
2456
2454
 
2457
2455
  const DEFAULT_CONFIGURATION = {
@@ -2563,51 +2561,13 @@ class WalletConnectV2 {
2563
2561
  }
2564
2562
  }
2565
2563
 
2566
- async getAllAvailableBlockchains() {
2567
- let timeTillResponse = new Date();
2568
- await Promise.race([...
2569
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
2570
- return new Promise((resolve)=>{
2571
- try {
2572
- this.signClient.request({
2573
- topic: this.session.topic,
2574
- chainId: chainIdentifier,
2575
- request:{
2576
- method: 'eth_chainId',
2577
- }
2578
- }).then(resolve);
2579
- } catch (e) {}
2580
- })
2581
- }),
2582
- new Promise(resolve=>setTimeout(resolve, 6000))
2583
- ]);
2584
- timeTillResponse = new Date() - timeTillResponse;
2585
-
2586
- let blockchains = [];
2587
- await Promise.race([
2588
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
2589
- try {
2590
- return this.signClient.request({
2591
- topic: this.session.topic,
2592
- chainId: chainIdentifier,
2593
- request:{
2594
- method: 'eth_chainId',
2595
- }
2596
- }).then(()=> blockchains.push(Blockchains.findByNetworkId(chainIdentifier.split(':')[1]).name))
2597
- } catch (e2) {}
2598
- })),
2599
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
2600
- ]);
2601
- return blockchains
2602
- }
2603
-
2604
2564
  async setSessionBlockchains() {
2605
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')])) {
2606
- this.blockchains = await this.getAllAvailableBlockchains();
2565
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
2566
+ this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
2607
2567
  } else if(this.session.namespaces.eip155.chains) {
2608
- this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
2568
+ this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains, 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
2609
2569
  } else if(this.session.namespaces.eip155.accounts) {
2610
- this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains, 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(accountIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
2570
+ this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains, 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(accountIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
2611
2571
  }
2612
2572
  }
2613
2573
 
@@ -2617,13 +2577,13 @@ class WalletConnectV2 {
2617
2577
 
2618
2578
  try {
2619
2579
 
2620
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
2580
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
2621
2581
 
2622
2582
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
2623
2583
  this.signClient = await getSignClient();
2624
2584
 
2625
2585
  this.signClient.on("session_delete", (session)=> {
2626
- if(_optionalChain$1([session, 'optionalAccess', _38 => _38.topic]) === _optionalChain$1([this, 'access', _39 => _39.session, 'optionalAccess', _40 => _40.topic])) {
2586
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
2627
2587
  localStorage[KEY+':name'] = undefined;
2628
2588
  localStorage[KEY+':logo'] = undefined;
2629
2589
  this.signClient = undefined;
@@ -2632,14 +2592,14 @@ class WalletConnectV2 {
2632
2592
  });
2633
2593
 
2634
2594
  this.signClient.on("session_update", async(session)=> {
2635
- if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
2595
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
2636
2596
  this.session = this.signClient.session.get(session.topic);
2637
2597
  await this.setSessionBlockchains();
2638
2598
  }
2639
2599
  });
2640
2600
 
2641
2601
  this.signClient.on("session_event", (event)=> {
2642
- if(_optionalChain$1([event, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {}
2602
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
2643
2603
  });
2644
2604
 
2645
2605
  const connectWallet = async()=>{
@@ -2650,24 +2610,24 @@ class WalletConnectV2 {
2650
2610
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
2651
2611
  };
2652
2612
 
2653
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
2613
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
2654
2614
  if(lastSession) {
2655
2615
  this.session = lastSession;
2656
2616
  } else {
2657
2617
  await connectWallet();
2658
2618
  }
2659
2619
 
2660
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
2620
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
2661
2621
  if(meta && meta.name) {
2662
2622
  this.name = meta.name;
2663
2623
  localStorage[KEY+':name'] = meta.name;
2664
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
2624
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
2665
2625
  this.logo = meta.icons[0];
2666
2626
  localStorage[KEY+':logo'] = this.logo;
2667
2627
  }
2668
2628
  }
2669
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
2670
- if(_optionalChain$1([options, 'optionalAccess', _54 => _54.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
2629
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
2630
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
2671
2631
 
2672
2632
  await this.setSessionBlockchains();
2673
2633
 
@@ -2724,7 +2684,7 @@ class WalletConnectV2 {
2724
2684
  switch (event) {
2725
2685
  case 'account':
2726
2686
  internalCallback = async(event)=> {
2727
- if(_optionalChain$1([event, 'optionalAccess', _55 => _55.topic]) === _optionalChain$1([this, 'access', _56 => _56.session, 'optionalAccess', _57 => _57.topic]) && event.params.event.name === 'accountsChanged') {
2687
+ if(_optionalChain$1([event, 'optionalAccess', _58 => _58.topic]) === _optionalChain$1([this, 'access', _59 => _59.session, 'optionalAccess', _60 => _60.topic]) && event.params.event.name === 'accountsChanged') {
2728
2688
  callback(await this.account());
2729
2689
  }
2730
2690
  };
@@ -44552,7 +44552,6 @@
44552
44552
  methods: [
44553
44553
  "eth_sendTransaction",
44554
44554
  "personal_sign",
44555
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
44556
44555
  "eth_signTypedData",
44557
44556
  "eth_signTypedData_v4",
44558
44557
  "wallet_switchEthereumChain"
@@ -44581,7 +44580,6 @@
44581
44580
  "eth_signTypedData",
44582
44581
  ]
44583
44582
  },
44584
-
44585
44583
  };
44586
44584
 
44587
44585
  const DEFAULT_CONFIGURATION = {
@@ -44693,51 +44691,13 @@
44693
44691
  }
44694
44692
  }
44695
44693
 
44696
- async getAllAvailableBlockchains() {
44697
- let timeTillResponse = new Date();
44698
- await Promise.race([...
44699
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
44700
- return new Promise((resolve)=>{
44701
- try {
44702
- this.signClient.request({
44703
- topic: this.session.topic,
44704
- chainId: chainIdentifier,
44705
- request:{
44706
- method: 'eth_chainId',
44707
- }
44708
- }).then(resolve);
44709
- } catch (e) {}
44710
- })
44711
- }),
44712
- new Promise(resolve=>setTimeout(resolve, 6000))
44713
- ]);
44714
- timeTillResponse = new Date() - timeTillResponse;
44715
-
44716
- let blockchains = [];
44717
- await Promise.race([
44718
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
44719
- try {
44720
- return this.signClient.request({
44721
- topic: this.session.topic,
44722
- chainId: chainIdentifier,
44723
- request:{
44724
- method: 'eth_chainId',
44725
- }
44726
- }).then(()=> blockchains.push(Blockchains__default['default'].findByNetworkId(chainIdentifier.split(':')[1]).name))
44727
- } catch (e2) {}
44728
- })),
44729
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
44730
- ]);
44731
- return blockchains
44732
- }
44733
-
44734
44694
  async setSessionBlockchains() {
44735
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')])) {
44736
- this.blockchains = await this.getAllAvailableBlockchains();
44695
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
44696
+ this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
44737
44697
  } else if(this.session.namespaces.eip155.chains) {
44738
- this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
44698
+ this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
44739
44699
  } else if(this.session.namespaces.eip155.accounts) {
44740
- this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(accountIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
44700
+ this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(accountIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
44741
44701
  }
44742
44702
  }
44743
44703
 
@@ -44747,13 +44707,13 @@
44747
44707
 
44748
44708
  try {
44749
44709
 
44750
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
44710
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
44751
44711
 
44752
44712
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
44753
44713
  this.signClient = await getSignClient();
44754
44714
 
44755
44715
  this.signClient.on("session_delete", (session)=> {
44756
- if(_optionalChain$1([session, 'optionalAccess', _38 => _38.topic]) === _optionalChain$1([this, 'access', _39 => _39.session, 'optionalAccess', _40 => _40.topic])) {
44716
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
44757
44717
  localStorage[KEY+':name'] = undefined;
44758
44718
  localStorage[KEY+':logo'] = undefined;
44759
44719
  this.signClient = undefined;
@@ -44762,14 +44722,14 @@
44762
44722
  });
44763
44723
 
44764
44724
  this.signClient.on("session_update", async(session)=> {
44765
- if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
44725
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
44766
44726
  this.session = this.signClient.session.get(session.topic);
44767
44727
  await this.setSessionBlockchains();
44768
44728
  }
44769
44729
  });
44770
44730
 
44771
44731
  this.signClient.on("session_event", (event)=> {
44772
- if(_optionalChain$1([event, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {}
44732
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
44773
44733
  });
44774
44734
 
44775
44735
  const connectWallet = async()=>{
@@ -44780,24 +44740,24 @@
44780
44740
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
44781
44741
  };
44782
44742
 
44783
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
44743
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
44784
44744
  if(lastSession) {
44785
44745
  this.session = lastSession;
44786
44746
  } else {
44787
44747
  await connectWallet();
44788
44748
  }
44789
44749
 
44790
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
44750
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
44791
44751
  if(meta && meta.name) {
44792
44752
  this.name = meta.name;
44793
44753
  localStorage[KEY+':name'] = meta.name;
44794
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
44754
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
44795
44755
  this.logo = meta.icons[0];
44796
44756
  localStorage[KEY+':logo'] = this.logo;
44797
44757
  }
44798
44758
  }
44799
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
44800
- if(_optionalChain$1([options, 'optionalAccess', _54 => _54.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
44759
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
44760
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
44801
44761
 
44802
44762
  await this.setSessionBlockchains();
44803
44763
 
@@ -44854,7 +44814,7 @@
44854
44814
  switch (event) {
44855
44815
  case 'account':
44856
44816
  internalCallback = async(event)=> {
44857
- if(_optionalChain$1([event, 'optionalAccess', _55 => _55.topic]) === _optionalChain$1([this, 'access', _56 => _56.session, 'optionalAccess', _57 => _57.topic]) && event.params.event.name === 'accountsChanged') {
44817
+ if(_optionalChain$1([event, 'optionalAccess', _58 => _58.topic]) === _optionalChain$1([this, 'access', _59 => _59.session, 'optionalAccess', _60 => _60.topic]) && event.params.event.name === 'accountsChanged') {
44858
44818
  callback(await this.account());
44859
44819
  }
44860
44820
  };
package/dist/umd/index.js CHANGED
@@ -1588,7 +1588,6 @@
1588
1588
  methods: [
1589
1589
  "eth_sendTransaction",
1590
1590
  "personal_sign",
1591
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
1592
1591
  "eth_signTypedData",
1593
1592
  "eth_signTypedData_v4",
1594
1593
  "wallet_switchEthereumChain"
@@ -1617,7 +1616,6 @@
1617
1616
  "eth_signTypedData",
1618
1617
  ]
1619
1618
  },
1620
-
1621
1619
  };
1622
1620
 
1623
1621
  const DEFAULT_CONFIGURATION = {
@@ -1729,51 +1727,13 @@
1729
1727
  }
1730
1728
  }
1731
1729
 
1732
- async getAllAvailableBlockchains() {
1733
- let timeTillResponse = new Date();
1734
- await Promise.race([...
1735
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
1736
- return new Promise((resolve)=>{
1737
- try {
1738
- this.signClient.request({
1739
- topic: this.session.topic,
1740
- chainId: chainIdentifier,
1741
- request:{
1742
- method: 'eth_chainId',
1743
- }
1744
- }).then(resolve);
1745
- } catch (e) {}
1746
- })
1747
- }),
1748
- new Promise(resolve=>setTimeout(resolve, 6000))
1749
- ]);
1750
- timeTillResponse = new Date() - timeTillResponse;
1751
-
1752
- let blockchains = [];
1753
- await Promise.race([
1754
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
1755
- try {
1756
- return this.signClient.request({
1757
- topic: this.session.topic,
1758
- chainId: chainIdentifier,
1759
- request:{
1760
- method: 'eth_chainId',
1761
- }
1762
- }).then(()=> blockchains.push(Blockchains__default['default'].findByNetworkId(chainIdentifier.split(':')[1]).name))
1763
- } catch (e2) {}
1764
- })),
1765
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
1766
- ]);
1767
- return blockchains
1768
- }
1769
-
1770
1730
  async setSessionBlockchains() {
1771
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')])) {
1772
- this.blockchains = await this.getAllAvailableBlockchains();
1731
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
1732
+ this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
1773
1733
  } else if(this.session.namespaces.eip155.chains) {
1774
- this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
1734
+ this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
1775
1735
  } else if(this.session.namespaces.eip155.accounts) {
1776
- this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(accountIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
1736
+ this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(accountIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
1777
1737
  }
1778
1738
  }
1779
1739
 
@@ -1783,13 +1743,13 @@
1783
1743
 
1784
1744
  try {
1785
1745
 
1786
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
1746
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
1787
1747
 
1788
1748
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
1789
1749
  this.signClient = await getSignClient();
1790
1750
 
1791
1751
  this.signClient.on("session_delete", (session)=> {
1792
- if(_optionalChain$1([session, 'optionalAccess', _38 => _38.topic]) === _optionalChain$1([this, 'access', _39 => _39.session, 'optionalAccess', _40 => _40.topic])) {
1752
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
1793
1753
  localStorage[KEY+':name'] = undefined;
1794
1754
  localStorage[KEY+':logo'] = undefined;
1795
1755
  this.signClient = undefined;
@@ -1798,14 +1758,14 @@
1798
1758
  });
1799
1759
 
1800
1760
  this.signClient.on("session_update", async(session)=> {
1801
- if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
1761
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
1802
1762
  this.session = this.signClient.session.get(session.topic);
1803
1763
  await this.setSessionBlockchains();
1804
1764
  }
1805
1765
  });
1806
1766
 
1807
1767
  this.signClient.on("session_event", (event)=> {
1808
- if(_optionalChain$1([event, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {}
1768
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
1809
1769
  });
1810
1770
 
1811
1771
  const connectWallet = async()=>{
@@ -1816,24 +1776,24 @@
1816
1776
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
1817
1777
  };
1818
1778
 
1819
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
1779
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
1820
1780
  if(lastSession) {
1821
1781
  this.session = lastSession;
1822
1782
  } else {
1823
1783
  await connectWallet();
1824
1784
  }
1825
1785
 
1826
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
1786
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
1827
1787
  if(meta && meta.name) {
1828
1788
  this.name = meta.name;
1829
1789
  localStorage[KEY+':name'] = meta.name;
1830
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
1790
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
1831
1791
  this.logo = meta.icons[0];
1832
1792
  localStorage[KEY+':logo'] = this.logo;
1833
1793
  }
1834
1794
  }
1835
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
1836
- if(_optionalChain$1([options, 'optionalAccess', _54 => _54.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
1795
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
1796
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
1837
1797
 
1838
1798
  await this.setSessionBlockchains();
1839
1799
 
@@ -1890,7 +1850,7 @@
1890
1850
  switch (event) {
1891
1851
  case 'account':
1892
1852
  internalCallback = async(event)=> {
1893
- if(_optionalChain$1([event, 'optionalAccess', _55 => _55.topic]) === _optionalChain$1([this, 'access', _56 => _56.session, 'optionalAccess', _57 => _57.topic]) && event.params.event.name === 'accountsChanged') {
1853
+ if(_optionalChain$1([event, 'optionalAccess', _58 => _58.topic]) === _optionalChain$1([this, 'access', _59 => _59.session, 'optionalAccess', _60 => _60.topic]) && event.params.event.name === 'accountsChanged') {
1894
1854
  callback(await this.account());
1895
1855
  }
1896
1856
  };
@@ -2424,7 +2424,6 @@
2424
2424
  methods: [
2425
2425
  "eth_sendTransaction",
2426
2426
  "personal_sign",
2427
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
2428
2427
  "eth_signTypedData",
2429
2428
  "eth_signTypedData_v4",
2430
2429
  "wallet_switchEthereumChain"
@@ -2453,7 +2452,6 @@
2453
2452
  "eth_signTypedData",
2454
2453
  ]
2455
2454
  },
2456
-
2457
2455
  };
2458
2456
 
2459
2457
  const DEFAULT_CONFIGURATION = {
@@ -2565,51 +2563,13 @@
2565
2563
  }
2566
2564
  }
2567
2565
 
2568
- async getAllAvailableBlockchains() {
2569
- let timeTillResponse = new Date();
2570
- await Promise.race([...
2571
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
2572
- return new Promise((resolve)=>{
2573
- try {
2574
- this.signClient.request({
2575
- topic: this.session.topic,
2576
- chainId: chainIdentifier,
2577
- request:{
2578
- method: 'eth_chainId',
2579
- }
2580
- }).then(resolve);
2581
- } catch (e) {}
2582
- })
2583
- }),
2584
- new Promise(resolve=>setTimeout(resolve, 6000))
2585
- ]);
2586
- timeTillResponse = new Date() - timeTillResponse;
2587
-
2588
- let blockchains = [];
2589
- await Promise.race([
2590
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
2591
- try {
2592
- return this.signClient.request({
2593
- topic: this.session.topic,
2594
- chainId: chainIdentifier,
2595
- request:{
2596
- method: 'eth_chainId',
2597
- }
2598
- }).then(()=> blockchains.push(Blockchains__default['default'].findByNetworkId(chainIdentifier.split(':')[1]).name))
2599
- } catch (e2) {}
2600
- })),
2601
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
2602
- ]);
2603
- return blockchains
2604
- }
2605
-
2606
2566
  async setSessionBlockchains() {
2607
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')])) {
2608
- this.blockchains = await this.getAllAvailableBlockchains();
2567
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
2568
+ this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
2609
2569
  } else if(this.session.namespaces.eip155.chains) {
2610
- this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _31 => _31.findByNetworkId, 'call', _32 => _32(chainIdentifier.split(':')[1]), 'optionalAccess', _33 => _33.name])).filter(Boolean);
2570
+ this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
2611
2571
  } else if(this.session.namespaces.eip155.accounts) {
2612
- this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(accountIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
2572
+ this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$1([Blockchains__default['default'], 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(accountIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
2613
2573
  }
2614
2574
  }
2615
2575
 
@@ -2619,13 +2579,13 @@
2619
2579
 
2620
2580
  try {
2621
2581
 
2622
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
2582
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
2623
2583
 
2624
2584
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
2625
2585
  this.signClient = await getSignClient();
2626
2586
 
2627
2587
  this.signClient.on("session_delete", (session)=> {
2628
- if(_optionalChain$1([session, 'optionalAccess', _38 => _38.topic]) === _optionalChain$1([this, 'access', _39 => _39.session, 'optionalAccess', _40 => _40.topic])) {
2588
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
2629
2589
  localStorage[KEY+':name'] = undefined;
2630
2590
  localStorage[KEY+':logo'] = undefined;
2631
2591
  this.signClient = undefined;
@@ -2634,14 +2594,14 @@
2634
2594
  });
2635
2595
 
2636
2596
  this.signClient.on("session_update", async(session)=> {
2637
- if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
2597
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
2638
2598
  this.session = this.signClient.session.get(session.topic);
2639
2599
  await this.setSessionBlockchains();
2640
2600
  }
2641
2601
  });
2642
2602
 
2643
2603
  this.signClient.on("session_event", (event)=> {
2644
- if(_optionalChain$1([event, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {}
2604
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
2645
2605
  });
2646
2606
 
2647
2607
  const connectWallet = async()=>{
@@ -2652,24 +2612,24 @@
2652
2612
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
2653
2613
  };
2654
2614
 
2655
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
2615
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
2656
2616
  if(lastSession) {
2657
2617
  this.session = lastSession;
2658
2618
  } else {
2659
2619
  await connectWallet();
2660
2620
  }
2661
2621
 
2662
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
2622
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
2663
2623
  if(meta && meta.name) {
2664
2624
  this.name = meta.name;
2665
2625
  localStorage[KEY+':name'] = meta.name;
2666
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
2626
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
2667
2627
  this.logo = meta.icons[0];
2668
2628
  localStorage[KEY+':logo'] = this.logo;
2669
2629
  }
2670
2630
  }
2671
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
2672
- if(_optionalChain$1([options, 'optionalAccess', _54 => _54.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
2631
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
2632
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
2673
2633
 
2674
2634
  await this.setSessionBlockchains();
2675
2635
 
@@ -2726,7 +2686,7 @@
2726
2686
  switch (event) {
2727
2687
  case 'account':
2728
2688
  internalCallback = async(event)=> {
2729
- if(_optionalChain$1([event, 'optionalAccess', _55 => _55.topic]) === _optionalChain$1([this, 'access', _56 => _56.session, 'optionalAccess', _57 => _57.topic]) && event.params.event.name === 'accountsChanged') {
2689
+ if(_optionalChain$1([event, 'optionalAccess', _58 => _58.topic]) === _optionalChain$1([this, 'access', _59 => _59.session, 'optionalAccess', _60 => _60.topic]) && event.params.event.name === 'accountsChanged') {
2730
2690
  callback(await this.account());
2731
2691
  }
2732
2692
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/web3-wallets-evm",
3
3
  "moduleName": "Web3Wallets",
4
- "version": "16.0.1",
4
+ "version": "16.0.3",
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",