@depay/web3-wallets-evm 15.15.1 → 15.15.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.
@@ -2,7 +2,7 @@ import { getProvider as getProvider$3, request as request$1, estimate as estimat
2
2
  import Blockchains from '@depay/web3-blockchains';
3
3
  import { ethers } from 'ethers';
4
4
  import { WalletConnectClient } from '@depay/walletconnect-v1';
5
- import { Core, SignClient } from '@depay/walletconnect-v2';
5
+ import { SignClient, Core } from '@depay/walletconnect-v2';
6
6
  import { CoinbaseWalletSDK } from '@depay/coinbase-wallet-sdk';
7
7
 
8
8
  var _global$1 = (typeof global !== "undefined" ? global :
@@ -44515,7 +44515,7 @@ const KEY = 'depay:wallets:wc2';
44515
44515
 
44516
44516
  const getLastSession = async()=>{
44517
44517
  if(!localStorage[KEY+":projectId"]) { return }
44518
- let signClient = await getSignClient(new Core({ projectId: localStorage[KEY+":projectId"] }));
44518
+ let signClient = await getSignClient();
44519
44519
  const existingSessions = signClient.find(getWalletConnectV2Config());
44520
44520
  const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
44521
44521
  if(lastSession && lastSession.expiry > Math.ceil(Date.now()/1000)) {
@@ -44583,16 +44583,22 @@ const getWalletConnectV2Config = ()=>{
44583
44583
  return { requiredNamespaces, optionalNamespaces }
44584
44584
  };
44585
44585
 
44586
- const getSignClient = async(core)=>{
44587
- return await SignClient.init({
44588
- core,
44589
- metadata: {
44590
- name: document.title || 'dApp',
44591
- description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
44592
- url: location.href,
44593
- icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
44594
- }
44595
- })
44586
+ const getSignClient = ()=>{
44587
+ if(window.getSignClientPromise) { return window.getSignClientPromise }
44588
+ window.getSignClientPromise = new Promise(async(resolve)=>{
44589
+ const signClient = await SignClient.init({
44590
+ core: new Core({ projectId: localStorage[KEY+":projectId"] }),
44591
+ metadata: {
44592
+ name: document.title || 'dApp',
44593
+ description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
44594
+ url: location.href,
44595
+ icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
44596
+ }
44597
+ });
44598
+ resolve(signClient);
44599
+ });
44600
+
44601
+ return window.getSignClientPromise
44596
44602
  };
44597
44603
 
44598
44604
  class WalletConnectV2 {
@@ -44611,8 +44617,6 @@ class WalletConnectV2 {
44611
44617
  this.name = (localStorage[KEY+':name'] && localStorage[KEY+':name'] != undefined) ? localStorage[KEY+':name'] : this.constructor.info.name;
44612
44618
  this.logo = (localStorage[KEY+':logo'] && localStorage[KEY+':logo'] != undefined) ? localStorage[KEY+':logo'] : this.constructor.info.logo;
44613
44619
  this.blockchains = this.constructor.info.blockchains;
44614
- this.connector = WalletConnect.instance || this.newWalletConnectInstance();
44615
- WalletConnect.instance = this.connector;
44616
44620
  this.sendTransaction = (transaction)=>{
44617
44621
  return sendTransaction$2({
44618
44622
  wallet: this,
@@ -44621,11 +44625,6 @@ class WalletConnectV2 {
44621
44625
  };
44622
44626
  }
44623
44627
 
44624
- newWalletConnectInstance() {
44625
- if(!localStorage[KEY+":projectId"]) { throw(`localStorage['${KEY+":projectId"}'] is not set!`) }
44626
- return new Core({ projectId: localStorage[KEY+":projectId"] })
44627
- }
44628
-
44629
44628
  async account() {
44630
44629
  const connectedChainId = await getConnectedChainId(this.signClient, this.session);
44631
44630
  const connectedBlockchain = Blockchains.findById(connectedChainId);
@@ -44647,13 +44646,12 @@ class WalletConnectV2 {
44647
44646
  try {
44648
44647
 
44649
44648
  // delete localStorage[`wc@2:client:0.3//session`] // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
44650
- this.signClient = await getSignClient(this.connector);
44649
+ this.signClient = await getSignClient();
44651
44650
 
44652
44651
  this.signClient.on("session_delete", (session)=> {
44653
44652
  if(_optionalChain([session, 'optionalAccess', _8 => _8.topic]) === _optionalChain([this, 'access', _9 => _9.session, 'optionalAccess', _10 => _10.topic])) {
44654
44653
  localStorage[KEY+':name'] = undefined;
44655
44654
  localStorage[KEY+':logo'] = undefined;
44656
- this.connector = undefined;
44657
44655
  WalletConnect.instance = undefined;
44658
44656
  this.signClient = undefined;
44659
44657
  this.session = undefined;
@@ -45066,10 +45064,10 @@ const getWallets = async(args)=>{
45066
45064
 
45067
45065
  if(wallet.getConnectedInstance) {
45068
45066
  instance = await wallet.getConnectedInstance();
45069
- if(drip) { drip(instance); }
45067
+ if(drip && instance) { drip(instance); }
45070
45068
  return instance
45071
45069
  } else {
45072
- if(drip) { drip(wallet); }
45070
+ if(drip && wallet) { drip(wallet); }
45073
45071
  return new wallet
45074
45072
  }
45075
45073
  }
package/dist/esm/index.js CHANGED
@@ -3,7 +3,7 @@ import Blockchains from '@depay/web3-blockchains';
3
3
  import { PublicKey, SystemProgram, TransactionMessage, VersionedTransaction, transact } from '@depay/solana-web3.js';
4
4
  import { ethers } from 'ethers';
5
5
  import { WalletConnectClient } from '@depay/walletconnect-v1';
6
- import { Core, SignClient } from '@depay/walletconnect-v2';
6
+ import { SignClient, Core } from '@depay/walletconnect-v2';
7
7
  import { CoinbaseWalletSDK } from '@depay/coinbase-wallet-sdk';
8
8
 
9
9
  function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
@@ -1552,7 +1552,7 @@ const KEY = 'depay:wallets:wc2';
1552
1552
 
1553
1553
  const getLastSession = async()=>{
1554
1554
  if(!localStorage[KEY+":projectId"]) { return }
1555
- let signClient = await getSignClient(new Core({ projectId: localStorage[KEY+":projectId"] }));
1555
+ let signClient = await getSignClient();
1556
1556
  const existingSessions = signClient.find(getWalletConnectV2Config());
1557
1557
  const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
1558
1558
  if(lastSession && lastSession.expiry > Math.ceil(Date.now()/1000)) {
@@ -1620,16 +1620,22 @@ const getWalletConnectV2Config = ()=>{
1620
1620
  return { requiredNamespaces, optionalNamespaces }
1621
1621
  };
1622
1622
 
1623
- const getSignClient = async(core)=>{
1624
- return await SignClient.init({
1625
- core,
1626
- metadata: {
1627
- name: document.title || 'dApp',
1628
- description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
1629
- url: location.href,
1630
- icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
1631
- }
1632
- })
1623
+ const getSignClient = ()=>{
1624
+ if(window.getSignClientPromise) { return window.getSignClientPromise }
1625
+ window.getSignClientPromise = new Promise(async(resolve)=>{
1626
+ const signClient = await SignClient.init({
1627
+ core: new Core({ projectId: localStorage[KEY+":projectId"] }),
1628
+ metadata: {
1629
+ name: document.title || 'dApp',
1630
+ description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
1631
+ url: location.href,
1632
+ icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
1633
+ }
1634
+ });
1635
+ resolve(signClient);
1636
+ });
1637
+
1638
+ return window.getSignClientPromise
1633
1639
  };
1634
1640
 
1635
1641
  class WalletConnectV2 {
@@ -1648,8 +1654,6 @@ class WalletConnectV2 {
1648
1654
  this.name = (localStorage[KEY+':name'] && localStorage[KEY+':name'] != undefined) ? localStorage[KEY+':name'] : this.constructor.info.name;
1649
1655
  this.logo = (localStorage[KEY+':logo'] && localStorage[KEY+':logo'] != undefined) ? localStorage[KEY+':logo'] : this.constructor.info.logo;
1650
1656
  this.blockchains = this.constructor.info.blockchains;
1651
- this.connector = WalletConnect.instance || this.newWalletConnectInstance();
1652
- WalletConnect.instance = this.connector;
1653
1657
  this.sendTransaction = (transaction)=>{
1654
1658
  return sendTransaction$1({
1655
1659
  wallet: this,
@@ -1658,11 +1662,6 @@ class WalletConnectV2 {
1658
1662
  };
1659
1663
  }
1660
1664
 
1661
- newWalletConnectInstance() {
1662
- if(!localStorage[KEY+":projectId"]) { throw(`localStorage['${KEY+":projectId"}'] is not set!`) }
1663
- return new Core({ projectId: localStorage[KEY+":projectId"] })
1664
- }
1665
-
1666
1665
  async account() {
1667
1666
  const connectedChainId = await getConnectedChainId(this.signClient, this.session);
1668
1667
  const connectedBlockchain = Blockchains.findById(connectedChainId);
@@ -1684,13 +1683,12 @@ class WalletConnectV2 {
1684
1683
  try {
1685
1684
 
1686
1685
  // delete localStorage[`wc@2:client:0.3//session`] // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
1687
- this.signClient = await getSignClient(this.connector);
1686
+ this.signClient = await getSignClient();
1688
1687
 
1689
1688
  this.signClient.on("session_delete", (session)=> {
1690
1689
  if(_optionalChain([session, 'optionalAccess', _8 => _8.topic]) === _optionalChain([this, 'access', _9 => _9.session, 'optionalAccess', _10 => _10.topic])) {
1691
1690
  localStorage[KEY+':name'] = undefined;
1692
1691
  localStorage[KEY+':logo'] = undefined;
1693
- this.connector = undefined;
1694
1692
  WalletConnect.instance = undefined;
1695
1693
  this.signClient = undefined;
1696
1694
  this.session = undefined;
@@ -2103,10 +2101,10 @@ const getWallets = async(args)=>{
2103
2101
 
2104
2102
  if(wallet.getConnectedInstance) {
2105
2103
  instance = await wallet.getConnectedInstance();
2106
- if(drip) { drip(instance); }
2104
+ if(drip && instance) { drip(instance); }
2107
2105
  return instance
2108
2106
  } else {
2109
- if(drip) { drip(wallet); }
2107
+ if(drip && wallet) { drip(wallet); }
2110
2108
  return new wallet
2111
2109
  }
2112
2110
  }
@@ -3,7 +3,7 @@ import Blockchains from '@depay/web3-blockchains';
3
3
  import { PublicKey, SystemProgram, TransactionMessage, VersionedTransaction, ACCOUNT_LAYOUT, Connection, transact } from '@depay/solana-web3.js';
4
4
  import { ethers } from 'ethers';
5
5
  import { WalletConnectClient } from '@depay/walletconnect-v1';
6
- import { Core, SignClient } from '@depay/walletconnect-v2';
6
+ import { SignClient, Core } from '@depay/walletconnect-v2';
7
7
  import { CoinbaseWalletSDK } from '@depay/coinbase-wallet-sdk';
8
8
 
9
9
  function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
@@ -2388,7 +2388,7 @@ const KEY = 'depay:wallets:wc2';
2388
2388
 
2389
2389
  const getLastSession = async()=>{
2390
2390
  if(!localStorage[KEY+":projectId"]) { return }
2391
- let signClient = await getSignClient(new Core({ projectId: localStorage[KEY+":projectId"] }));
2391
+ let signClient = await getSignClient();
2392
2392
  const existingSessions = signClient.find(getWalletConnectV2Config());
2393
2393
  const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
2394
2394
  if(lastSession && lastSession.expiry > Math.ceil(Date.now()/1000)) {
@@ -2456,16 +2456,22 @@ const getWalletConnectV2Config = ()=>{
2456
2456
  return { requiredNamespaces, optionalNamespaces }
2457
2457
  };
2458
2458
 
2459
- const getSignClient = async(core)=>{
2460
- return await SignClient.init({
2461
- core,
2462
- metadata: {
2463
- name: document.title || 'dApp',
2464
- description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
2465
- url: location.href,
2466
- icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
2467
- }
2468
- })
2459
+ const getSignClient = ()=>{
2460
+ if(window.getSignClientPromise) { return window.getSignClientPromise }
2461
+ window.getSignClientPromise = new Promise(async(resolve)=>{
2462
+ const signClient = await SignClient.init({
2463
+ core: new Core({ projectId: localStorage[KEY+":projectId"] }),
2464
+ metadata: {
2465
+ name: document.title || 'dApp',
2466
+ description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
2467
+ url: location.href,
2468
+ icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
2469
+ }
2470
+ });
2471
+ resolve(signClient);
2472
+ });
2473
+
2474
+ return window.getSignClientPromise
2469
2475
  };
2470
2476
 
2471
2477
  class WalletConnectV2 {
@@ -2484,8 +2490,6 @@ class WalletConnectV2 {
2484
2490
  this.name = (localStorage[KEY+':name'] && localStorage[KEY+':name'] != undefined) ? localStorage[KEY+':name'] : this.constructor.info.name;
2485
2491
  this.logo = (localStorage[KEY+':logo'] && localStorage[KEY+':logo'] != undefined) ? localStorage[KEY+':logo'] : this.constructor.info.logo;
2486
2492
  this.blockchains = this.constructor.info.blockchains;
2487
- this.connector = WalletConnect.instance || this.newWalletConnectInstance();
2488
- WalletConnect.instance = this.connector;
2489
2493
  this.sendTransaction = (transaction)=>{
2490
2494
  return sendTransaction$1({
2491
2495
  wallet: this,
@@ -2494,11 +2498,6 @@ class WalletConnectV2 {
2494
2498
  };
2495
2499
  }
2496
2500
 
2497
- newWalletConnectInstance() {
2498
- if(!localStorage[KEY+":projectId"]) { throw(`localStorage['${KEY+":projectId"}'] is not set!`) }
2499
- return new Core({ projectId: localStorage[KEY+":projectId"] })
2500
- }
2501
-
2502
2501
  async account() {
2503
2502
  const connectedChainId = await getConnectedChainId(this.signClient, this.session);
2504
2503
  const connectedBlockchain = Blockchains.findById(connectedChainId);
@@ -2520,13 +2519,12 @@ class WalletConnectV2 {
2520
2519
  try {
2521
2520
 
2522
2521
  // delete localStorage[`wc@2:client:0.3//session`] // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
2523
- this.signClient = await getSignClient(this.connector);
2522
+ this.signClient = await getSignClient();
2524
2523
 
2525
2524
  this.signClient.on("session_delete", (session)=> {
2526
2525
  if(_optionalChain([session, 'optionalAccess', _8 => _8.topic]) === _optionalChain([this, 'access', _9 => _9.session, 'optionalAccess', _10 => _10.topic])) {
2527
2526
  localStorage[KEY+':name'] = undefined;
2528
2527
  localStorage[KEY+':logo'] = undefined;
2529
- this.connector = undefined;
2530
2528
  WalletConnect.instance = undefined;
2531
2529
  this.signClient = undefined;
2532
2530
  this.session = undefined;
@@ -2939,10 +2937,10 @@ const getWallets = async(args)=>{
2939
2937
 
2940
2938
  if(wallet.getConnectedInstance) {
2941
2939
  instance = await wallet.getConnectedInstance();
2942
- if(drip) { drip(instance); }
2940
+ if(drip && instance) { drip(instance); }
2943
2941
  return instance
2944
2942
  } else {
2945
- if(drip) { drip(wallet); }
2943
+ if(drip && wallet) { drip(wallet); }
2946
2944
  return new wallet
2947
2945
  }
2948
2946
  }
@@ -44518,7 +44518,7 @@
44518
44518
 
44519
44519
  const getLastSession = async()=>{
44520
44520
  if(!localStorage[KEY+":projectId"]) { return }
44521
- let signClient = await getSignClient(new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] }));
44521
+ let signClient = await getSignClient();
44522
44522
  const existingSessions = signClient.find(getWalletConnectV2Config());
44523
44523
  const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
44524
44524
  if(lastSession && lastSession.expiry > Math.ceil(Date.now()/1000)) {
@@ -44586,16 +44586,22 @@
44586
44586
  return { requiredNamespaces, optionalNamespaces }
44587
44587
  };
44588
44588
 
44589
- const getSignClient = async(core)=>{
44590
- return await walletconnectV2.SignClient.init({
44591
- core,
44592
- metadata: {
44593
- name: document.title || 'dApp',
44594
- description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
44595
- url: location.href,
44596
- icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
44597
- }
44598
- })
44589
+ const getSignClient = ()=>{
44590
+ if(window.getSignClientPromise) { return window.getSignClientPromise }
44591
+ window.getSignClientPromise = new Promise(async(resolve)=>{
44592
+ const signClient = await walletconnectV2.SignClient.init({
44593
+ core: new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] }),
44594
+ metadata: {
44595
+ name: document.title || 'dApp',
44596
+ description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
44597
+ url: location.href,
44598
+ icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
44599
+ }
44600
+ });
44601
+ resolve(signClient);
44602
+ });
44603
+
44604
+ return window.getSignClientPromise
44599
44605
  };
44600
44606
 
44601
44607
  class WalletConnectV2 {
@@ -44614,8 +44620,6 @@
44614
44620
  this.name = (localStorage[KEY+':name'] && localStorage[KEY+':name'] != undefined) ? localStorage[KEY+':name'] : this.constructor.info.name;
44615
44621
  this.logo = (localStorage[KEY+':logo'] && localStorage[KEY+':logo'] != undefined) ? localStorage[KEY+':logo'] : this.constructor.info.logo;
44616
44622
  this.blockchains = this.constructor.info.blockchains;
44617
- this.connector = WalletConnect.instance || this.newWalletConnectInstance();
44618
- WalletConnect.instance = this.connector;
44619
44623
  this.sendTransaction = (transaction)=>{
44620
44624
  return sendTransaction$2({
44621
44625
  wallet: this,
@@ -44624,11 +44628,6 @@
44624
44628
  };
44625
44629
  }
44626
44630
 
44627
- newWalletConnectInstance() {
44628
- if(!localStorage[KEY+":projectId"]) { throw(`localStorage['${KEY+":projectId"}'] is not set!`) }
44629
- return new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] })
44630
- }
44631
-
44632
44631
  async account() {
44633
44632
  const connectedChainId = await getConnectedChainId(this.signClient, this.session);
44634
44633
  const connectedBlockchain = Blockchains__default['default'].findById(connectedChainId);
@@ -44650,13 +44649,12 @@
44650
44649
  try {
44651
44650
 
44652
44651
  // delete localStorage[`wc@2:client:0.3//session`] // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
44653
- this.signClient = await getSignClient(this.connector);
44652
+ this.signClient = await getSignClient();
44654
44653
 
44655
44654
  this.signClient.on("session_delete", (session)=> {
44656
44655
  if(_optionalChain([session, 'optionalAccess', _8 => _8.topic]) === _optionalChain([this, 'access', _9 => _9.session, 'optionalAccess', _10 => _10.topic])) {
44657
44656
  localStorage[KEY+':name'] = undefined;
44658
44657
  localStorage[KEY+':logo'] = undefined;
44659
- this.connector = undefined;
44660
44658
  WalletConnect.instance = undefined;
44661
44659
  this.signClient = undefined;
44662
44660
  this.session = undefined;
@@ -45069,10 +45067,10 @@
45069
45067
 
45070
45068
  if(wallet.getConnectedInstance) {
45071
45069
  instance = await wallet.getConnectedInstance();
45072
- if(drip) { drip(instance); }
45070
+ if(drip && instance) { drip(instance); }
45073
45071
  return instance
45074
45072
  } else {
45075
- if(drip) { drip(wallet); }
45073
+ if(drip && wallet) { drip(wallet); }
45076
45074
  return new wallet
45077
45075
  }
45078
45076
  }
package/dist/umd/index.js CHANGED
@@ -1554,7 +1554,7 @@
1554
1554
 
1555
1555
  const getLastSession = async()=>{
1556
1556
  if(!localStorage[KEY+":projectId"]) { return }
1557
- let signClient = await getSignClient(new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] }));
1557
+ let signClient = await getSignClient();
1558
1558
  const existingSessions = signClient.find(getWalletConnectV2Config());
1559
1559
  const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
1560
1560
  if(lastSession && lastSession.expiry > Math.ceil(Date.now()/1000)) {
@@ -1622,16 +1622,22 @@
1622
1622
  return { requiredNamespaces, optionalNamespaces }
1623
1623
  };
1624
1624
 
1625
- const getSignClient = async(core)=>{
1626
- return await walletconnectV2.SignClient.init({
1627
- core,
1628
- metadata: {
1629
- name: document.title || 'dApp',
1630
- description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
1631
- url: location.href,
1632
- icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
1633
- }
1634
- })
1625
+ const getSignClient = ()=>{
1626
+ if(window.getSignClientPromise) { return window.getSignClientPromise }
1627
+ window.getSignClientPromise = new Promise(async(resolve)=>{
1628
+ const signClient = await walletconnectV2.SignClient.init({
1629
+ core: new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] }),
1630
+ metadata: {
1631
+ name: document.title || 'dApp',
1632
+ description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
1633
+ url: location.href,
1634
+ icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
1635
+ }
1636
+ });
1637
+ resolve(signClient);
1638
+ });
1639
+
1640
+ return window.getSignClientPromise
1635
1641
  };
1636
1642
 
1637
1643
  class WalletConnectV2 {
@@ -1650,8 +1656,6 @@
1650
1656
  this.name = (localStorage[KEY+':name'] && localStorage[KEY+':name'] != undefined) ? localStorage[KEY+':name'] : this.constructor.info.name;
1651
1657
  this.logo = (localStorage[KEY+':logo'] && localStorage[KEY+':logo'] != undefined) ? localStorage[KEY+':logo'] : this.constructor.info.logo;
1652
1658
  this.blockchains = this.constructor.info.blockchains;
1653
- this.connector = WalletConnect.instance || this.newWalletConnectInstance();
1654
- WalletConnect.instance = this.connector;
1655
1659
  this.sendTransaction = (transaction)=>{
1656
1660
  return sendTransaction$1({
1657
1661
  wallet: this,
@@ -1660,11 +1664,6 @@
1660
1664
  };
1661
1665
  }
1662
1666
 
1663
- newWalletConnectInstance() {
1664
- if(!localStorage[KEY+":projectId"]) { throw(`localStorage['${KEY+":projectId"}'] is not set!`) }
1665
- return new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] })
1666
- }
1667
-
1668
1667
  async account() {
1669
1668
  const connectedChainId = await getConnectedChainId(this.signClient, this.session);
1670
1669
  const connectedBlockchain = Blockchains__default['default'].findById(connectedChainId);
@@ -1686,13 +1685,12 @@
1686
1685
  try {
1687
1686
 
1688
1687
  // delete localStorage[`wc@2:client:0.3//session`] // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
1689
- this.signClient = await getSignClient(this.connector);
1688
+ this.signClient = await getSignClient();
1690
1689
 
1691
1690
  this.signClient.on("session_delete", (session)=> {
1692
1691
  if(_optionalChain([session, 'optionalAccess', _8 => _8.topic]) === _optionalChain([this, 'access', _9 => _9.session, 'optionalAccess', _10 => _10.topic])) {
1693
1692
  localStorage[KEY+':name'] = undefined;
1694
1693
  localStorage[KEY+':logo'] = undefined;
1695
- this.connector = undefined;
1696
1694
  WalletConnect.instance = undefined;
1697
1695
  this.signClient = undefined;
1698
1696
  this.session = undefined;
@@ -2105,10 +2103,10 @@
2105
2103
 
2106
2104
  if(wallet.getConnectedInstance) {
2107
2105
  instance = await wallet.getConnectedInstance();
2108
- if(drip) { drip(instance); }
2106
+ if(drip && instance) { drip(instance); }
2109
2107
  return instance
2110
2108
  } else {
2111
- if(drip) { drip(wallet); }
2109
+ if(drip && wallet) { drip(wallet); }
2112
2110
  return new wallet
2113
2111
  }
2114
2112
  }
@@ -2390,7 +2390,7 @@
2390
2390
 
2391
2391
  const getLastSession = async()=>{
2392
2392
  if(!localStorage[KEY+":projectId"]) { return }
2393
- let signClient = await getSignClient(new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] }));
2393
+ let signClient = await getSignClient();
2394
2394
  const existingSessions = signClient.find(getWalletConnectV2Config());
2395
2395
  const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
2396
2396
  if(lastSession && lastSession.expiry > Math.ceil(Date.now()/1000)) {
@@ -2458,16 +2458,22 @@
2458
2458
  return { requiredNamespaces, optionalNamespaces }
2459
2459
  };
2460
2460
 
2461
- const getSignClient = async(core)=>{
2462
- return await walletconnectV2.SignClient.init({
2463
- core,
2464
- metadata: {
2465
- name: document.title || 'dApp',
2466
- description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
2467
- url: location.href,
2468
- icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
2469
- }
2470
- })
2461
+ const getSignClient = ()=>{
2462
+ if(window.getSignClientPromise) { return window.getSignClientPromise }
2463
+ window.getSignClientPromise = new Promise(async(resolve)=>{
2464
+ const signClient = await walletconnectV2.SignClient.init({
2465
+ core: new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] }),
2466
+ metadata: {
2467
+ name: document.title || 'dApp',
2468
+ description: _optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="description"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4('content')]) || document.title || 'dApp',
2469
+ url: location.href,
2470
+ icons: [_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _7 => _7.href]) || `${location.origin}/favicon.ico`]
2471
+ }
2472
+ });
2473
+ resolve(signClient);
2474
+ });
2475
+
2476
+ return window.getSignClientPromise
2471
2477
  };
2472
2478
 
2473
2479
  class WalletConnectV2 {
@@ -2486,8 +2492,6 @@
2486
2492
  this.name = (localStorage[KEY+':name'] && localStorage[KEY+':name'] != undefined) ? localStorage[KEY+':name'] : this.constructor.info.name;
2487
2493
  this.logo = (localStorage[KEY+':logo'] && localStorage[KEY+':logo'] != undefined) ? localStorage[KEY+':logo'] : this.constructor.info.logo;
2488
2494
  this.blockchains = this.constructor.info.blockchains;
2489
- this.connector = WalletConnect.instance || this.newWalletConnectInstance();
2490
- WalletConnect.instance = this.connector;
2491
2495
  this.sendTransaction = (transaction)=>{
2492
2496
  return sendTransaction$1({
2493
2497
  wallet: this,
@@ -2496,11 +2500,6 @@
2496
2500
  };
2497
2501
  }
2498
2502
 
2499
- newWalletConnectInstance() {
2500
- if(!localStorage[KEY+":projectId"]) { throw(`localStorage['${KEY+":projectId"}'] is not set!`) }
2501
- return new walletconnectV2.Core({ projectId: localStorage[KEY+":projectId"] })
2502
- }
2503
-
2504
2503
  async account() {
2505
2504
  const connectedChainId = await getConnectedChainId(this.signClient, this.session);
2506
2505
  const connectedBlockchain = Blockchains__default['default'].findById(connectedChainId);
@@ -2522,13 +2521,12 @@
2522
2521
  try {
2523
2522
 
2524
2523
  // delete localStorage[`wc@2:client:0.3//session`] // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
2525
- this.signClient = await getSignClient(this.connector);
2524
+ this.signClient = await getSignClient();
2526
2525
 
2527
2526
  this.signClient.on("session_delete", (session)=> {
2528
2527
  if(_optionalChain([session, 'optionalAccess', _8 => _8.topic]) === _optionalChain([this, 'access', _9 => _9.session, 'optionalAccess', _10 => _10.topic])) {
2529
2528
  localStorage[KEY+':name'] = undefined;
2530
2529
  localStorage[KEY+':logo'] = undefined;
2531
- this.connector = undefined;
2532
2530
  WalletConnect.instance = undefined;
2533
2531
  this.signClient = undefined;
2534
2532
  this.session = undefined;
@@ -2941,10 +2939,10 @@
2941
2939
 
2942
2940
  if(wallet.getConnectedInstance) {
2943
2941
  instance = await wallet.getConnectedInstance();
2944
- if(drip) { drip(instance); }
2942
+ if(drip && instance) { drip(instance); }
2945
2943
  return instance
2946
2944
  } else {
2947
- if(drip) { drip(wallet); }
2945
+ if(drip && wallet) { drip(wallet); }
2948
2946
  return new wallet
2949
2947
  }
2950
2948
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/web3-wallets-evm",
3
3
  "moduleName": "Web3Wallets",
4
- "version": "15.15.1",
4
+ "version": "15.15.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",