@depay/web3-wallets-evm 14.10.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/umd/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/web3-blockchains'), require('ethers'), require('@depay/web3-client'), require('@depay/web3-constants'), require('@depay/solana-web3.js'), require('@depay/walletconnect-v1'), require('@depay/walletconnect-v2'), require('@depay/coinbase-wallet-sdk')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@depay/web3-blockchains', 'ethers', '@depay/web3-client', '@depay/web3-constants', '@depay/solana-web3.js', '@depay/walletconnect-v1', '@depay/walletconnect-v2', '@depay/coinbase-wallet-sdk'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Wallets = {}, global.Web3Blockchains, global.ethers, global.Web3Client, global.Web3Constants, global.SolanaWeb3js, global.WalletConnect, global.WalletConnectV2, global.CoinbaseWalletSdk));
5
- }(this, (function (exports, web3Blockchains, ethers, web3Client, web3Constants, solanaWeb3_js, walletconnectV1, walletconnectV2, coinbaseWalletSdk) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/web3-blockchains'), require('ethers'), require('@depay/web3-client'), require('@depay/web3-constants'), require('@depay/solana-web3.js'), require('@depay/walletconnect-v1'), require('@depay/coinbase-wallet-sdk')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@depay/web3-blockchains', 'ethers', '@depay/web3-client', '@depay/web3-constants', '@depay/solana-web3.js', '@depay/walletconnect-v1', '@depay/coinbase-wallet-sdk'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Wallets = {}, global.Web3Blockchains, global.ethers, global.Web3Client, global.Web3Constants, global.SolanaWeb3js, global.WalletConnect, global.CoinbaseWalletSdk));
5
+ }(this, (function (exports, web3Blockchains, ethers, web3Client, web3Constants, solanaWeb3_js, walletconnectV1, coinbaseWalletSdk) { 'use strict';
6
6
 
7
- function _optionalChain$g(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; }
7
+ function _optionalChain$e(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; }
8
8
  class Transaction {
9
9
 
10
10
  constructor({ blockchain, from, to, value, api, method, params, instructions, sent, succeeded, failed }) {
@@ -15,7 +15,7 @@
15
15
  this.to = (to && to.match('0x')) ? ethers.ethers.utils.getAddress(to) : to;
16
16
 
17
17
  // optional
18
- this.value = _optionalChain$g([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
18
+ this.value = _optionalChain$e([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
19
19
  this.api = api;
20
20
  this.method = method;
21
21
  this.params = params;
@@ -293,7 +293,7 @@
293
293
  setProvider: setProvider$1,
294
294
  };
295
295
 
296
- function _optionalChain$f(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; }
296
+ function _optionalChain$d(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; }
297
297
  let getCacheStore = () => {
298
298
  if (getWindow()._cacheStore == undefined) {
299
299
  resetCache();
@@ -323,7 +323,7 @@
323
323
 
324
324
  let get = function ({ key, expires }) {
325
325
  let cachedEntry = getCacheStore()[key];
326
- if (_optionalChain$f([cachedEntry, 'optionalAccess', _ => _.expiresAt]) > Date.now()) {
326
+ if (_optionalChain$d([cachedEntry, 'optionalAccess', _ => _.expiresAt]) > Date.now()) {
327
327
  return cachedEntry.value
328
328
  }
329
329
  };
@@ -483,7 +483,7 @@
483
483
  })
484
484
  };
485
485
 
486
- const sendTransaction$4 = async ({ transaction, wallet })=> {
486
+ const sendTransaction$3 = async ({ transaction, wallet })=> {
487
487
  transaction = new Transaction(transaction);
488
488
  if((await wallet.connectedTo(transaction.blockchain)) == false) {
489
489
  await wallet.switchTo(transaction.blockchain);
@@ -496,7 +496,7 @@
496
496
  transaction.nonce = transactionCount;
497
497
  let provider = new ethers.ethers.providers.Web3Provider(wallet.getProvider(), 'any');
498
498
  let signer = provider.getSigner(0);
499
- await submit$4({ transaction, provider, signer }).then((sentTransaction)=>{
499
+ await submit$3({ transaction, provider, signer }).then((sentTransaction)=>{
500
500
  if (sentTransaction) {
501
501
  transaction.id = sentTransaction.hash;
502
502
  transaction.nonce = sentTransaction.nonce || transactionCount;
@@ -530,15 +530,15 @@
530
530
  return transaction
531
531
  };
532
532
 
533
- const submit$4 = ({ transaction, provider, signer }) => {
533
+ const submit$3 = ({ transaction, provider, signer }) => {
534
534
  if(transaction.method) {
535
- return submitContractInteraction$3({ transaction, signer, provider })
535
+ return submitContractInteraction$2({ transaction, signer, provider })
536
536
  } else {
537
- return submitSimpleTransfer$4({ transaction, signer })
537
+ return submitSimpleTransfer$3({ transaction, signer })
538
538
  }
539
539
  };
540
540
 
541
- const submitContractInteraction$3 = ({ transaction, signer, provider })=>{
541
+ const submitContractInteraction$2 = ({ transaction, signer, provider })=>{
542
542
  let contract = new ethers.ethers.Contract(transaction.to, transaction.api, provider);
543
543
  let contractArguments = transaction.getContractArguments({ contract });
544
544
  let method = contract.connect(signer)[transaction.method];
@@ -553,7 +553,7 @@
553
553
  }
554
554
  };
555
555
 
556
- const submitSimpleTransfer$4 = ({ transaction, signer })=>{
556
+ const submitSimpleTransfer$3 = ({ transaction, signer })=>{
557
557
  return signer.sendTransaction({
558
558
  to: transaction.to,
559
559
  value: Transaction.bigNumberify(transaction.value, transaction.blockchain)
@@ -564,7 +564,7 @@
564
564
  supported$2.evm = ['ethereum', 'bsc', 'polygon', 'velas'];
565
565
  supported$2.solana = [];
566
566
 
567
- function _optionalChain$e(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; }
567
+ function _optionalChain$c(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; }
568
568
  class WindowEthereum {
569
569
 
570
570
  static __initStatic() {this.info = {
@@ -575,12 +575,12 @@
575
575
 
576
576
  static __initStatic2() {this.isAvailable = ()=>{
577
577
  return (
578
- _optionalChain$e([window, 'optionalAccess', _13 => _13.ethereum]) &&
578
+ _optionalChain$c([window, 'optionalAccess', _13 => _13.ethereum]) &&
579
579
  Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)/)).length != 1 && // MetaMask
580
- !_optionalChain$e([window, 'optionalAccess', _14 => _14.coin98]) && // Coin98
581
- !(_optionalChain$e([window, 'optionalAccess', _15 => _15.ethereum, 'optionalAccess', _16 => _16.isTrust]) || _optionalChain$e([window, 'optionalAccess', _17 => _17.ethereum, 'optionalAccess', _18 => _18.isTrustWallet])) && // Trust Wallet
582
- !_optionalChain$e([window, 'optionalAccess', _19 => _19.ethereum, 'optionalAccess', _20 => _20.isDeficonnectProvider]) && // crypto.com
583
- !(_optionalChain$e([window, 'optionalAccess', _21 => _21.ethereum, 'optionalAccess', _22 => _22.isCoinbaseWallet]) || _optionalChain$e([window, 'optionalAccess', _23 => _23.ethereum, 'optionalAccess', _24 => _24.isWalletLink]))
580
+ !_optionalChain$c([window, 'optionalAccess', _14 => _14.coin98]) && // Coin98
581
+ !(_optionalChain$c([window, 'optionalAccess', _15 => _15.ethereum, 'optionalAccess', _16 => _16.isTrust]) || _optionalChain$c([window, 'optionalAccess', _17 => _17.ethereum, 'optionalAccess', _18 => _18.isTrustWallet])) && // Trust Wallet
582
+ !_optionalChain$c([window, 'optionalAccess', _19 => _19.ethereum, 'optionalAccess', _20 => _20.isDeficonnectProvider]) && // crypto.com
583
+ !(_optionalChain$c([window, 'optionalAccess', _21 => _21.ethereum, 'optionalAccess', _22 => _22.isCoinbaseWallet]) || _optionalChain$c([window, 'optionalAccess', _23 => _23.ethereum, 'optionalAccess', _24 => _24.isWalletLink]))
584
584
  )
585
585
  };}
586
586
 
@@ -589,7 +589,7 @@
589
589
  this.logo = this.constructor.info.logo;
590
590
  this.blockchains = this.constructor.info.blockchains;
591
591
  this.sendTransaction = (transaction)=>{
592
- return sendTransaction$4({
592
+ return sendTransaction$3({
593
593
  wallet: this,
594
594
  transaction
595
595
  })
@@ -691,7 +691,7 @@
691
691
  }
692
692
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
693
693
 
694
- function _optionalChain$d(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; }
694
+ function _optionalChain$b(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; }
695
695
  class Binance extends WindowEthereum {
696
696
 
697
697
  static __initStatic() {this.info = {
@@ -701,7 +701,7 @@
701
701
  };}
702
702
 
703
703
  static __initStatic2() {this.isAvailable = ()=>{
704
- return _optionalChain$d([window, 'optionalAccess', _2 => _2.BinanceChain]) &&
704
+ return _optionalChain$b([window, 'optionalAccess', _2 => _2.BinanceChain]) &&
705
705
  !window.coin98
706
706
  };}
707
707
 
@@ -709,7 +709,7 @@
709
709
 
710
710
  } Binance.__initStatic(); Binance.__initStatic2();
711
711
 
712
- function _optionalChain$c(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; }
712
+ function _optionalChain$a(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; }
713
713
  class Brave extends WindowEthereum {
714
714
 
715
715
  static __initStatic() {this.info = {
@@ -718,10 +718,10 @@
718
718
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
719
719
  };}
720
720
 
721
- static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$c([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isBraveWallet]) };}
721
+ static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$a([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isBraveWallet]) };}
722
722
  } Brave.__initStatic(); Brave.__initStatic2();
723
723
 
724
- function _optionalChain$b(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; }
724
+ function _optionalChain$9(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; }
725
725
  class Coin98 extends WindowEthereum {
726
726
 
727
727
  static __initStatic() {this.info = {
@@ -730,10 +730,10 @@
730
730
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
731
731
  };}
732
732
 
733
- static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$b([window, 'optionalAccess', _2 => _2.coin98]) };}
733
+ static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$9([window, 'optionalAccess', _2 => _2.coin98]) };}
734
734
  } Coin98.__initStatic(); Coin98.__initStatic2();
735
735
 
736
- function _optionalChain$a(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; }
736
+ function _optionalChain$8(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; }
737
737
  class Coinbase extends WindowEthereum {
738
738
 
739
739
  static __initStatic() {this.info = {
@@ -742,10 +742,10 @@
742
742
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
743
743
  };}
744
744
 
745
- static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$a([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isCoinbaseWallet]) || _optionalChain$a([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isWalletLink])) };}
745
+ static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$8([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isCoinbaseWallet]) || _optionalChain$8([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isWalletLink])) };}
746
746
  } Coinbase.__initStatic(); Coinbase.__initStatic2();
747
747
 
748
- function _optionalChain$9(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; }
748
+ function _optionalChain$7(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; }
749
749
  class CryptoCom extends WindowEthereum {
750
750
 
751
751
  static __initStatic() {this.info = {
@@ -754,10 +754,10 @@
754
754
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
755
755
  };}
756
756
 
757
- static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$9([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isDeficonnectProvider]) };}
757
+ static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$7([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isDeficonnectProvider]) };}
758
758
  } CryptoCom.__initStatic(); CryptoCom.__initStatic2();
759
759
 
760
- function _optionalChain$8(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; }
760
+ function _optionalChain$6(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; }
761
761
  class MetaMask extends WindowEthereum {
762
762
 
763
763
  static __initStatic() {this.info = {
@@ -767,11 +767,11 @@
767
767
  };}
768
768
 
769
769
  static __initStatic2() {this.isAvailable = ()=>{
770
- return _optionalChain$8([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isMetaMask]) && Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)/)).length == 1
770
+ return _optionalChain$6([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isMetaMask]) && Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)/)).length == 1
771
771
  };}
772
772
  } MetaMask.__initStatic(); MetaMask.__initStatic2();
773
773
 
774
- function _optionalChain$7(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; }
774
+ function _optionalChain$5(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; }
775
775
  class Opera extends WindowEthereum {
776
776
 
777
777
  static __initStatic() {this.info = {
@@ -780,17 +780,17 @@
780
780
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
781
781
  };}
782
782
 
783
- static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$7([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isOpera]) };}
783
+ static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$5([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isOpera]) };}
784
784
  } Opera.__initStatic(); Opera.__initStatic2();
785
785
 
786
- function _optionalChain$6(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; }
786
+ function _optionalChain$4(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; }
787
787
  const POLL_SPEED = 500; // 0.5 seconds
788
788
  const MAX_POLLS = 240; // 120 seconds
789
789
 
790
- const sendTransaction$3 = async ({ transaction, wallet })=> {
790
+ const sendTransaction$2 = async ({ transaction, wallet })=> {
791
791
  transaction = new Transaction(transaction);
792
792
  await transaction.prepare({ wallet });
793
- await submit$3({ transaction, wallet }).then(({ signature })=>{
793
+ await submit$2({ transaction, wallet }).then(({ signature })=>{
794
794
  if(signature) {
795
795
  transaction.id = signature;
796
796
  transaction.url = web3Blockchains.Blockchain.findByName(transaction.blockchain).explorerUrlFor({ transaction });
@@ -803,14 +803,14 @@
803
803
 
804
804
  const provider = await web3Client.getProvider(transaction.blockchain);
805
805
  const { value } = await provider.getSignatureStatus(signature);
806
- const confirmationStatus = _optionalChain$6([value, 'optionalAccess', _ => _.confirmationStatus]);
806
+ const confirmationStatus = _optionalChain$4([value, 'optionalAccess', _ => _.confirmationStatus]);
807
807
  if(confirmationStatus) {
808
808
  const hasReachedSufficientCommitment = confirmationStatus === 'confirmed' || confirmationStatus === 'finalized';
809
809
  if (hasReachedSufficientCommitment) {
810
810
  if(value.err) {
811
811
  transaction._failed = true;
812
812
  const confirmedTransaction = await provider.getConfirmedTransaction(signature);
813
- const failedReason = _optionalChain$6([confirmedTransaction, 'optionalAccess', _2 => _2.meta, 'optionalAccess', _3 => _3.logMessages]) ? confirmedTransaction.meta.logMessages[confirmedTransaction.meta.logMessages.length - 1] : null;
813
+ const failedReason = _optionalChain$4([confirmedTransaction, 'optionalAccess', _2 => _2.meta, 'optionalAccess', _3 => _3.logMessages]) ? confirmedTransaction.meta.logMessages[confirmedTransaction.meta.logMessages.length - 1] : null;
814
814
  if(transaction.failed) transaction.failed(transaction, failedReason);
815
815
  } else {
816
816
  transaction._succeeded = true;
@@ -827,15 +827,15 @@
827
827
  return transaction
828
828
  };
829
829
 
830
- const submit$3 = ({ transaction, wallet })=> {
830
+ const submit$2 = ({ transaction, wallet })=> {
831
831
  if(transaction.instructions) {
832
832
  return submitInstructions({ transaction, wallet })
833
833
  } else {
834
- return submitSimpleTransfer$3({ transaction, wallet })
834
+ return submitSimpleTransfer$2({ transaction, wallet })
835
835
  }
836
836
  };
837
837
 
838
- const submitSimpleTransfer$3 = async ({ transaction, wallet })=> {
838
+ const submitSimpleTransfer$2 = async ({ transaction, wallet })=> {
839
839
  let fromPubkey = new solanaWeb3_js.PublicKey(await wallet.account());
840
840
  let toPubkey = new solanaWeb3_js.PublicKey(transaction.to);
841
841
  const provider = await web3Client.getProvider(transaction.blockchain);
@@ -873,7 +873,7 @@
873
873
  supported$1.evm = ['ethereum', 'bsc', 'polygon', 'velas'];
874
874
  supported$1.solana = ['solana'];
875
875
 
876
- function _optionalChain$5(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; }
876
+ function _optionalChain$3(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; }
877
877
  class WindowSolana {
878
878
 
879
879
  static __initStatic() {this.info = {
@@ -884,8 +884,8 @@
884
884
 
885
885
  static __initStatic2() {this.isAvailable = ()=>{
886
886
  return (
887
- _optionalChain$5([window, 'optionalAccess', _4 => _4.solana]) &&
888
- !_optionalChain$5([window, 'optionalAccess', _5 => _5.solana, 'optionalAccess', _6 => _6.isPhantom]) &&
887
+ _optionalChain$3([window, 'optionalAccess', _4 => _4.solana]) &&
888
+ !_optionalChain$3([window, 'optionalAccess', _5 => _5.solana, 'optionalAccess', _6 => _6.isPhantom]) &&
889
889
  !window.coin98
890
890
  )
891
891
  };}
@@ -895,7 +895,7 @@
895
895
  this.logo = this.constructor.info.logo;
896
896
  this.blockchains = this.constructor.info.blockchains;
897
897
  this.sendTransaction = (transaction)=>{
898
- return sendTransaction$3({
898
+ return sendTransaction$2({
899
899
  wallet: this,
900
900
  transaction
901
901
  })
@@ -903,9 +903,9 @@
903
903
  }
904
904
 
905
905
  async account() {
906
- if(_optionalChain$5([window, 'optionalAccess', _7 => _7.solana]) == undefined){ return }
907
- if(_optionalChain$5([window, 'optionalAccess', _8 => _8.solana, 'optionalAccess', _9 => _9.publicKey])) { return window.solana.publicKey.toString() }
908
- if(_optionalChain$5([window, 'optionalAccess', _10 => _10.solana, 'optionalAccess', _11 => _11.isBraveWallet]) != true) {
906
+ if(_optionalChain$3([window, 'optionalAccess', _7 => _7.solana]) == undefined){ return }
907
+ if(_optionalChain$3([window, 'optionalAccess', _8 => _8.solana, 'optionalAccess', _9 => _9.publicKey])) { return window.solana.publicKey.toString() }
908
+ if(_optionalChain$3([window, 'optionalAccess', _10 => _10.solana, 'optionalAccess', _11 => _11.isBraveWallet]) != true) {
909
909
  let publicKey;
910
910
  try { ({ publicKey } = await window.solana.connect({ onlyIfTrusted: true })); } catch (e) {}
911
911
  if(publicKey){ return publicKey.toString() }
@@ -913,7 +913,7 @@
913
913
  }
914
914
 
915
915
  async connect() {
916
- if(!_optionalChain$5([window, 'optionalAccess', _12 => _12.solana])) { return undefined }
916
+ if(!_optionalChain$3([window, 'optionalAccess', _12 => _12.solana])) { return undefined }
917
917
  let { publicKey } = await window.solana.connect();
918
918
  return publicKey.toString()
919
919
  }
@@ -922,7 +922,7 @@
922
922
  let internalCallback;
923
923
  switch (event) {
924
924
  case 'account':
925
- internalCallback = (publicKey) => callback(_optionalChain$5([publicKey, 'optionalAccess', _13 => _13.toString, 'call', _14 => _14()]));
925
+ internalCallback = (publicKey) => callback(_optionalChain$3([publicKey, 'optionalAccess', _13 => _13.toString, 'call', _14 => _14()]));
926
926
  window.solana.on('accountChanged', internalCallback);
927
927
  break
928
928
  }
@@ -962,7 +962,7 @@
962
962
  }
963
963
  } WindowSolana.__initStatic(); WindowSolana.__initStatic2();
964
964
 
965
- function _optionalChain$4(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; }
965
+ function _optionalChain$2(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; }
966
966
  class Phantom extends WindowSolana {
967
967
 
968
968
  static __initStatic() {this.info = {
@@ -971,10 +971,10 @@
971
971
  blockchains: supported$1.solana
972
972
  };}
973
973
 
974
- static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$4([window, 'optionalAccess', _3 => _3.solana, 'optionalAccess', _4 => _4.isPhantom]) };}
974
+ static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$2([window, 'optionalAccess', _3 => _3.solana, 'optionalAccess', _4 => _4.isPhantom]) };}
975
975
  } Phantom.__initStatic(); Phantom.__initStatic2();
976
976
 
977
- function _optionalChain$3(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; }
977
+ function _optionalChain$1(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; }
978
978
  class Trust extends WindowEthereum {
979
979
 
980
980
  static __initStatic() {this.info = {
@@ -983,7 +983,7 @@
983
983
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
984
984
  };}
985
985
 
986
- static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$3([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isTrust]) || _optionalChain$3([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isTrustWallet])) };}
986
+ static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$1([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isTrust]) || _optionalChain$1([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isTrustWallet])) };}
987
987
  } Trust.__initStatic(); Trust.__initStatic2();
988
988
 
989
989
  class Argent {
@@ -1098,7 +1098,7 @@
1098
1098
  }
1099
1099
  };
1100
1100
 
1101
- const sendTransaction$2 = async ({ transaction, wallet })=> {
1101
+ const sendTransaction$1 = async ({ transaction, wallet })=> {
1102
1102
  transaction = new Transaction(transaction);
1103
1103
  if((await wallet.connectedTo(transaction.blockchain)) == false) {
1104
1104
  await wallet.switchTo(transaction.blockchain);
@@ -1110,13 +1110,13 @@
1110
1110
  const smartContractWallet = await getSmartContractWallet(transaction.blockchain, transaction.from);
1111
1111
  let transactionCount = await wallet.transactionCount({ blockchain: transaction.blockchain, address: transaction.from });
1112
1112
  transaction.nonce = transactionCount;
1113
- await submit$2({ transaction, wallet }).then((tx)=>{
1113
+ await submit$1({ transaction, wallet }).then((tx)=>{
1114
1114
  if (tx) {
1115
1115
  let blockchain = web3Blockchains.Blockchain.findByName(transaction.blockchain);
1116
1116
  transaction.id = tx;
1117
1117
  transaction.url = smartContractWallet && smartContractWallet.explorerUrlFor ? smartContractWallet.explorerUrlFor({ transaction }) : blockchain.explorerUrlFor({ transaction });
1118
1118
  if (transaction.sent) transaction.sent(transaction);
1119
- retrieveTransaction$1({ blockchain: transaction.blockchain, tx, smartContractWallet }).then((sentTransaction)=>{
1119
+ retrieveTransaction({ blockchain: transaction.blockchain, tx, smartContractWallet }).then((sentTransaction)=>{
1120
1120
  transaction.id = sentTransaction.hash || transaction.id;
1121
1121
  transaction.url = blockchain.explorerUrlFor({ transaction });
1122
1122
  transaction.nonce = sentTransaction.nonce || transactionCount;
@@ -1147,7 +1147,7 @@
1147
1147
  return transaction
1148
1148
  };
1149
1149
 
1150
- const retrieveTransaction$1 = async ({ blockchain, tx, smartContractWallet })=>{
1150
+ const retrieveTransaction = async ({ blockchain, tx, smartContractWallet })=>{
1151
1151
  const provider = await web3Client.getProvider(blockchain);
1152
1152
  let retrieve = async()=>{
1153
1153
  try {
@@ -1168,15 +1168,15 @@
1168
1168
  return sentTransaction
1169
1169
  };
1170
1170
 
1171
- const submit$2 = ({ transaction, wallet }) => {
1171
+ const submit$1 = ({ transaction, wallet }) => {
1172
1172
  if(transaction.method) {
1173
- return submitContractInteraction$2({ transaction, wallet })
1173
+ return submitContractInteraction$1({ transaction, wallet })
1174
1174
  } else {
1175
- return submitSimpleTransfer$2({ transaction, wallet })
1175
+ return submitSimpleTransfer$1({ transaction, wallet })
1176
1176
  }
1177
1177
  };
1178
1178
 
1179
- const submitContractInteraction$2 = async ({ transaction, wallet })=>{
1179
+ const submitContractInteraction$1 = async ({ transaction, wallet })=>{
1180
1180
  const provider = await web3Client.getProvider(transaction.blockchain);
1181
1181
  const gasPrice = await provider.getGasPrice();
1182
1182
  const gas = await web3Client.estimate(transaction);
@@ -1194,7 +1194,7 @@
1194
1194
  })
1195
1195
  };
1196
1196
 
1197
- const submitSimpleTransfer$2 = async ({ transaction, wallet })=>{
1197
+ const submitSimpleTransfer$1 = async ({ transaction, wallet })=>{
1198
1198
  const provider = await web3Client.getProvider(transaction.blockchain);
1199
1199
  const gasPrice = await provider.getGasPrice();
1200
1200
  const gas = await web3Client.estimate(transaction);
@@ -1211,17 +1211,30 @@
1211
1211
  })
1212
1212
  };
1213
1213
 
1214
- function _optionalChain$2(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; }
1215
- const KEY$1 = '_DePayWeb3WalletsConnectedWalletConnectV1Instance';
1214
+ function _optionalChain(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; }
1215
+ const KEY = '_DePayWeb3WalletsConnectedWalletConnectV1Instance';
1216
+
1217
+ let currentPlainInstance;
1216
1218
 
1217
- const getConnectedInstance$2 = ()=>{
1218
- if(window[KEY$1]) { return window[KEY$1] }
1219
- let connector = getWalletConnectInstance(()=>{});
1220
- if(connector.connected) { return new WalletConnectV1() }
1219
+ const getPlainInstance = ()=>{
1220
+ if(currentPlainInstance) { return currentPlainInstance }
1221
+ currentPlainInstance = getWalletConnectInstance(()=>{});
1221
1222
  };
1222
1223
 
1223
- const setConnectedInstance$2 = (value)=>{
1224
- window[KEY$1] = value;
1224
+ const isConnected = async()=>{
1225
+ let connector = getPlainInstance();
1226
+ let account;
1227
+ try { account = await connector.sendCustomRequest({ method: 'eth_chainId' }); } catch (e) {}
1228
+ return !!account
1229
+ };
1230
+
1231
+ const getConnectedInstance$1 = async()=>{
1232
+ if(window[KEY]) { return window[KEY] }
1233
+ if(await isConnected()) { return new WalletConnectV1() }
1234
+ };
1235
+
1236
+ const setConnectedInstance$1 = (value)=>{
1237
+ window[KEY] = value;
1225
1238
  };
1226
1239
 
1227
1240
  const getWalletConnectInstance = (connect)=>{
@@ -1243,16 +1256,15 @@
1243
1256
  };}
1244
1257
 
1245
1258
  static __initStatic2() {this.isAvailable = ()=>{
1246
- let connector = getWalletConnectInstance(()=>{});
1247
- return getConnectedInstance$2() != undefined || connector.connected
1259
+ return getConnectedInstance$1() != undefined
1248
1260
  };}
1249
1261
 
1250
1262
  constructor() {
1251
- this.name = localStorage[KEY$1+'_name'] ? localStorage[KEY$1+'_name'] : this.constructor.info.name;
1252
- this.logo = localStorage[KEY$1+'_logo'] ? localStorage[KEY$1+'_logo'] : this.constructor.info.logo;
1263
+ this.name = (localStorage[KEY+'_name'] && localStorage[KEY+'_name'] != 'undefined') ? localStorage[KEY+'_name'] : this.constructor.info.name;
1264
+ this.logo = (localStorage[KEY+'_logo'] && localStorage[KEY+'_logo'] != 'undefined') ? localStorage[KEY+'_logo'] : this.constructor.info.logo;
1253
1265
  this.blockchains = this.constructor.info.blockchains;
1254
1266
  this.sendTransaction = (transaction)=>{
1255
- return sendTransaction$2({
1267
+ return sendTransaction$1({
1256
1268
  wallet: this,
1257
1269
  transaction
1258
1270
  })
@@ -1277,14 +1289,14 @@
1277
1289
  });
1278
1290
 
1279
1291
  instance.on("disconnect", (error, payload) => {
1280
- setConnectedInstance$2(undefined);
1281
- localStorage[KEY$1+'_name'] = undefined;
1282
- localStorage[KEY$1+'_logo'] = undefined;
1292
+ setConnectedInstance$1(undefined);
1293
+ localStorage[KEY+'_name'] = undefined;
1294
+ localStorage[KEY+'_logo'] = undefined;
1283
1295
  if (error) { throw error }
1284
1296
  });
1285
1297
 
1286
1298
  instance.on("modal_closed", ()=>{
1287
- setConnectedInstance$2(undefined);
1299
+ setConnectedInstance$1(undefined);
1288
1300
  this.connector = undefined;
1289
1301
  });
1290
1302
 
@@ -1317,11 +1329,11 @@
1317
1329
 
1318
1330
  let { accounts, chainId } = await this.connector.connect();
1319
1331
 
1320
- if(_optionalChain$2([options, 'optionalAccess', _ => _.name])) { localStorage[KEY$1+'_name'] = this.name = options.name; }
1321
- if(_optionalChain$2([options, 'optionalAccess', _2 => _2.logo])) { localStorage[KEY$1+'_logo'] = this.logo = options.logo; }
1332
+ if(_optionalChain([options, 'optionalAccess', _ => _.name])) { localStorage[KEY+'_name'] = this.name = options.name; }
1333
+ if(_optionalChain([options, 'optionalAccess', _2 => _2.logo])) { localStorage[KEY+'_logo'] = this.logo = options.logo; }
1322
1334
 
1323
1335
  if(accounts instanceof Array && accounts.length) {
1324
- setConnectedInstance$2(this);
1336
+ setConnectedInstance$1(this);
1325
1337
  accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
1326
1338
  this.connectedChainId = chainId;
1327
1339
 
@@ -1445,298 +1457,8 @@
1445
1457
  }
1446
1458
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
1447
1459
 
1448
- WalletConnectV1.getConnectedInstance = getConnectedInstance$2;
1449
- WalletConnectV1.setConnectedInstance = setConnectedInstance$2;
1450
-
1451
- function _optionalChain$1(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; }
1452
- const sendTransaction$1 = async ({ transaction, wallet })=> {
1453
- transaction = new Transaction(transaction);
1454
- if((await wallet.connectedTo(transaction.blockchain)) == false) {
1455
- await wallet.switchTo(transaction.blockchain);
1456
- }
1457
- if((await wallet.connectedTo(transaction.blockchain)) == false) {
1458
- throw({ code: 'WRONG_NETWORK' })
1459
- }
1460
- await transaction.prepare({ wallet });
1461
- let transactionCount = await web3Client.request({ blockchain: transaction.blockchain, method: 'transactionCount', address: transaction.from });
1462
- transaction.nonce = transactionCount;
1463
- await submit$1({ transaction, wallet }).then(async (response)=>{
1464
- if(typeof response == 'string') {
1465
- let blockchain = web3Blockchains.Blockchain.findByName(transaction.blockchain);
1466
- transaction.id = response;
1467
- transaction.url = blockchain.explorerUrlFor({ transaction });
1468
- if (transaction.sent) transaction.sent(transaction);
1469
- let sentTransaction = await retrieveTransaction(transaction.id, transaction.blockchain);
1470
- transaction.nonce = sentTransaction.nonce || transactionCount;
1471
- if(!sentTransaction) {
1472
- transaction._failed = true;
1473
- console.log('Error retrieving transaction');
1474
- if(transaction.failed) transaction.failed(transaction, 'Error retrieving transaction');
1475
- } else {
1476
- sentTransaction.wait(1).then(() => {
1477
- transaction._succeeded = true;
1478
- if (transaction.succeeded) transaction.succeeded(transaction);
1479
- }).catch((error)=>{
1480
- if(error && error.code && error.code == 'TRANSACTION_REPLACED') {
1481
- if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) {
1482
- transaction.id = error.replacement.hash;
1483
- transaction._succeeded = true;
1484
- if (transaction.succeeded) transaction.succeeded(transaction);
1485
- } else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
1486
- transaction.id = error.replacement.hash;
1487
- transaction._failed = true;
1488
- if(transaction.failed) transaction.failed(transaction, error);
1489
- }
1490
- } else {
1491
- transaction._failed = true;
1492
- if(transaction.failed) transaction.failed(transaction, error);
1493
- }
1494
- });
1495
- }
1496
- } else {
1497
- throw(response)
1498
- }
1499
- });
1500
- return transaction
1501
- };
1502
-
1503
- const retrieveTransaction = async (tx, blockchain)=>{
1504
- let sentTransaction;
1505
- const provider = await web3Client.getProvider(blockchain);
1506
- sentTransaction = await provider.getTransaction(tx);
1507
- const maxRetries = 120;
1508
- let attempt = 1;
1509
- while (attempt <= maxRetries && !sentTransaction) {
1510
- sentTransaction = await provider.getTransaction(tx);
1511
- await (new Promise((resolve)=>setTimeout(resolve, 5000)));
1512
- attempt++;
1513
- }
1514
- return sentTransaction
1515
- };
1516
-
1517
- const submit$1 = ({ transaction, wallet }) => {
1518
- if(transaction.method) {
1519
- return submitContractInteraction$1({ transaction, wallet })
1520
- } else {
1521
- return submitSimpleTransfer$1({ transaction, wallet })
1522
- }
1523
- };
1524
-
1525
- const submitContractInteraction$1 = async ({ transaction, wallet })=>{
1526
- const provider = await web3Client.getProvider(transaction.blockchain);
1527
- return wallet.signClient.request({
1528
- topic: wallet.session.topic,
1529
- chainId: wallet.session.chainId,
1530
- request: {
1531
- method: 'eth_sendTransaction',
1532
- params: [{
1533
- from: transaction.from,
1534
- to: transaction.to,
1535
- value: _optionalChain$1([transaction, 'access', _ => _.value, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()]),
1536
- data: await transaction.getData(),
1537
- gas: (await web3Client.estimate(transaction)).toString(),
1538
- gasPrice: (await provider.getGasPrice()).toString(),
1539
- nonce: transaction.nonce,
1540
- }]
1541
- }
1542
- })
1543
- };
1544
-
1545
- const submitSimpleTransfer$1 = async ({ transaction, wallet })=>{
1546
- const provider = await web3Client.getProvider(transaction.blockchain);
1547
- let blockchain = web3Blockchains.Blockchain.findByName(transaction.blockchain);
1548
- return wallet.signClient.request({
1549
- topic: wallet.session.topic,
1550
- chainId: wallet.session.chainId,
1551
- request: {
1552
- method: 'eth_sendTransaction',
1553
- params: [{
1554
- chainId: blockchain.id,
1555
- from: transaction.from,
1556
- to: transaction.to,
1557
- value: _optionalChain$1([transaction, 'access', _4 => _4.value, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]),
1558
- gas: (await web3Client.estimate(transaction)).toString(),
1559
- gasPrice: (await provider.getGasPrice()).toString(),
1560
- nonce: transaction.nonce
1561
- }]
1562
- }
1563
- }).catch((e)=>{console.log('ERROR', e);})
1564
- };
1565
-
1566
- function _optionalChain(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; }
1567
- const KEY = '_DePayWeb3WalletsConnectedWalletConnectV2Instance';
1568
-
1569
- const getConnectedInstance$1 = ()=>{
1570
- return window[KEY]
1571
- };
1572
-
1573
- const setConnectedInstance$1 = (value)=>{
1574
- window[KEY] = value;
1575
- };
1576
-
1577
- class WalletConnectV2 {
1578
-
1579
- static __initStatic() {this.info = {
1580
- name: 'WalletConnect',
1581
- logo: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMjUuNC4xLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAtLT48c3ZnIHZlcnNpb249JzEuMScgaWQ9J0xheWVyXzEnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZycgeG1sbnM6eGxpbms9J2h0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsnIHg9JzBweCcgeT0nMHB4JyB2aWV3Qm94PScwIDAgNTAwIDUwMCcgc3R5bGU9J2VuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTAwIDUwMDsnIHhtbDpzcGFjZT0ncHJlc2VydmUnPjxzdHlsZSB0eXBlPSd0ZXh0L2Nzcyc+IC5zdDB7ZmlsbDojNTk5MUNEO30KPC9zdHlsZT48ZyBpZD0nUGFnZS0xJz48ZyBpZD0nd2FsbGV0Y29ubmVjdC1sb2dvLWFsdCc+PHBhdGggaWQ9J1dhbGxldENvbm5lY3QnIGNsYXNzPSdzdDAnIGQ9J00xMDIuNywxNjJjODEuNS03OS44LDIxMy42LTc5LjgsMjk1LjEsMGw5LjgsOS42YzQuMSw0LDQuMSwxMC41LDAsMTQuNEwzNzQsMjE4LjkgYy0yLDItNS4zLDItNy40LDBsLTEzLjUtMTMuMmMtNTYuOC01NS43LTE0OS01NS43LTIwNS44LDBsLTE0LjUsMTQuMWMtMiwyLTUuMywyLTcuNCwwTDkxLjksMTg3Yy00LjEtNC00LjEtMTAuNSwwLTE0LjQgTDEwMi43LDE2MnogTTQ2Ny4xLDIyOS45bDI5LjksMjkuMmM0LjEsNCw0LjEsMTAuNSwwLDE0LjRMMzYyLjMsNDA1LjRjLTQuMSw0LTEwLjcsNC0xNC44LDBjMCwwLDAsMCwwLDBMMjUyLDMxMS45IGMtMS0xLTIuNy0xLTMuNywwaDBsLTk1LjUsOTMuNWMtNC4xLDQtMTAuNyw0LTE0LjgsMGMwLDAsMCwwLDAsMEwzLjQsMjczLjZjLTQuMS00LTQuMS0xMC41LDAtMTQuNGwyOS45LTI5LjIgYzQuMS00LDEwLjctNCwxNC44LDBsOTUuNSw5My41YzEsMSwyLjcsMSwzLjcsMGMwLDAsMCwwLDAsMGw5NS41LTkzLjVjNC4xLTQsMTAuNy00LDE0LjgsMGMwLDAsMCwwLDAsMGw5NS41LDkzLjUgYzEsMSwyLjcsMSwzLjcsMGw5NS41LTkzLjVDNDU2LjQsMjI1LjksNDYzLDIyNS45LDQ2Ny4xLDIyOS45eicvPjwvZz48L2c+PC9zdmc+Cg==",
1582
- blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
1583
- };}
1584
-
1585
- static __initStatic2() {this.isAvailable = ()=>{
1586
- return getConnectedInstance$1() != undefined
1587
- };}
1588
-
1589
- constructor() {
1590
- this.name = this.constructor.info.name;
1591
- this.logo = this.constructor.info.logo;
1592
- this.blockchains = this.constructor.info.blockchains;
1593
- this.connector = WalletConnect.instance || this.newWalletConnectInstance();
1594
- WalletConnect.instance = this.connector;
1595
- this.sendTransaction = (transaction)=>{
1596
- return sendTransaction$1({
1597
- wallet: this,
1598
- transaction
1599
- })
1600
- };
1601
- }
1602
-
1603
- newWalletConnectInstance() {
1604
- return new walletconnectV2.Core({ projectId: window._walletConnectProjectId })
1605
- }
1606
-
1607
- async account() {
1608
- if(this.connectedAccount == undefined) { return }
1609
- return this.connectedAccount
1610
- }
1611
-
1612
- async connect({ connect, blockchain }) {
1613
-
1614
- if(!connect || typeof connect != 'function') { throw('Provided connect paremeters is not present or not a function!') }
1615
-
1616
- try {
1617
-
1618
- delete localStorage[`wc@2:core:${this.connector.pairing.version}//subscription`]; // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
1619
- this.signClient = await walletconnectV2.SignClient.init({ core: this.connector });
1620
-
1621
- this.signClient.on("session_delete", () => {
1622
- console.log('WALLETCONNECT DISCONNECT');
1623
- this.connector = undefined;
1624
- WalletConnect.instance = undefined;
1625
- this.connectedAccount = undefined;
1626
- this.signClient = undefined;
1627
- this.session = undefined;
1628
- });
1629
-
1630
- blockchain = web3Blockchains.Blockchain.findByName(blockchain);
1631
-
1632
- let namespaces = {};
1633
-
1634
- namespaces[blockchain.namespace] = {
1635
- methods: [
1636
- "eth_sendTransaction",
1637
- "personal_sign",
1638
- "eth_chainId",
1639
- "wallet_switchEthereumChain",
1640
- ],
1641
- chains: [`${blockchain.namespace}:${blockchain.networkId}`],
1642
- events: [],
1643
- };
1644
-
1645
- const { uri, approval } = await this.signClient.connect({ requiredNamespaces: namespaces });
1646
-
1647
- await connect({ uri });
1648
- this.session = await approval();
1649
- this.session.chainId = `${blockchain.namespace}:${blockchain.networkId}`;
1650
-
1651
- let meta = _optionalChain([this, 'access', _ => _.session, 'optionalAccess', _2 => _2.peer, 'optionalAccess', _3 => _3.metadata]);
1652
- if(meta && meta.name) {
1653
- this.name = meta.name;
1654
- if(_optionalChain([meta, 'optionalAccess', _4 => _4.icons]) && meta.icons.length) { this.logo = meta.icons[0]; }
1655
- }
1656
-
1657
- const account = Object.values(this.session.namespaces)[0].accounts[0].split(":")[2];
1658
- this.connectedAccount = account;
1659
- this.connectedBlockchain = blockchain.name;
1660
-
1661
- return account
1662
-
1663
- } catch (error) {
1664
- console.log('WALLETCONNECT ERROR', error);
1665
- }
1666
- }
1667
-
1668
- async connectedTo(input) {
1669
- if(input) {
1670
- return input === this.connectedBlockchain
1671
- } else {
1672
- const blockchain = web3Blockchains.Blockchain.findByName(this.connectedBlockchain);
1673
- return blockchain.name
1674
- }
1675
- }
1676
-
1677
- switchTo(blockchainName) {
1678
- return new Promise((resolve, reject)=>{
1679
- let resolved, rejected;
1680
- const blockchain = web3Blockchains.Blockchain.findByName(blockchainName);
1681
- setTimeout(async()=>{
1682
- if(!(await this.connectedTo(blockchainName)) && !resolved && !rejected){
1683
- reject({ code: 'NOT_SUPPORTED' });
1684
- } else {
1685
- resolve();
1686
- }
1687
- }, 4000);
1688
- this.connectedBlockchain = blockchain.name;
1689
- this.signClient.request({
1690
- topic: this.session.topic,
1691
- chainId: this.session.chainId,
1692
- request:{
1693
- method: 'wallet_switchEthereumChain',
1694
- params: [{ chainId: blockchain.id }],
1695
- }
1696
- }).then((result)=>{
1697
- console.log('RESULT ', result);
1698
- resolved = true;
1699
- resolve();
1700
- });
1701
- })
1702
- }
1703
-
1704
- addNetwork(blockchainName) {
1705
- return new Promise((resolve, reject)=>{
1706
- reject({ code: 'NOT_SUPPORTED' });
1707
- })
1708
- }
1709
-
1710
- on(event, callback) {
1711
- // currently not supported
1712
- }
1713
-
1714
- off(event, callback) {
1715
- // currently not supported
1716
- }
1717
-
1718
- async sign(message) {
1719
- let address = await this.account();
1720
- var params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
1721
- let signature = await this.signClient.request({
1722
- topic: this.session.topic,
1723
- chainId: this.session.chainId,
1724
- request:{
1725
- id: 1,
1726
- jsonrpc: '2.0',
1727
- method: 'personal_sign',
1728
- params
1729
- }
1730
- });
1731
- if(typeof signature == 'object') {
1732
- signature = ethers.ethers.utils.hexlify(signature);
1733
- }
1734
- return signature
1735
- }
1736
- } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
1737
-
1738
- WalletConnectV2.getConnectedInstance = getConnectedInstance$1;
1739
- WalletConnectV2.setConnectedInstance = setConnectedInstance$1;
1460
+ WalletConnectV1.getConnectedInstance = getConnectedInstance$1;
1461
+ WalletConnectV1.setConnectedInstance = setConnectedInstance$1;
1740
1462
 
1741
1463
  const sendTransaction = async ({ transaction, wallet })=> {
1742
1464
  transaction = new Transaction(transaction);
@@ -1965,40 +1687,32 @@
1965
1687
  WindowEthereum,
1966
1688
  WindowSolana,
1967
1689
  WalletConnectV1,
1968
- WalletConnectV2,
1969
1690
  WalletLink
1970
1691
  };
1971
1692
 
1972
- const getWallets = ()=>{
1973
- let availableWallets = [];
1693
+ const getWallets = async()=>{
1974
1694
 
1975
- Object.keys(wallets).forEach((key)=>{
1976
- let wallet = wallets[key];
1977
- if(wallet.isAvailable()) {
1978
- let instance;
1979
- if(wallet.getConnectedInstance && wallet.getConnectedInstance()) {
1980
- instance = wallet.getConnectedInstance();
1981
- } else {
1982
- instance = new wallet;
1983
- }
1984
- availableWallets.push(instance);
1985
- }
1986
- });
1987
-
1988
- return availableWallets
1989
- };
1990
-
1991
- const getConnectedWallets = async()=>{
1992
-
1993
- let connectedWallets = (await Promise.all(
1994
- getWallets().map(async(wallet)=>{
1995
- if(await wallet.account()) {
1996
- return wallet
1695
+ let availableWallets = await Promise.all(
1696
+ Object.keys(wallets).map(
1697
+ async(key)=>{
1698
+
1699
+ let wallet = wallets[key];
1700
+
1701
+ if(wallet.isAvailable()) {
1702
+ let instance;
1703
+
1704
+ if(wallet.getConnectedInstance) {
1705
+ instance = await wallet.getConnectedInstance();
1706
+ return instance
1707
+ } else {
1708
+ return new wallet
1709
+ }
1710
+ }
1997
1711
  }
1998
- })
1999
- )).filter((value)=>!!value);
1712
+ )
1713
+ );
2000
1714
 
2001
- return connectedWallets
1715
+ return availableWallets.filter((wallet)=>wallet)
2002
1716
  };
2003
1717
 
2004
1718
  const supported = [
@@ -2012,11 +1726,9 @@
2012
1726
  wallets.Coin98,
2013
1727
  wallets.CryptoCom,
2014
1728
  wallets.WalletConnectV1,
2015
- wallets.WalletConnectV2,
2016
1729
  wallets.WalletLink
2017
1730
  ];
2018
1731
 
2019
- exports.getConnectedWallets = getConnectedWallets;
2020
1732
  exports.getWallets = getWallets;
2021
1733
  exports.supported = supported;
2022
1734
  exports.wallets = wallets;