@depay/web3-wallets-evm 16.0.2 → 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"
@@ -44580,17 +44579,6 @@ const CONFIGURATIONS = {
44580
44579
  },
44581
44580
  };
44582
44581
 
44583
- const isMobile = ()=> {
44584
- if (typeof window !== 'undefined') {
44585
- return Boolean(
44586
- window.matchMedia('(pointer:coarse)').matches ||
44587
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)
44588
- )
44589
- }
44590
-
44591
- return false
44592
- };
44593
-
44594
44582
  const DEFAULT_CONFIGURATION = {
44595
44583
  events: ['accountsChanged'],
44596
44584
  methods: [
@@ -44700,51 +44688,13 @@ class WalletConnectV2 {
44700
44688
  }
44701
44689
  }
44702
44690
 
44703
- async getAllAvailableBlockchains() {
44704
- let timeTillResponse = new Date();
44705
- await Promise.race([...
44706
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
44707
- return new Promise((resolve)=>{
44708
- try {
44709
- this.signClient.request({
44710
- topic: this.session.topic,
44711
- chainId: chainIdentifier,
44712
- request:{
44713
- method: 'eth_chainId',
44714
- }
44715
- }).then(resolve);
44716
- } catch (e) {}
44717
- })
44718
- }),
44719
- new Promise(resolve=>setTimeout(resolve, 6000))
44720
- ]);
44721
- timeTillResponse = new Date() - timeTillResponse;
44722
-
44723
- let blockchains = [];
44724
- await Promise.race([
44725
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
44726
- try {
44727
- return this.signClient.request({
44728
- topic: this.session.topic,
44729
- chainId: chainIdentifier,
44730
- request:{
44731
- method: 'eth_chainId',
44732
- }
44733
- }).then(()=> blockchains.push(Blockchains.findByNetworkId(chainIdentifier.split(':')[1]).name))
44734
- } catch (e2) {}
44735
- })),
44736
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
44737
- ]);
44738
- return blockchains
44739
- }
44740
-
44741
44691
  async setSessionBlockchains() {
44742
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')]) && !isMobile()) {
44743
- 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);
44744
44694
  } else if(this.session.namespaces.eip155.chains) {
44745
- 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);
44746
44696
  } else if(this.session.namespaces.eip155.accounts) {
44747
- 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);
44748
44698
  }
44749
44699
  }
44750
44700
 
@@ -44754,13 +44704,13 @@ class WalletConnectV2 {
44754
44704
 
44755
44705
  try {
44756
44706
 
44757
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
44707
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
44758
44708
 
44759
44709
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
44760
44710
  this.signClient = await getSignClient();
44761
44711
 
44762
44712
  this.signClient.on("session_delete", (session)=> {
44763
- 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])) {
44764
44714
  localStorage[KEY+':name'] = undefined;
44765
44715
  localStorage[KEY+':logo'] = undefined;
44766
44716
  this.signClient = undefined;
@@ -44769,14 +44719,14 @@ class WalletConnectV2 {
44769
44719
  });
44770
44720
 
44771
44721
  this.signClient.on("session_update", async(session)=> {
44772
- 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])) {
44773
44723
  this.session = this.signClient.session.get(session.topic);
44774
44724
  await this.setSessionBlockchains();
44775
44725
  }
44776
44726
  });
44777
44727
 
44778
44728
  this.signClient.on("session_event", (event)=> {
44779
- 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])) {}
44780
44730
  });
44781
44731
 
44782
44732
  const connectWallet = async()=>{
@@ -44787,24 +44737,24 @@ class WalletConnectV2 {
44787
44737
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
44788
44738
  };
44789
44739
 
44790
- 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;
44791
44741
  if(lastSession) {
44792
44742
  this.session = lastSession;
44793
44743
  } else {
44794
44744
  await connectWallet();
44795
44745
  }
44796
44746
 
44797
- 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]);
44798
44748
  if(meta && meta.name) {
44799
44749
  this.name = meta.name;
44800
44750
  localStorage[KEY+':name'] = meta.name;
44801
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
44751
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
44802
44752
  this.logo = meta.icons[0];
44803
44753
  localStorage[KEY+':logo'] = this.logo;
44804
44754
  }
44805
44755
  }
44806
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
44807
- 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; }
44808
44758
 
44809
44759
  await this.setSessionBlockchains();
44810
44760
 
@@ -44861,7 +44811,7 @@ class WalletConnectV2 {
44861
44811
  switch (event) {
44862
44812
  case 'account':
44863
44813
  internalCallback = async(event)=> {
44864
- 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') {
44865
44815
  callback(await this.account());
44866
44816
  }
44867
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"
@@ -1617,17 +1616,6 @@ const CONFIGURATIONS = {
1617
1616
  },
1618
1617
  };
1619
1618
 
1620
- const isMobile = ()=> {
1621
- if (typeof window !== 'undefined') {
1622
- return Boolean(
1623
- window.matchMedia('(pointer:coarse)').matches ||
1624
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)
1625
- )
1626
- }
1627
-
1628
- return false
1629
- };
1630
-
1631
1619
  const DEFAULT_CONFIGURATION = {
1632
1620
  events: ['accountsChanged'],
1633
1621
  methods: [
@@ -1737,51 +1725,13 @@ class WalletConnectV2 {
1737
1725
  }
1738
1726
  }
1739
1727
 
1740
- async getAllAvailableBlockchains() {
1741
- let timeTillResponse = new Date();
1742
- await Promise.race([...
1743
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
1744
- return new Promise((resolve)=>{
1745
- try {
1746
- this.signClient.request({
1747
- topic: this.session.topic,
1748
- chainId: chainIdentifier,
1749
- request:{
1750
- method: 'eth_chainId',
1751
- }
1752
- }).then(resolve);
1753
- } catch (e) {}
1754
- })
1755
- }),
1756
- new Promise(resolve=>setTimeout(resolve, 6000))
1757
- ]);
1758
- timeTillResponse = new Date() - timeTillResponse;
1759
-
1760
- let blockchains = [];
1761
- await Promise.race([
1762
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
1763
- try {
1764
- return this.signClient.request({
1765
- topic: this.session.topic,
1766
- chainId: chainIdentifier,
1767
- request:{
1768
- method: 'eth_chainId',
1769
- }
1770
- }).then(()=> blockchains.push(Blockchains.findByNetworkId(chainIdentifier.split(':')[1]).name))
1771
- } catch (e2) {}
1772
- })),
1773
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
1774
- ]);
1775
- return blockchains
1776
- }
1777
-
1778
1728
  async setSessionBlockchains() {
1779
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')]) && !isMobile()) {
1780
- 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);
1781
1731
  } else if(this.session.namespaces.eip155.chains) {
1782
- 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);
1783
1733
  } else if(this.session.namespaces.eip155.accounts) {
1784
- 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);
1785
1735
  }
1786
1736
  }
1787
1737
 
@@ -1791,13 +1741,13 @@ class WalletConnectV2 {
1791
1741
 
1792
1742
  try {
1793
1743
 
1794
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
1744
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
1795
1745
 
1796
1746
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
1797
1747
  this.signClient = await getSignClient();
1798
1748
 
1799
1749
  this.signClient.on("session_delete", (session)=> {
1800
- 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])) {
1801
1751
  localStorage[KEY+':name'] = undefined;
1802
1752
  localStorage[KEY+':logo'] = undefined;
1803
1753
  this.signClient = undefined;
@@ -1806,14 +1756,14 @@ class WalletConnectV2 {
1806
1756
  });
1807
1757
 
1808
1758
  this.signClient.on("session_update", async(session)=> {
1809
- 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])) {
1810
1760
  this.session = this.signClient.session.get(session.topic);
1811
1761
  await this.setSessionBlockchains();
1812
1762
  }
1813
1763
  });
1814
1764
 
1815
1765
  this.signClient.on("session_event", (event)=> {
1816
- 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])) {}
1817
1767
  });
1818
1768
 
1819
1769
  const connectWallet = async()=>{
@@ -1824,24 +1774,24 @@ class WalletConnectV2 {
1824
1774
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
1825
1775
  };
1826
1776
 
1827
- 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;
1828
1778
  if(lastSession) {
1829
1779
  this.session = lastSession;
1830
1780
  } else {
1831
1781
  await connectWallet();
1832
1782
  }
1833
1783
 
1834
- 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]);
1835
1785
  if(meta && meta.name) {
1836
1786
  this.name = meta.name;
1837
1787
  localStorage[KEY+':name'] = meta.name;
1838
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
1788
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
1839
1789
  this.logo = meta.icons[0];
1840
1790
  localStorage[KEY+':logo'] = this.logo;
1841
1791
  }
1842
1792
  }
1843
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
1844
- 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; }
1845
1795
 
1846
1796
  await this.setSessionBlockchains();
1847
1797
 
@@ -1898,7 +1848,7 @@ class WalletConnectV2 {
1898
1848
  switch (event) {
1899
1849
  case 'account':
1900
1850
  internalCallback = async(event)=> {
1901
- 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') {
1902
1852
  callback(await this.account());
1903
1853
  }
1904
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"
@@ -2453,17 +2452,6 @@ const CONFIGURATIONS = {
2453
2452
  },
2454
2453
  };
2455
2454
 
2456
- const isMobile = ()=> {
2457
- if (typeof window !== 'undefined') {
2458
- return Boolean(
2459
- window.matchMedia('(pointer:coarse)').matches ||
2460
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)
2461
- )
2462
- }
2463
-
2464
- return false
2465
- };
2466
-
2467
2455
  const DEFAULT_CONFIGURATION = {
2468
2456
  events: ['accountsChanged'],
2469
2457
  methods: [
@@ -2573,51 +2561,13 @@ class WalletConnectV2 {
2573
2561
  }
2574
2562
  }
2575
2563
 
2576
- async getAllAvailableBlockchains() {
2577
- let timeTillResponse = new Date();
2578
- await Promise.race([...
2579
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
2580
- return new Promise((resolve)=>{
2581
- try {
2582
- this.signClient.request({
2583
- topic: this.session.topic,
2584
- chainId: chainIdentifier,
2585
- request:{
2586
- method: 'eth_chainId',
2587
- }
2588
- }).then(resolve);
2589
- } catch (e) {}
2590
- })
2591
- }),
2592
- new Promise(resolve=>setTimeout(resolve, 6000))
2593
- ]);
2594
- timeTillResponse = new Date() - timeTillResponse;
2595
-
2596
- let blockchains = [];
2597
- await Promise.race([
2598
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
2599
- try {
2600
- return this.signClient.request({
2601
- topic: this.session.topic,
2602
- chainId: chainIdentifier,
2603
- request:{
2604
- method: 'eth_chainId',
2605
- }
2606
- }).then(()=> blockchains.push(Blockchains.findByNetworkId(chainIdentifier.split(':')[1]).name))
2607
- } catch (e2) {}
2608
- })),
2609
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
2610
- ]);
2611
- return blockchains
2612
- }
2613
-
2614
2564
  async setSessionBlockchains() {
2615
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')]) && !isMobile()) {
2616
- 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);
2617
2567
  } else if(this.session.namespaces.eip155.chains) {
2618
- 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);
2619
2569
  } else if(this.session.namespaces.eip155.accounts) {
2620
- 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);
2621
2571
  }
2622
2572
  }
2623
2573
 
@@ -2627,13 +2577,13 @@ class WalletConnectV2 {
2627
2577
 
2628
2578
  try {
2629
2579
 
2630
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
2580
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
2631
2581
 
2632
2582
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
2633
2583
  this.signClient = await getSignClient();
2634
2584
 
2635
2585
  this.signClient.on("session_delete", (session)=> {
2636
- 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])) {
2637
2587
  localStorage[KEY+':name'] = undefined;
2638
2588
  localStorage[KEY+':logo'] = undefined;
2639
2589
  this.signClient = undefined;
@@ -2642,14 +2592,14 @@ class WalletConnectV2 {
2642
2592
  });
2643
2593
 
2644
2594
  this.signClient.on("session_update", async(session)=> {
2645
- 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])) {
2646
2596
  this.session = this.signClient.session.get(session.topic);
2647
2597
  await this.setSessionBlockchains();
2648
2598
  }
2649
2599
  });
2650
2600
 
2651
2601
  this.signClient.on("session_event", (event)=> {
2652
- 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])) {}
2653
2603
  });
2654
2604
 
2655
2605
  const connectWallet = async()=>{
@@ -2660,24 +2610,24 @@ class WalletConnectV2 {
2660
2610
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
2661
2611
  };
2662
2612
 
2663
- 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;
2664
2614
  if(lastSession) {
2665
2615
  this.session = lastSession;
2666
2616
  } else {
2667
2617
  await connectWallet();
2668
2618
  }
2669
2619
 
2670
- 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]);
2671
2621
  if(meta && meta.name) {
2672
2622
  this.name = meta.name;
2673
2623
  localStorage[KEY+':name'] = meta.name;
2674
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
2624
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
2675
2625
  this.logo = meta.icons[0];
2676
2626
  localStorage[KEY+':logo'] = this.logo;
2677
2627
  }
2678
2628
  }
2679
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
2680
- 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; }
2681
2631
 
2682
2632
  await this.setSessionBlockchains();
2683
2633
 
@@ -2734,7 +2684,7 @@ class WalletConnectV2 {
2734
2684
  switch (event) {
2735
2685
  case 'account':
2736
2686
  internalCallback = async(event)=> {
2737
- 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') {
2738
2688
  callback(await this.account());
2739
2689
  }
2740
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"
@@ -44583,17 +44582,6 @@
44583
44582
  },
44584
44583
  };
44585
44584
 
44586
- const isMobile = ()=> {
44587
- if (typeof window !== 'undefined') {
44588
- return Boolean(
44589
- window.matchMedia('(pointer:coarse)').matches ||
44590
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)
44591
- )
44592
- }
44593
-
44594
- return false
44595
- };
44596
-
44597
44585
  const DEFAULT_CONFIGURATION = {
44598
44586
  events: ['accountsChanged'],
44599
44587
  methods: [
@@ -44703,51 +44691,13 @@
44703
44691
  }
44704
44692
  }
44705
44693
 
44706
- async getAllAvailableBlockchains() {
44707
- let timeTillResponse = new Date();
44708
- await Promise.race([...
44709
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
44710
- return new Promise((resolve)=>{
44711
- try {
44712
- this.signClient.request({
44713
- topic: this.session.topic,
44714
- chainId: chainIdentifier,
44715
- request:{
44716
- method: 'eth_chainId',
44717
- }
44718
- }).then(resolve);
44719
- } catch (e) {}
44720
- })
44721
- }),
44722
- new Promise(resolve=>setTimeout(resolve, 6000))
44723
- ]);
44724
- timeTillResponse = new Date() - timeTillResponse;
44725
-
44726
- let blockchains = [];
44727
- await Promise.race([
44728
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
44729
- try {
44730
- return this.signClient.request({
44731
- topic: this.session.topic,
44732
- chainId: chainIdentifier,
44733
- request:{
44734
- method: 'eth_chainId',
44735
- }
44736
- }).then(()=> blockchains.push(Blockchains__default['default'].findByNetworkId(chainIdentifier.split(':')[1]).name))
44737
- } catch (e2) {}
44738
- })),
44739
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
44740
- ]);
44741
- return blockchains
44742
- }
44743
-
44744
44694
  async setSessionBlockchains() {
44745
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')]) && !isMobile()) {
44746
- 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);
44747
44697
  } else if(this.session.namespaces.eip155.chains) {
44748
- 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);
44749
44699
  } else if(this.session.namespaces.eip155.accounts) {
44750
- 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);
44751
44701
  }
44752
44702
  }
44753
44703
 
@@ -44757,13 +44707,13 @@
44757
44707
 
44758
44708
  try {
44759
44709
 
44760
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
44710
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
44761
44711
 
44762
44712
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
44763
44713
  this.signClient = await getSignClient();
44764
44714
 
44765
44715
  this.signClient.on("session_delete", (session)=> {
44766
- 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])) {
44767
44717
  localStorage[KEY+':name'] = undefined;
44768
44718
  localStorage[KEY+':logo'] = undefined;
44769
44719
  this.signClient = undefined;
@@ -44772,14 +44722,14 @@
44772
44722
  });
44773
44723
 
44774
44724
  this.signClient.on("session_update", async(session)=> {
44775
- 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])) {
44776
44726
  this.session = this.signClient.session.get(session.topic);
44777
44727
  await this.setSessionBlockchains();
44778
44728
  }
44779
44729
  });
44780
44730
 
44781
44731
  this.signClient.on("session_event", (event)=> {
44782
- 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])) {}
44783
44733
  });
44784
44734
 
44785
44735
  const connectWallet = async()=>{
@@ -44790,24 +44740,24 @@
44790
44740
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
44791
44741
  };
44792
44742
 
44793
- 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;
44794
44744
  if(lastSession) {
44795
44745
  this.session = lastSession;
44796
44746
  } else {
44797
44747
  await connectWallet();
44798
44748
  }
44799
44749
 
44800
- 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]);
44801
44751
  if(meta && meta.name) {
44802
44752
  this.name = meta.name;
44803
44753
  localStorage[KEY+':name'] = meta.name;
44804
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
44754
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
44805
44755
  this.logo = meta.icons[0];
44806
44756
  localStorage[KEY+':logo'] = this.logo;
44807
44757
  }
44808
44758
  }
44809
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
44810
- 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; }
44811
44761
 
44812
44762
  await this.setSessionBlockchains();
44813
44763
 
@@ -44864,7 +44814,7 @@
44864
44814
  switch (event) {
44865
44815
  case 'account':
44866
44816
  internalCallback = async(event)=> {
44867
- 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') {
44868
44818
  callback(await this.account());
44869
44819
  }
44870
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"
@@ -1619,17 +1618,6 @@
1619
1618
  },
1620
1619
  };
1621
1620
 
1622
- const isMobile = ()=> {
1623
- if (typeof window !== 'undefined') {
1624
- return Boolean(
1625
- window.matchMedia('(pointer:coarse)').matches ||
1626
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)
1627
- )
1628
- }
1629
-
1630
- return false
1631
- };
1632
-
1633
1621
  const DEFAULT_CONFIGURATION = {
1634
1622
  events: ['accountsChanged'],
1635
1623
  methods: [
@@ -1739,51 +1727,13 @@
1739
1727
  }
1740
1728
  }
1741
1729
 
1742
- async getAllAvailableBlockchains() {
1743
- let timeTillResponse = new Date();
1744
- await Promise.race([...
1745
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
1746
- return new Promise((resolve)=>{
1747
- try {
1748
- this.signClient.request({
1749
- topic: this.session.topic,
1750
- chainId: chainIdentifier,
1751
- request:{
1752
- method: 'eth_chainId',
1753
- }
1754
- }).then(resolve);
1755
- } catch (e) {}
1756
- })
1757
- }),
1758
- new Promise(resolve=>setTimeout(resolve, 6000))
1759
- ]);
1760
- timeTillResponse = new Date() - timeTillResponse;
1761
-
1762
- let blockchains = [];
1763
- await Promise.race([
1764
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
1765
- try {
1766
- return this.signClient.request({
1767
- topic: this.session.topic,
1768
- chainId: chainIdentifier,
1769
- request:{
1770
- method: 'eth_chainId',
1771
- }
1772
- }).then(()=> blockchains.push(Blockchains__default['default'].findByNetworkId(chainIdentifier.split(':')[1]).name))
1773
- } catch (e2) {}
1774
- })),
1775
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
1776
- ]);
1777
- return blockchains
1778
- }
1779
-
1780
1730
  async setSessionBlockchains() {
1781
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')]) && !isMobile()) {
1782
- 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);
1783
1733
  } else if(this.session.namespaces.eip155.chains) {
1784
- 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);
1785
1735
  } else if(this.session.namespaces.eip155.accounts) {
1786
- 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);
1787
1737
  }
1788
1738
  }
1789
1739
 
@@ -1793,13 +1743,13 @@
1793
1743
 
1794
1744
  try {
1795
1745
 
1796
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
1746
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
1797
1747
 
1798
1748
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
1799
1749
  this.signClient = await getSignClient();
1800
1750
 
1801
1751
  this.signClient.on("session_delete", (session)=> {
1802
- 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])) {
1803
1753
  localStorage[KEY+':name'] = undefined;
1804
1754
  localStorage[KEY+':logo'] = undefined;
1805
1755
  this.signClient = undefined;
@@ -1808,14 +1758,14 @@
1808
1758
  });
1809
1759
 
1810
1760
  this.signClient.on("session_update", async(session)=> {
1811
- 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])) {
1812
1762
  this.session = this.signClient.session.get(session.topic);
1813
1763
  await this.setSessionBlockchains();
1814
1764
  }
1815
1765
  });
1816
1766
 
1817
1767
  this.signClient.on("session_event", (event)=> {
1818
- 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])) {}
1819
1769
  });
1820
1770
 
1821
1771
  const connectWallet = async()=>{
@@ -1826,24 +1776,24 @@
1826
1776
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
1827
1777
  };
1828
1778
 
1829
- 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;
1830
1780
  if(lastSession) {
1831
1781
  this.session = lastSession;
1832
1782
  } else {
1833
1783
  await connectWallet();
1834
1784
  }
1835
1785
 
1836
- 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]);
1837
1787
  if(meta && meta.name) {
1838
1788
  this.name = meta.name;
1839
1789
  localStorage[KEY+':name'] = meta.name;
1840
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
1790
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
1841
1791
  this.logo = meta.icons[0];
1842
1792
  localStorage[KEY+':logo'] = this.logo;
1843
1793
  }
1844
1794
  }
1845
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
1846
- 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; }
1847
1797
 
1848
1798
  await this.setSessionBlockchains();
1849
1799
 
@@ -1900,7 +1850,7 @@
1900
1850
  switch (event) {
1901
1851
  case 'account':
1902
1852
  internalCallback = async(event)=> {
1903
- 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') {
1904
1854
  callback(await this.account());
1905
1855
  }
1906
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"
@@ -2455,17 +2454,6 @@
2455
2454
  },
2456
2455
  };
2457
2456
 
2458
- const isMobile = ()=> {
2459
- if (typeof window !== 'undefined') {
2460
- return Boolean(
2461
- window.matchMedia('(pointer:coarse)').matches ||
2462
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)
2463
- )
2464
- }
2465
-
2466
- return false
2467
- };
2468
-
2469
2457
  const DEFAULT_CONFIGURATION = {
2470
2458
  events: ['accountsChanged'],
2471
2459
  methods: [
@@ -2575,51 +2563,13 @@
2575
2563
  }
2576
2564
  }
2577
2565
 
2578
- async getAllAvailableBlockchains() {
2579
- let timeTillResponse = new Date();
2580
- await Promise.race([...
2581
- this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
2582
- return new Promise((resolve)=>{
2583
- try {
2584
- this.signClient.request({
2585
- topic: this.session.topic,
2586
- chainId: chainIdentifier,
2587
- request:{
2588
- method: 'eth_chainId',
2589
- }
2590
- }).then(resolve);
2591
- } catch (e) {}
2592
- })
2593
- }),
2594
- new Promise(resolve=>setTimeout(resolve, 6000))
2595
- ]);
2596
- timeTillResponse = new Date() - timeTillResponse;
2597
-
2598
- let blockchains = [];
2599
- await Promise.race([
2600
- Promise.all(this.session.namespaces.eip155.chains.map((chainIdentifier)=>{
2601
- try {
2602
- return this.signClient.request({
2603
- topic: this.session.topic,
2604
- chainId: chainIdentifier,
2605
- request:{
2606
- method: 'eth_chainId',
2607
- }
2608
- }).then(()=> blockchains.push(Blockchains__default['default'].findByNetworkId(chainIdentifier.split(':')[1]).name))
2609
- } catch (e2) {}
2610
- })),
2611
- new Promise(resolve => setTimeout(resolve, timeTillResponse*2))
2612
- ]);
2613
- return blockchains
2614
- }
2615
-
2616
2566
  async setSessionBlockchains() {
2617
- if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('eth_chainId')]) && !isMobile()) {
2618
- 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);
2619
2569
  } else if(this.session.namespaces.eip155.chains) {
2620
- 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);
2621
2571
  } else if(this.session.namespaces.eip155.accounts) {
2622
- 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);
2623
2573
  }
2624
2574
  }
2625
2575
 
@@ -2629,13 +2579,13 @@
2629
2579
 
2630
2580
  try {
2631
2581
 
2632
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
2582
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
2633
2583
 
2634
2584
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
2635
2585
  this.signClient = await getSignClient();
2636
2586
 
2637
2587
  this.signClient.on("session_delete", (session)=> {
2638
- 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])) {
2639
2589
  localStorage[KEY+':name'] = undefined;
2640
2590
  localStorage[KEY+':logo'] = undefined;
2641
2591
  this.signClient = undefined;
@@ -2644,14 +2594,14 @@
2644
2594
  });
2645
2595
 
2646
2596
  this.signClient.on("session_update", async(session)=> {
2647
- 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])) {
2648
2598
  this.session = this.signClient.session.get(session.topic);
2649
2599
  await this.setSessionBlockchains();
2650
2600
  }
2651
2601
  });
2652
2602
 
2653
2603
  this.signClient.on("session_event", (event)=> {
2654
- 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])) {}
2655
2605
  });
2656
2606
 
2657
2607
  const connectWallet = async()=>{
@@ -2662,24 +2612,24 @@
2662
2612
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
2663
2613
  };
2664
2614
 
2665
- 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;
2666
2616
  if(lastSession) {
2667
2617
  this.session = lastSession;
2668
2618
  } else {
2669
2619
  await connectWallet();
2670
2620
  }
2671
2621
 
2672
- 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]);
2673
2623
  if(meta && meta.name) {
2674
2624
  this.name = meta.name;
2675
2625
  localStorage[KEY+':name'] = meta.name;
2676
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
2626
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
2677
2627
  this.logo = meta.icons[0];
2678
2628
  localStorage[KEY+':logo'] = this.logo;
2679
2629
  }
2680
2630
  }
2681
- if(_optionalChain$1([options, 'optionalAccess', _53 => _53.name])) { localStorage[KEY+':name'] = this.name = options.name; }
2682
- 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; }
2683
2633
 
2684
2634
  await this.setSessionBlockchains();
2685
2635
 
@@ -2736,7 +2686,7 @@
2736
2686
  switch (event) {
2737
2687
  case 'account':
2738
2688
  internalCallback = async(event)=> {
2739
- 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') {
2740
2690
  callback(await this.account());
2741
2691
  }
2742
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.2",
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",