@depay/web3-wallets-evm 16.0.2 → 16.0.4

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.
@@ -42199,10 +42199,18 @@ class Transaction {
42199
42199
  })
42200
42200
  }
42201
42201
 
42202
+ getParamType(param) {
42203
+ if(_optionalChain$l([param, 'optionalAccess', _5 => _5.components, 'optionalAccess', _6 => _6.length])) {
42204
+ return `(${param.components.map((param)=>this.getParamType(param)).join(',')})`
42205
+ } else {
42206
+ return param.type
42207
+ }
42208
+ }
42209
+
42202
42210
  getMethodNameWithSignature() {
42203
42211
  let fragment = this.findFragment();
42204
42212
  if(fragment.inputs) {
42205
- return `${this.method}(${fragment.inputs.map((input)=>input.type).join(',')})`
42213
+ return `${this.method}(${fragment.inputs.map((param)=>this.getParamType(param)).join(',')})`
42206
42214
  } else {
42207
42215
  return this.method
42208
42216
  }
@@ -44549,7 +44557,6 @@ const CONFIGURATIONS = {
44549
44557
  methods: [
44550
44558
  "eth_sendTransaction",
44551
44559
  "personal_sign",
44552
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
44553
44560
  "eth_signTypedData",
44554
44561
  "eth_signTypedData_v4",
44555
44562
  "wallet_switchEthereumChain"
@@ -44580,17 +44587,6 @@ const CONFIGURATIONS = {
44580
44587
  },
44581
44588
  };
44582
44589
 
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
44590
  const DEFAULT_CONFIGURATION = {
44595
44591
  events: ['accountsChanged'],
44596
44592
  methods: [
@@ -44700,51 +44696,13 @@ class WalletConnectV2 {
44700
44696
  }
44701
44697
  }
44702
44698
 
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
44699
  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();
44700
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
44701
+ 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
44702
  } 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);
44703
+ 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
44704
  } 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);
44705
+ 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
44706
  }
44749
44707
  }
44750
44708
 
@@ -44754,13 +44712,13 @@ class WalletConnectV2 {
44754
44712
 
44755
44713
  try {
44756
44714
 
44757
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
44715
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
44758
44716
 
44759
44717
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
44760
44718
  this.signClient = await getSignClient();
44761
44719
 
44762
44720
  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])) {
44721
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
44764
44722
  localStorage[KEY+':name'] = undefined;
44765
44723
  localStorage[KEY+':logo'] = undefined;
44766
44724
  this.signClient = undefined;
@@ -44769,14 +44727,14 @@ class WalletConnectV2 {
44769
44727
  });
44770
44728
 
44771
44729
  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])) {
44730
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
44773
44731
  this.session = this.signClient.session.get(session.topic);
44774
44732
  await this.setSessionBlockchains();
44775
44733
  }
44776
44734
  });
44777
44735
 
44778
44736
  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])) {}
44737
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
44780
44738
  });
44781
44739
 
44782
44740
  const connectWallet = async()=>{
@@ -44787,24 +44745,24 @@ class WalletConnectV2 {
44787
44745
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
44788
44746
  };
44789
44747
 
44790
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
44748
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
44791
44749
  if(lastSession) {
44792
44750
  this.session = lastSession;
44793
44751
  } else {
44794
44752
  await connectWallet();
44795
44753
  }
44796
44754
 
44797
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
44755
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
44798
44756
  if(meta && meta.name) {
44799
44757
  this.name = meta.name;
44800
44758
  localStorage[KEY+':name'] = meta.name;
44801
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
44759
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
44802
44760
  this.logo = meta.icons[0];
44803
44761
  localStorage[KEY+':logo'] = this.logo;
44804
44762
  }
44805
44763
  }
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; }
44764
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
44765
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
44808
44766
 
44809
44767
  await this.setSessionBlockchains();
44810
44768
 
@@ -44861,7 +44819,7 @@ class WalletConnectV2 {
44861
44819
  switch (event) {
44862
44820
  case 'account':
44863
44821
  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') {
44822
+ 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
44823
  callback(await this.account());
44866
44824
  }
44867
44825
  };
package/dist/esm/index.js CHANGED
@@ -70,10 +70,18 @@ class Transaction {
70
70
  })
71
71
  }
72
72
 
73
+ getParamType(param) {
74
+ if(_optionalChain$l([param, 'optionalAccess', _5 => _5.components, 'optionalAccess', _6 => _6.length])) {
75
+ return `(${param.components.map((param)=>this.getParamType(param)).join(',')})`
76
+ } else {
77
+ return param.type
78
+ }
79
+ }
80
+
73
81
  getMethodNameWithSignature() {
74
82
  let fragment = this.findFragment();
75
83
  if(fragment.inputs) {
76
- return `${this.method}(${fragment.inputs.map((input)=>input.type).join(',')})`
84
+ return `${this.method}(${fragment.inputs.map((param)=>this.getParamType(param)).join(',')})`
77
85
  } else {
78
86
  return this.method
79
87
  }
@@ -1586,7 +1594,6 @@ const CONFIGURATIONS = {
1586
1594
  methods: [
1587
1595
  "eth_sendTransaction",
1588
1596
  "personal_sign",
1589
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
1590
1597
  "eth_signTypedData",
1591
1598
  "eth_signTypedData_v4",
1592
1599
  "wallet_switchEthereumChain"
@@ -1617,17 +1624,6 @@ const CONFIGURATIONS = {
1617
1624
  },
1618
1625
  };
1619
1626
 
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
1627
  const DEFAULT_CONFIGURATION = {
1632
1628
  events: ['accountsChanged'],
1633
1629
  methods: [
@@ -1737,51 +1733,13 @@ class WalletConnectV2 {
1737
1733
  }
1738
1734
  }
1739
1735
 
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
1736
  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();
1737
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
1738
+ 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
1739
  } 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);
1740
+ 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
1741
  } 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);
1742
+ 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
1743
  }
1786
1744
  }
1787
1745
 
@@ -1791,13 +1749,13 @@ class WalletConnectV2 {
1791
1749
 
1792
1750
  try {
1793
1751
 
1794
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
1752
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
1795
1753
 
1796
1754
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
1797
1755
  this.signClient = await getSignClient();
1798
1756
 
1799
1757
  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])) {
1758
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
1801
1759
  localStorage[KEY+':name'] = undefined;
1802
1760
  localStorage[KEY+':logo'] = undefined;
1803
1761
  this.signClient = undefined;
@@ -1806,14 +1764,14 @@ class WalletConnectV2 {
1806
1764
  });
1807
1765
 
1808
1766
  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])) {
1767
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
1810
1768
  this.session = this.signClient.session.get(session.topic);
1811
1769
  await this.setSessionBlockchains();
1812
1770
  }
1813
1771
  });
1814
1772
 
1815
1773
  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])) {}
1774
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
1817
1775
  });
1818
1776
 
1819
1777
  const connectWallet = async()=>{
@@ -1824,24 +1782,24 @@ class WalletConnectV2 {
1824
1782
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
1825
1783
  };
1826
1784
 
1827
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
1785
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
1828
1786
  if(lastSession) {
1829
1787
  this.session = lastSession;
1830
1788
  } else {
1831
1789
  await connectWallet();
1832
1790
  }
1833
1791
 
1834
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
1792
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
1835
1793
  if(meta && meta.name) {
1836
1794
  this.name = meta.name;
1837
1795
  localStorage[KEY+':name'] = meta.name;
1838
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
1796
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
1839
1797
  this.logo = meta.icons[0];
1840
1798
  localStorage[KEY+':logo'] = this.logo;
1841
1799
  }
1842
1800
  }
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; }
1801
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
1802
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
1845
1803
 
1846
1804
  await this.setSessionBlockchains();
1847
1805
 
@@ -1898,7 +1856,7 @@ class WalletConnectV2 {
1898
1856
  switch (event) {
1899
1857
  case 'account':
1900
1858
  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') {
1859
+ 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
1860
  callback(await this.account());
1903
1861
  }
1904
1862
  };
@@ -70,10 +70,18 @@ class Transaction {
70
70
  })
71
71
  }
72
72
 
73
+ getParamType(param) {
74
+ if(_optionalChain$l([param, 'optionalAccess', _5 => _5.components, 'optionalAccess', _6 => _6.length])) {
75
+ return `(${param.components.map((param)=>this.getParamType(param)).join(',')})`
76
+ } else {
77
+ return param.type
78
+ }
79
+ }
80
+
73
81
  getMethodNameWithSignature() {
74
82
  let fragment = this.findFragment();
75
83
  if(fragment.inputs) {
76
- return `${this.method}(${fragment.inputs.map((input)=>input.type).join(',')})`
84
+ return `${this.method}(${fragment.inputs.map((param)=>this.getParamType(param)).join(',')})`
77
85
  } else {
78
86
  return this.method
79
87
  }
@@ -2422,7 +2430,6 @@ const CONFIGURATIONS = {
2422
2430
  methods: [
2423
2431
  "eth_sendTransaction",
2424
2432
  "personal_sign",
2425
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
2426
2433
  "eth_signTypedData",
2427
2434
  "eth_signTypedData_v4",
2428
2435
  "wallet_switchEthereumChain"
@@ -2453,17 +2460,6 @@ const CONFIGURATIONS = {
2453
2460
  },
2454
2461
  };
2455
2462
 
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
2463
  const DEFAULT_CONFIGURATION = {
2468
2464
  events: ['accountsChanged'],
2469
2465
  methods: [
@@ -2573,51 +2569,13 @@ class WalletConnectV2 {
2573
2569
  }
2574
2570
  }
2575
2571
 
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
2572
  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();
2573
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
2574
+ 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
2575
  } 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);
2576
+ 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
2577
  } 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);
2578
+ 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
2579
  }
2622
2580
  }
2623
2581
 
@@ -2627,13 +2585,13 @@ class WalletConnectV2 {
2627
2585
 
2628
2586
  try {
2629
2587
 
2630
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
2588
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
2631
2589
 
2632
2590
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
2633
2591
  this.signClient = await getSignClient();
2634
2592
 
2635
2593
  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])) {
2594
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
2637
2595
  localStorage[KEY+':name'] = undefined;
2638
2596
  localStorage[KEY+':logo'] = undefined;
2639
2597
  this.signClient = undefined;
@@ -2642,14 +2600,14 @@ class WalletConnectV2 {
2642
2600
  });
2643
2601
 
2644
2602
  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])) {
2603
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
2646
2604
  this.session = this.signClient.session.get(session.topic);
2647
2605
  await this.setSessionBlockchains();
2648
2606
  }
2649
2607
  });
2650
2608
 
2651
2609
  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])) {}
2610
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
2653
2611
  });
2654
2612
 
2655
2613
  const connectWallet = async()=>{
@@ -2660,24 +2618,24 @@ class WalletConnectV2 {
2660
2618
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
2661
2619
  };
2662
2620
 
2663
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
2621
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
2664
2622
  if(lastSession) {
2665
2623
  this.session = lastSession;
2666
2624
  } else {
2667
2625
  await connectWallet();
2668
2626
  }
2669
2627
 
2670
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
2628
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
2671
2629
  if(meta && meta.name) {
2672
2630
  this.name = meta.name;
2673
2631
  localStorage[KEY+':name'] = meta.name;
2674
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
2632
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
2675
2633
  this.logo = meta.icons[0];
2676
2634
  localStorage[KEY+':logo'] = this.logo;
2677
2635
  }
2678
2636
  }
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; }
2637
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
2638
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
2681
2639
 
2682
2640
  await this.setSessionBlockchains();
2683
2641
 
@@ -2734,7 +2692,7 @@ class WalletConnectV2 {
2734
2692
  switch (event) {
2735
2693
  case 'account':
2736
2694
  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') {
2695
+ 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
2696
  callback(await this.account());
2739
2697
  }
2740
2698
  };
@@ -42202,10 +42202,18 @@
42202
42202
  })
42203
42203
  }
42204
42204
 
42205
+ getParamType(param) {
42206
+ if(_optionalChain$l([param, 'optionalAccess', _5 => _5.components, 'optionalAccess', _6 => _6.length])) {
42207
+ return `(${param.components.map((param)=>this.getParamType(param)).join(',')})`
42208
+ } else {
42209
+ return param.type
42210
+ }
42211
+ }
42212
+
42205
42213
  getMethodNameWithSignature() {
42206
42214
  let fragment = this.findFragment();
42207
42215
  if(fragment.inputs) {
42208
- return `${this.method}(${fragment.inputs.map((input)=>input.type).join(',')})`
42216
+ return `${this.method}(${fragment.inputs.map((param)=>this.getParamType(param)).join(',')})`
42209
42217
  } else {
42210
42218
  return this.method
42211
42219
  }
@@ -44552,7 +44560,6 @@
44552
44560
  methods: [
44553
44561
  "eth_sendTransaction",
44554
44562
  "personal_sign",
44555
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
44556
44563
  "eth_signTypedData",
44557
44564
  "eth_signTypedData_v4",
44558
44565
  "wallet_switchEthereumChain"
@@ -44583,17 +44590,6 @@
44583
44590
  },
44584
44591
  };
44585
44592
 
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
44593
  const DEFAULT_CONFIGURATION = {
44598
44594
  events: ['accountsChanged'],
44599
44595
  methods: [
@@ -44703,51 +44699,13 @@
44703
44699
  }
44704
44700
  }
44705
44701
 
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
44702
  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();
44703
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
44704
+ 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
44705
  } 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);
44706
+ 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
44707
  } 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);
44708
+ 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
44709
  }
44752
44710
  }
44753
44711
 
@@ -44757,13 +44715,13 @@
44757
44715
 
44758
44716
  try {
44759
44717
 
44760
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
44718
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
44761
44719
 
44762
44720
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
44763
44721
  this.signClient = await getSignClient();
44764
44722
 
44765
44723
  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])) {
44724
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
44767
44725
  localStorage[KEY+':name'] = undefined;
44768
44726
  localStorage[KEY+':logo'] = undefined;
44769
44727
  this.signClient = undefined;
@@ -44772,14 +44730,14 @@
44772
44730
  });
44773
44731
 
44774
44732
  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])) {
44733
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
44776
44734
  this.session = this.signClient.session.get(session.topic);
44777
44735
  await this.setSessionBlockchains();
44778
44736
  }
44779
44737
  });
44780
44738
 
44781
44739
  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])) {}
44740
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
44783
44741
  });
44784
44742
 
44785
44743
  const connectWallet = async()=>{
@@ -44790,24 +44748,24 @@
44790
44748
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
44791
44749
  };
44792
44750
 
44793
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
44751
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
44794
44752
  if(lastSession) {
44795
44753
  this.session = lastSession;
44796
44754
  } else {
44797
44755
  await connectWallet();
44798
44756
  }
44799
44757
 
44800
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
44758
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
44801
44759
  if(meta && meta.name) {
44802
44760
  this.name = meta.name;
44803
44761
  localStorage[KEY+':name'] = meta.name;
44804
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
44762
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
44805
44763
  this.logo = meta.icons[0];
44806
44764
  localStorage[KEY+':logo'] = this.logo;
44807
44765
  }
44808
44766
  }
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; }
44767
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
44768
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
44811
44769
 
44812
44770
  await this.setSessionBlockchains();
44813
44771
 
@@ -44864,7 +44822,7 @@
44864
44822
  switch (event) {
44865
44823
  case 'account':
44866
44824
  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') {
44825
+ 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
44826
  callback(await this.account());
44869
44827
  }
44870
44828
  };
package/dist/umd/index.js CHANGED
@@ -72,10 +72,18 @@
72
72
  })
73
73
  }
74
74
 
75
+ getParamType(param) {
76
+ if(_optionalChain$l([param, 'optionalAccess', _5 => _5.components, 'optionalAccess', _6 => _6.length])) {
77
+ return `(${param.components.map((param)=>this.getParamType(param)).join(',')})`
78
+ } else {
79
+ return param.type
80
+ }
81
+ }
82
+
75
83
  getMethodNameWithSignature() {
76
84
  let fragment = this.findFragment();
77
85
  if(fragment.inputs) {
78
- return `${this.method}(${fragment.inputs.map((input)=>input.type).join(',')})`
86
+ return `${this.method}(${fragment.inputs.map((param)=>this.getParamType(param)).join(',')})`
79
87
  } else {
80
88
  return this.method
81
89
  }
@@ -1588,7 +1596,6 @@
1588
1596
  methods: [
1589
1597
  "eth_sendTransaction",
1590
1598
  "personal_sign",
1591
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
1592
1599
  "eth_signTypedData",
1593
1600
  "eth_signTypedData_v4",
1594
1601
  "wallet_switchEthereumChain"
@@ -1619,17 +1626,6 @@
1619
1626
  },
1620
1627
  };
1621
1628
 
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
1629
  const DEFAULT_CONFIGURATION = {
1634
1630
  events: ['accountsChanged'],
1635
1631
  methods: [
@@ -1739,51 +1735,13 @@
1739
1735
  }
1740
1736
  }
1741
1737
 
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
1738
  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();
1739
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
1740
+ 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
1741
  } 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);
1742
+ 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
1743
  } 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);
1744
+ 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
1745
  }
1788
1746
  }
1789
1747
 
@@ -1793,13 +1751,13 @@
1793
1751
 
1794
1752
  try {
1795
1753
 
1796
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
1754
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
1797
1755
 
1798
1756
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
1799
1757
  this.signClient = await getSignClient();
1800
1758
 
1801
1759
  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])) {
1760
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
1803
1761
  localStorage[KEY+':name'] = undefined;
1804
1762
  localStorage[KEY+':logo'] = undefined;
1805
1763
  this.signClient = undefined;
@@ -1808,14 +1766,14 @@
1808
1766
  });
1809
1767
 
1810
1768
  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])) {
1769
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
1812
1770
  this.session = this.signClient.session.get(session.topic);
1813
1771
  await this.setSessionBlockchains();
1814
1772
  }
1815
1773
  });
1816
1774
 
1817
1775
  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])) {}
1776
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
1819
1777
  });
1820
1778
 
1821
1779
  const connectWallet = async()=>{
@@ -1826,24 +1784,24 @@
1826
1784
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
1827
1785
  };
1828
1786
 
1829
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
1787
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
1830
1788
  if(lastSession) {
1831
1789
  this.session = lastSession;
1832
1790
  } else {
1833
1791
  await connectWallet();
1834
1792
  }
1835
1793
 
1836
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
1794
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
1837
1795
  if(meta && meta.name) {
1838
1796
  this.name = meta.name;
1839
1797
  localStorage[KEY+':name'] = meta.name;
1840
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
1798
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
1841
1799
  this.logo = meta.icons[0];
1842
1800
  localStorage[KEY+':logo'] = this.logo;
1843
1801
  }
1844
1802
  }
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; }
1803
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
1804
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
1847
1805
 
1848
1806
  await this.setSessionBlockchains();
1849
1807
 
@@ -1900,7 +1858,7 @@
1900
1858
  switch (event) {
1901
1859
  case 'account':
1902
1860
  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') {
1861
+ 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
1862
  callback(await this.account());
1905
1863
  }
1906
1864
  };
@@ -72,10 +72,18 @@
72
72
  })
73
73
  }
74
74
 
75
+ getParamType(param) {
76
+ if(_optionalChain$l([param, 'optionalAccess', _5 => _5.components, 'optionalAccess', _6 => _6.length])) {
77
+ return `(${param.components.map((param)=>this.getParamType(param)).join(',')})`
78
+ } else {
79
+ return param.type
80
+ }
81
+ }
82
+
75
83
  getMethodNameWithSignature() {
76
84
  let fragment = this.findFragment();
77
85
  if(fragment.inputs) {
78
- return `${this.method}(${fragment.inputs.map((input)=>input.type).join(',')})`
86
+ return `${this.method}(${fragment.inputs.map((param)=>this.getParamType(param)).join(',')})`
79
87
  } else {
80
88
  return this.method
81
89
  }
@@ -2424,7 +2432,6 @@
2424
2432
  methods: [
2425
2433
  "eth_sendTransaction",
2426
2434
  "personal_sign",
2427
- "eth_chainId", // only add eth_chainId if you do not trust the wallet provided chainIds!
2428
2435
  "eth_signTypedData",
2429
2436
  "eth_signTypedData_v4",
2430
2437
  "wallet_switchEthereumChain"
@@ -2455,17 +2462,6 @@
2455
2462
  },
2456
2463
  };
2457
2464
 
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
2465
  const DEFAULT_CONFIGURATION = {
2470
2466
  events: ['accountsChanged'],
2471
2467
  methods: [
@@ -2575,51 +2571,13 @@
2575
2571
  }
2576
2572
  }
2577
2573
 
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
2574
  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();
2575
+ if(_optionalChain$1([CONFIGURATIONS, 'access', _27 => _27[this.walletName], 'optionalAccess', _28 => _28.methods, 'optionalAccess', _29 => _29.includes, 'call', _30 => _30('wallet_switchEthereumChain')])) {
2576
+ 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
2577
  } 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);
2578
+ 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
2579
  } 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);
2580
+ 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
2581
  }
2624
2582
  }
2625
2583
 
@@ -2629,13 +2587,13 @@
2629
2587
 
2630
2588
  try {
2631
2589
 
2632
- this.walletName = _optionalChain$1([options, 'optionalAccess', _37 => _37.name]);
2590
+ this.walletName = _optionalChain$1([options, 'optionalAccess', _40 => _40.name]);
2633
2591
 
2634
2592
  // delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
2635
2593
  this.signClient = await getSignClient();
2636
2594
 
2637
2595
  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])) {
2596
+ if(_optionalChain$1([session, 'optionalAccess', _41 => _41.topic]) === _optionalChain$1([this, 'access', _42 => _42.session, 'optionalAccess', _43 => _43.topic])) {
2639
2597
  localStorage[KEY+':name'] = undefined;
2640
2598
  localStorage[KEY+':logo'] = undefined;
2641
2599
  this.signClient = undefined;
@@ -2644,14 +2602,14 @@
2644
2602
  });
2645
2603
 
2646
2604
  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])) {
2605
+ if(_optionalChain$1([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$1([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
2648
2606
  this.session = this.signClient.session.get(session.topic);
2649
2607
  await this.setSessionBlockchains();
2650
2608
  }
2651
2609
  });
2652
2610
 
2653
2611
  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])) {}
2612
+ if(_optionalChain$1([event, 'optionalAccess', _47 => _47.topic]) === _optionalChain$1([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {}
2655
2613
  });
2656
2614
 
2657
2615
  const connectWallet = async()=>{
@@ -2662,24 +2620,24 @@
2662
2620
  await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
2663
2621
  };
2664
2622
 
2665
- const lastSession = _optionalChain$1([this, 'optionalAccess', _47 => _47.walletName, 'optionalAccess', _48 => _48.length]) ? await getLastSession(this.walletName) : undefined;
2623
+ const lastSession = _optionalChain$1([this, 'optionalAccess', _50 => _50.walletName, 'optionalAccess', _51 => _51.length]) ? await getLastSession(this.walletName) : undefined;
2666
2624
  if(lastSession) {
2667
2625
  this.session = lastSession;
2668
2626
  } else {
2669
2627
  await connectWallet();
2670
2628
  }
2671
2629
 
2672
- let meta = _optionalChain$1([this, 'access', _49 => _49.session, 'optionalAccess', _50 => _50.peer, 'optionalAccess', _51 => _51.metadata]);
2630
+ let meta = _optionalChain$1([this, 'access', _52 => _52.session, 'optionalAccess', _53 => _53.peer, 'optionalAccess', _54 => _54.metadata]);
2673
2631
  if(meta && meta.name) {
2674
2632
  this.name = meta.name;
2675
2633
  localStorage[KEY+':name'] = meta.name;
2676
- if(_optionalChain$1([meta, 'optionalAccess', _52 => _52.icons]) && meta.icons.length) {
2634
+ if(_optionalChain$1([meta, 'optionalAccess', _55 => _55.icons]) && meta.icons.length) {
2677
2635
  this.logo = meta.icons[0];
2678
2636
  localStorage[KEY+':logo'] = this.logo;
2679
2637
  }
2680
2638
  }
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; }
2639
+ if(_optionalChain$1([options, 'optionalAccess', _56 => _56.name])) { localStorage[KEY+':name'] = this.name = options.name; }
2640
+ if(_optionalChain$1([options, 'optionalAccess', _57 => _57.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
2683
2641
 
2684
2642
  await this.setSessionBlockchains();
2685
2643
 
@@ -2736,7 +2694,7 @@
2736
2694
  switch (event) {
2737
2695
  case 'account':
2738
2696
  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') {
2697
+ 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
2698
  callback(await this.account());
2741
2699
  }
2742
2700
  };
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.4",
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",