@depay/web3-wallets-evm 13.1.2 → 14.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-constants'), require('@depay/solana-web3.js'), require('@depay/web3-client'), require('@depay/walletconnect-v1'), require('@depay/coinbase-wallet-sdk')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@depay/web3-blockchains', 'ethers', '@depay/web3-constants', '@depay/solana-web3.js', '@depay/web3-client', '@depay/walletconnect-v1', '@depay/coinbase-wallet-sdk'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Wallets = {}, global.Web3Blockchains, global.ethers, global.Web3Constants, global.SolanaWeb3js, global.Web3Client, global.WalletConnect, global.CoinbaseWalletSdk));
5
- }(this, (function (exports, web3Blockchains, ethers, web3Constants, solanaWeb3_js, web3Client, walletconnectV1, coinbaseWalletSdk) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/web3-blockchains'), require('ethers'), require('@depay/web3-constants'), require('@depay/solana-web3.js'), require('@depay/web3-client'), 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-constants', '@depay/solana-web3.js', '@depay/web3-client', '@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.Web3Constants, global.SolanaWeb3js, global.Web3Client, global.WalletConnect, global.WalletConnectV2, global.CoinbaseWalletSdk));
5
+ }(this, (function (exports, web3Blockchains, ethers, web3Constants, solanaWeb3_js, web3Client, walletconnectV1, walletconnectV2, coinbaseWalletSdk) { 'use strict';
6
6
 
7
- 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; }
7
+ 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; }
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$9([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
18
+ this.value = _optionalChain$b([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$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; }
296
+ 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; }
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$8([cachedEntry, 'optionalAccess', _ => _.expiresAt]) > Date.now()) {
326
+ if (_optionalChain$a([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$3 = async ({ transaction, wallet })=> {
486
+ const sendTransaction$4 = 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(window.ethereum, 'any');
498
498
  let signer = provider.getSigner(0);
499
- await submit$3({ transaction, provider, signer }).then((sentTransaction)=>{
499
+ await submit$4({ 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$3 = ({ transaction, provider, signer }) => {
533
+ const submit$4 = ({ transaction, provider, signer }) => {
534
534
  if(transaction.method) {
535
- return submitContractInteraction$2({ transaction, signer, provider })
535
+ return submitContractInteraction$3({ transaction, signer, provider })
536
536
  } else {
537
- return submitSimpleTransfer$3({ transaction, signer })
537
+ return submitSimpleTransfer$4({ transaction, signer })
538
538
  }
539
539
  };
540
540
 
541
- const submitContractInteraction$2 = ({ transaction, signer, provider })=>{
541
+ const submitContractInteraction$3 = ({ 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$3 = ({ transaction, signer })=>{
556
+ const submitSimpleTransfer$4 = ({ 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$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; }
567
+ 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; }
568
568
  class WindowEthereum {
569
569
 
570
570
  static __initStatic() {this.info = {
@@ -575,9 +575,9 @@
575
575
 
576
576
  static __initStatic2() {this.isAvailable = ()=>{
577
577
  return (
578
- _optionalChain$7([window, 'optionalAccess', _8 => _8.ethereum]) &&
579
- !_optionalChain$7([window, 'optionalAccess', _9 => _9.ethereum, 'optionalAccess', _10 => _10.isMetaMask]) &&
580
- !(_optionalChain$7([window, 'optionalAccess', _11 => _11.ethereum, 'optionalAccess', _12 => _12.isCoinbaseWallet]) || _optionalChain$7([window, 'optionalAccess', _13 => _13.ethereum, 'optionalAccess', _14 => _14.isWalletLink]))
578
+ _optionalChain$9([window, 'optionalAccess', _8 => _8.ethereum]) &&
579
+ !_optionalChain$9([window, 'optionalAccess', _9 => _9.ethereum, 'optionalAccess', _10 => _10.isMetaMask]) &&
580
+ !(_optionalChain$9([window, 'optionalAccess', _11 => _11.ethereum, 'optionalAccess', _12 => _12.isCoinbaseWallet]) || _optionalChain$9([window, 'optionalAccess', _13 => _13.ethereum, 'optionalAccess', _14 => _14.isWalletLink]))
581
581
  )
582
582
  };}
583
583
 
@@ -586,7 +586,7 @@
586
586
  this.logo = this.constructor.info.logo;
587
587
  this.blockchains = this.constructor.info.blockchains;
588
588
  this.sendTransaction = (transaction)=>{
589
- return sendTransaction$3({
589
+ return sendTransaction$4({
590
590
  wallet: this,
591
591
  transaction
592
592
  })
@@ -594,13 +594,13 @@
594
594
  }
595
595
 
596
596
  async account() {
597
- if(!_optionalChain$7([window, 'optionalAccess', _15 => _15.ethereum])) { return undefined }
597
+ if(!_optionalChain$9([window, 'optionalAccess', _15 => _15.ethereum])) { return undefined }
598
598
  const accounts = (await window.ethereum.request({ method: 'eth_accounts' })).map((address)=>ethers.ethers.utils.getAddress(address));
599
599
  return accounts[0]
600
600
  }
601
601
 
602
602
  async connect() {
603
- if(!_optionalChain$7([window, 'optionalAccess', _16 => _16.ethereum])) { return undefined }
603
+ if(!_optionalChain$9([window, 'optionalAccess', _16 => _16.ethereum])) { return undefined }
604
604
  const accounts = (await window.ethereum.request({ method: 'eth_requestAccounts' })).map((address)=>ethers.ethers.utils.getAddress(address));
605
605
  return accounts[0]
606
606
  }
@@ -682,7 +682,7 @@
682
682
  }
683
683
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
684
684
 
685
- 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; }
685
+ 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; }
686
686
  class Coinbase extends WindowEthereum {
687
687
 
688
688
  static __initStatic() {this.info = {
@@ -691,10 +691,10 @@
691
691
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
692
692
  };}
693
693
 
694
- static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$6([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isCoinbaseWallet]) || _optionalChain$6([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isWalletLink])) };}
694
+ 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])) };}
695
695
  } Coinbase.__initStatic(); Coinbase.__initStatic2();
696
696
 
697
- 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; }
697
+ 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; }
698
698
  class MetaMask extends WindowEthereum {
699
699
 
700
700
  static __initStatic() {this.info = {
@@ -703,17 +703,17 @@
703
703
  blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
704
704
  };}
705
705
 
706
- static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$5([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isMetaMask]) };}
706
+ static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$7([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isMetaMask]) };}
707
707
  } MetaMask.__initStatic(); MetaMask.__initStatic2();
708
708
 
709
- 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; }
709
+ 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; }
710
710
  const POLL_SPEED = 500; // 0.5 seconds
711
711
  const MAX_POLLS = 240; // 120 seconds
712
712
 
713
- const sendTransaction$2 = async ({ transaction, wallet })=> {
713
+ const sendTransaction$3 = async ({ transaction, wallet })=> {
714
714
  transaction = new Transaction(transaction);
715
715
  await transaction.prepare({ wallet });
716
- await submit$2({ transaction, wallet }).then(({ signature })=>{
716
+ await submit$3({ transaction, wallet }).then(({ signature })=>{
717
717
  if(signature) {
718
718
  transaction.id = signature;
719
719
  transaction.url = web3Blockchains.Blockchain.findByName(transaction.blockchain).explorerUrlFor({ transaction });
@@ -726,14 +726,14 @@
726
726
 
727
727
  const provider = await web3Client.getProvider(transaction.blockchain);
728
728
  const { value } = await provider.getSignatureStatus(signature);
729
- const confirmationStatus = _optionalChain$4([value, 'optionalAccess', _ => _.confirmationStatus]);
729
+ const confirmationStatus = _optionalChain$6([value, 'optionalAccess', _ => _.confirmationStatus]);
730
730
  if(confirmationStatus) {
731
731
  const hasReachedSufficientCommitment = confirmationStatus === 'confirmed' || confirmationStatus === 'finalized';
732
732
  if (hasReachedSufficientCommitment) {
733
733
  if(value.err) {
734
734
  transaction._failed = true;
735
735
  const confirmedTransaction = await provider.getConfirmedTransaction(signature);
736
- const failedReason = _optionalChain$4([confirmedTransaction, 'optionalAccess', _2 => _2.meta, 'optionalAccess', _3 => _3.logMessages]) ? confirmedTransaction.meta.logMessages[confirmedTransaction.meta.logMessages.length - 1] : null;
736
+ const failedReason = _optionalChain$6([confirmedTransaction, 'optionalAccess', _2 => _2.meta, 'optionalAccess', _3 => _3.logMessages]) ? confirmedTransaction.meta.logMessages[confirmedTransaction.meta.logMessages.length - 1] : null;
737
737
  if(transaction.failed) transaction.failed(transaction, failedReason);
738
738
  } else {
739
739
  transaction._succeeded = true;
@@ -750,15 +750,15 @@
750
750
  return transaction
751
751
  };
752
752
 
753
- const submit$2 = ({ transaction, wallet })=> {
753
+ const submit$3 = ({ transaction, wallet })=> {
754
754
  if(transaction.instructions) {
755
755
  return submitInstructions({ transaction, wallet })
756
756
  } else {
757
- return submitSimpleTransfer$2({ transaction, wallet })
757
+ return submitSimpleTransfer$3({ transaction, wallet })
758
758
  }
759
759
  };
760
760
 
761
- const submitSimpleTransfer$2 = async ({ transaction, wallet })=> {
761
+ const submitSimpleTransfer$3 = async ({ transaction, wallet })=> {
762
762
  let fromPubkey = new solanaWeb3_js.PublicKey(await wallet.account());
763
763
  let toPubkey = new solanaWeb3_js.PublicKey(transaction.to);
764
764
  const provider = await web3Client.getProvider(transaction.blockchain);
@@ -796,7 +796,7 @@
796
796
  supported$1.evm = ['ethereum', 'bsc', 'polygon', 'velas'];
797
797
  supported$1.solana = ['solana'];
798
798
 
799
- 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; }
799
+ 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; }
800
800
  class WindowSolana {
801
801
 
802
802
  static __initStatic() {this.info = {
@@ -807,8 +807,8 @@
807
807
 
808
808
  static __initStatic2() {this.isAvailable = ()=>{
809
809
  return (
810
- _optionalChain$3([window, 'optionalAccess', _4 => _4.solana]) &&
811
- !_optionalChain$3([window, 'optionalAccess', _5 => _5.solana, 'optionalAccess', _6 => _6.isPhantom])
810
+ _optionalChain$5([window, 'optionalAccess', _4 => _4.solana]) &&
811
+ !_optionalChain$5([window, 'optionalAccess', _5 => _5.solana, 'optionalAccess', _6 => _6.isPhantom])
812
812
  )
813
813
  };}
814
814
 
@@ -817,7 +817,7 @@
817
817
  this.logo = this.constructor.info.logo;
818
818
  this.blockchains = this.constructor.info.blockchains;
819
819
  this.sendTransaction = (transaction)=>{
820
- return sendTransaction$2({
820
+ return sendTransaction$3({
821
821
  wallet: this,
822
822
  transaction
823
823
  })
@@ -825,9 +825,9 @@
825
825
  }
826
826
 
827
827
  async account() {
828
- if(_optionalChain$3([window, 'optionalAccess', _7 => _7.solana]) == undefined){ return }
829
- if(_optionalChain$3([window, 'optionalAccess', _8 => _8.solana, 'optionalAccess', _9 => _9.publicKey])) { return window.solana.publicKey.toString() }
830
- if(_optionalChain$3([window, 'optionalAccess', _10 => _10.solana, 'optionalAccess', _11 => _11.isBraveWallet]) != true) {
828
+ if(_optionalChain$5([window, 'optionalAccess', _7 => _7.solana]) == undefined){ return }
829
+ if(_optionalChain$5([window, 'optionalAccess', _8 => _8.solana, 'optionalAccess', _9 => _9.publicKey])) { return window.solana.publicKey.toString() }
830
+ if(_optionalChain$5([window, 'optionalAccess', _10 => _10.solana, 'optionalAccess', _11 => _11.isBraveWallet]) != true) {
831
831
  let publicKey;
832
832
  try { ({ publicKey } = await window.solana.connect({ onlyIfTrusted: true })); } catch (e) {}
833
833
  if(publicKey){ return publicKey.toString() }
@@ -835,7 +835,7 @@
835
835
  }
836
836
 
837
837
  async connect() {
838
- if(!_optionalChain$3([window, 'optionalAccess', _12 => _12.solana])) { return undefined }
838
+ if(!_optionalChain$5([window, 'optionalAccess', _12 => _12.solana])) { return undefined }
839
839
  let { publicKey } = await window.solana.connect();
840
840
  return publicKey.toString()
841
841
  }
@@ -844,7 +844,7 @@
844
844
  let internalCallback;
845
845
  switch (event) {
846
846
  case 'account':
847
- internalCallback = (publicKey) => callback(_optionalChain$3([publicKey, 'optionalAccess', _13 => _13.toString, 'call', _14 => _14()]));
847
+ internalCallback = (publicKey) => callback(_optionalChain$5([publicKey, 'optionalAccess', _13 => _13.toString, 'call', _14 => _14()]));
848
848
  window.solana.on('accountChanged', internalCallback);
849
849
  break
850
850
  }
@@ -884,7 +884,7 @@
884
884
  }
885
885
  } WindowSolana.__initStatic(); WindowSolana.__initStatic2();
886
886
 
887
- 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; }
887
+ 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; }
888
888
  class Phantom extends WindowSolana {
889
889
 
890
890
  static __initStatic() {this.info = {
@@ -893,11 +893,11 @@
893
893
  blockchains: supported$1.solana
894
894
  };}
895
895
 
896
- static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$2([window, 'optionalAccess', _3 => _3.solana, 'optionalAccess', _4 => _4.isPhantom]) };}
896
+ static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$4([window, 'optionalAccess', _3 => _3.solana, 'optionalAccess', _4 => _4.isPhantom]) };}
897
897
  } Phantom.__initStatic(); Phantom.__initStatic2();
898
898
 
899
- 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; }
900
- const sendTransaction$1 = async ({ transaction, wallet })=> {
899
+ 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; }
900
+ const sendTransaction$2 = async ({ transaction, wallet })=> {
901
901
  transaction = new Transaction(transaction);
902
902
  if((await wallet.connectedTo(transaction.blockchain)) == false) {
903
903
  await wallet.switchTo(transaction.blockchain);
@@ -908,13 +908,13 @@
908
908
  await transaction.prepare({ wallet });
909
909
  let transactionCount = await web3Client.request({ blockchain: transaction.blockchain, method: 'transactionCount', address: transaction.from });
910
910
  transaction.nonce = transactionCount;
911
- await submit$1({ transaction, wallet }).then(async (tx)=>{
911
+ await submit$2({ transaction, wallet }).then(async (tx)=>{
912
912
  if (tx) {
913
913
  let blockchain = web3Blockchains.Blockchain.findByName(transaction.blockchain);
914
914
  transaction.id = tx;
915
915
  transaction.url = blockchain.explorerUrlFor({ transaction });
916
916
  if (transaction.sent) transaction.sent(transaction);
917
- let sentTransaction = await retrieveTransaction(tx, transaction.blockchain);
917
+ let sentTransaction = await retrieveTransaction$1(tx, transaction.blockchain);
918
918
  transaction.nonce = sentTransaction.nonce || transactionCount;
919
919
  if(!sentTransaction) {
920
920
  transaction._failed = true;
@@ -948,7 +948,7 @@
948
948
  return transaction
949
949
  };
950
950
 
951
- const retrieveTransaction = async (tx, blockchain)=>{
951
+ const retrieveTransaction$1 = async (tx, blockchain)=>{
952
952
  let sentTransaction;
953
953
  const provider = await web3Client.getProvider(blockchain);
954
954
  sentTransaction = await provider.getTransaction(tx);
@@ -962,47 +962,51 @@
962
962
  return sentTransaction
963
963
  };
964
964
 
965
- const submit$1 = ({ transaction, wallet }) => {
965
+ const submit$2 = ({ transaction, wallet }) => {
966
966
  if(transaction.method) {
967
- return submitContractInteraction$1({ transaction, wallet })
967
+ return submitContractInteraction$2({ transaction, wallet })
968
968
  } else {
969
- return submitSimpleTransfer$1({ transaction, wallet })
969
+ return submitSimpleTransfer$2({ transaction, wallet })
970
970
  }
971
971
  };
972
972
 
973
- const submitContractInteraction$1 = async ({ transaction, wallet })=>{
973
+ const submitContractInteraction$2 = async ({ transaction, wallet })=>{
974
974
  const provider = await web3Client.getProvider(transaction.blockchain);
975
975
  return wallet.connector.sendTransaction({
976
976
  from: transaction.from,
977
977
  to: transaction.to,
978
- value: _optionalChain$1([transaction, 'access', _ => _.value, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()]),
978
+ value: _optionalChain$3([transaction, 'access', _ => _.value, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()]),
979
979
  data: await transaction.getData(),
980
980
  gas: (await web3Client.estimate(transaction)).toString(),
981
- gasPrice: (await provider.getGasPrice()).toString()
981
+ gasPrice: (await provider.getGasPrice()).toString(),
982
+ nonce: transaction.nonce,
982
983
  })
983
984
  };
984
985
 
985
- const submitSimpleTransfer$1 = async ({ transaction, wallet })=>{
986
+ const submitSimpleTransfer$2 = async ({ transaction, wallet })=>{
986
987
  const provider = await web3Client.getProvider(transaction.blockchain);
987
988
  return wallet.connector.sendTransaction({
988
989
  from: transaction.from,
989
990
  to: transaction.to,
990
- value: _optionalChain$1([transaction, 'access', _4 => _4.value, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]),
991
+ value: _optionalChain$3([transaction, 'access', _4 => _4.value, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]),
991
992
  gas: (await web3Client.estimate(transaction)).toString(),
992
- gasPrice: (await provider.getGasPrice()).toString()
993
+ gasPrice: (await provider.getGasPrice()).toString(),
994
+ nonce: transaction.nonce,
993
995
  })
994
996
  };
995
997
 
996
- 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; }
997
- const getConnectedInstance$1 = ()=>{
998
- return window._connectedWalletConnectInstance
998
+ 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; }
999
+ const KEY$1 = '_DePayWeb3WalletsConnectedWalletConnectV1Instance';
1000
+
1001
+ const getConnectedInstance$2 = ()=>{
1002
+ return window[KEY$1]
999
1003
  };
1000
1004
 
1001
- const setConnectedInstance$1 = (value)=>{
1002
- window._connectedWalletConnectInstance = value;
1005
+ const setConnectedInstance$2 = (value)=>{
1006
+ window[KEY$1] = value;
1003
1007
  };
1004
1008
 
1005
- class WalletConnect {
1009
+ class WalletConnectV1 {
1006
1010
 
1007
1011
  static __initStatic() {this.info = {
1008
1012
  name: 'WalletConnect',
@@ -1011,16 +1015,16 @@
1011
1015
  };}
1012
1016
 
1013
1017
  static __initStatic2() {this.isAvailable = ()=>{
1014
- return getConnectedInstance$1() != undefined
1018
+ return getConnectedInstance$2() != undefined
1015
1019
  };}
1016
1020
 
1017
1021
  constructor() {
1018
1022
  this.name = this.constructor.info.name;
1019
1023
  this.logo = this.constructor.info.logo;
1020
1024
  this.blockchains = this.constructor.info.blockchains;
1021
- this.connector = WalletConnect.instance || this.newWalletConnectInstance();
1025
+ this.connector = WalletConnectV1.instance || this.newWalletConnectInstance();
1022
1026
  this.sendTransaction = (transaction)=>{
1023
- return sendTransaction$1({
1027
+ return sendTransaction$2({
1024
1028
  wallet: this,
1025
1029
  transaction
1026
1030
  })
@@ -1048,12 +1052,12 @@
1048
1052
  });
1049
1053
 
1050
1054
  instance.on("disconnect", (error, payload) => {
1051
- setConnectedInstance$1(undefined);
1055
+ setConnectedInstance$2(undefined);
1052
1056
  if (error) { throw error }
1053
1057
  });
1054
1058
 
1055
1059
  instance.on("modal_closed", ()=>{
1056
- setConnectedInstance$1(undefined);
1060
+ setConnectedInstance$2(undefined);
1057
1061
  this.connector = undefined;
1058
1062
  });
1059
1063
 
@@ -1075,14 +1079,14 @@
1075
1079
 
1076
1080
  if(this.connector.connected) {
1077
1081
  await this.connector.killSession();
1078
- setConnectedInstance$1(undefined);
1082
+ setConnectedInstance$2(undefined);
1079
1083
  this.connector = this.newWalletConnectInstance();
1080
1084
  }
1081
1085
 
1082
- let { accounts, chainId } = await this.connector.connect({ chainId: _optionalChain([options, 'optionalAccess', _ => _.chainId]) });
1086
+ let { accounts, chainId } = await this.connector.connect({ chainId: _optionalChain$2([options, 'optionalAccess', _ => _.chainId]) });
1083
1087
 
1084
1088
  if(accounts instanceof Array && accounts.length) {
1085
- setConnectedInstance$1(this);
1089
+ setConnectedInstance$2(this);
1086
1090
  }
1087
1091
 
1088
1092
  accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
@@ -1193,10 +1197,277 @@
1193
1197
  let signature = await this.connector.signPersonalMessage(params);
1194
1198
  return signature
1195
1199
  }
1196
- } WalletConnect.__initStatic(); WalletConnect.__initStatic2();
1200
+ } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
1201
+
1202
+ WalletConnectV1.getConnectedInstance = getConnectedInstance$2;
1203
+ WalletConnectV1.setConnectedInstance = setConnectedInstance$2;
1204
+
1205
+ 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; }
1206
+ const sendTransaction$1 = async ({ transaction, wallet })=> {
1207
+ transaction = new Transaction(transaction);
1208
+ if((await wallet.connectedTo(transaction.blockchain)) == false) {
1209
+ await wallet.switchTo(transaction.blockchain);
1210
+ }
1211
+ if((await wallet.connectedTo(transaction.blockchain)) == false) {
1212
+ throw({ code: 'WRONG_NETWORK' })
1213
+ }
1214
+ await transaction.prepare({ wallet });
1215
+ let transactionCount = await web3Client.request({ blockchain: transaction.blockchain, method: 'transactionCount', address: transaction.from });
1216
+ transaction.nonce = transactionCount;
1217
+ await submit$1({ transaction, wallet }).then(async (response)=>{
1218
+ if(typeof response == 'string') {
1219
+ let blockchain = web3Blockchains.Blockchain.findByName(transaction.blockchain);
1220
+ transaction.id = response;
1221
+ transaction.url = blockchain.explorerUrlFor({ transaction });
1222
+ if (transaction.sent) transaction.sent(transaction);
1223
+ let sentTransaction = await retrieveTransaction(transaction.id, transaction.blockchain);
1224
+ transaction.nonce = sentTransaction.nonce || transactionCount;
1225
+ if(!sentTransaction) {
1226
+ transaction._failed = true;
1227
+ console.log('Error retrieving transaction');
1228
+ if(transaction.failed) transaction.failed(transaction, 'Error retrieving transaction');
1229
+ } else {
1230
+ sentTransaction.wait(1).then(() => {
1231
+ transaction._succeeded = true;
1232
+ if (transaction.succeeded) transaction.succeeded(transaction);
1233
+ }).catch((error)=>{
1234
+ if(error && error.code && error.code == 'TRANSACTION_REPLACED') {
1235
+ if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) {
1236
+ transaction.id = error.replacement.hash;
1237
+ transaction._succeeded = true;
1238
+ if (transaction.succeeded) transaction.succeeded(transaction);
1239
+ } else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
1240
+ transaction.id = error.replacement.hash;
1241
+ transaction._failed = true;
1242
+ if(transaction.failed) transaction.failed(transaction, error);
1243
+ }
1244
+ } else {
1245
+ transaction._failed = true;
1246
+ if(transaction.failed) transaction.failed(transaction, error);
1247
+ }
1248
+ });
1249
+ }
1250
+ } else {
1251
+ throw(response)
1252
+ }
1253
+ });
1254
+ return transaction
1255
+ };
1256
+
1257
+ const retrieveTransaction = async (tx, blockchain)=>{
1258
+ let sentTransaction;
1259
+ const provider = await web3Client.getProvider(blockchain);
1260
+ sentTransaction = await provider.getTransaction(tx);
1261
+ const maxRetries = 120;
1262
+ let attempt = 1;
1263
+ while (attempt <= maxRetries && !sentTransaction) {
1264
+ sentTransaction = await provider.getTransaction(tx);
1265
+ await (new Promise((resolve)=>setTimeout(resolve, 5000)));
1266
+ attempt++;
1267
+ }
1268
+ return sentTransaction
1269
+ };
1270
+
1271
+ const submit$1 = ({ transaction, wallet }) => {
1272
+ if(transaction.method) {
1273
+ return submitContractInteraction$1({ transaction, wallet })
1274
+ } else {
1275
+ return submitSimpleTransfer$1({ transaction, wallet })
1276
+ }
1277
+ };
1278
+
1279
+ const submitContractInteraction$1 = async ({ transaction, wallet })=>{
1280
+ const provider = await web3Client.getProvider(transaction.blockchain);
1281
+ return wallet.signClient.request({
1282
+ topic: wallet.session.topic,
1283
+ chainId: wallet.session.chainId,
1284
+ request: {
1285
+ method: 'eth_sendTransaction',
1286
+ params: [{
1287
+ from: transaction.from,
1288
+ to: transaction.to,
1289
+ value: _optionalChain$1([transaction, 'access', _ => _.value, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()]),
1290
+ data: await transaction.getData(),
1291
+ gas: (await web3Client.estimate(transaction)).toString(),
1292
+ gasPrice: (await provider.getGasPrice()).toString(),
1293
+ nonce: transaction.nonce,
1294
+ }]
1295
+ }
1296
+ })
1297
+ };
1298
+
1299
+ const submitSimpleTransfer$1 = async ({ transaction, wallet })=>{
1300
+ const provider = await web3Client.getProvider(transaction.blockchain);
1301
+ let blockchain = web3Blockchains.Blockchain.findByName(transaction.blockchain);
1302
+ return wallet.signClient.request({
1303
+ topic: wallet.session.topic,
1304
+ chainId: wallet.session.chainId,
1305
+ request: {
1306
+ method: 'eth_sendTransaction',
1307
+ params: [{
1308
+ chainId: blockchain.id,
1309
+ from: transaction.from,
1310
+ to: transaction.to,
1311
+ value: _optionalChain$1([transaction, 'access', _4 => _4.value, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]),
1312
+ gas: (await web3Client.estimate(transaction)).toString(),
1313
+ gasPrice: (await provider.getGasPrice()).toString(),
1314
+ nonce: transaction.nonce
1315
+ }]
1316
+ }
1317
+ }).catch((e)=>{console.log('ERROR', e);})
1318
+ };
1319
+
1320
+ 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; }
1321
+ const KEY = '_DePayWeb3WalletsConnectedWalletConnectV2Instance';
1322
+
1323
+ const getConnectedInstance$1 = ()=>{
1324
+ return window[KEY]
1325
+ };
1326
+
1327
+ const setConnectedInstance$1 = (value)=>{
1328
+ window[KEY] = value;
1329
+ };
1330
+
1331
+ class WalletConnectV2 {
1332
+
1333
+ static __initStatic() {this.info = {
1334
+ name: 'WalletConnect',
1335
+ logo: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMjUuNC4xLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAtLT48c3ZnIHZlcnNpb249JzEuMScgaWQ9J0xheWVyXzEnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZycgeG1sbnM6eGxpbms9J2h0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsnIHg9JzBweCcgeT0nMHB4JyB2aWV3Qm94PScwIDAgNTAwIDUwMCcgc3R5bGU9J2VuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTAwIDUwMDsnIHhtbDpzcGFjZT0ncHJlc2VydmUnPjxzdHlsZSB0eXBlPSd0ZXh0L2Nzcyc+IC5zdDB7ZmlsbDojNTk5MUNEO30KPC9zdHlsZT48ZyBpZD0nUGFnZS0xJz48ZyBpZD0nd2FsbGV0Y29ubmVjdC1sb2dvLWFsdCc+PHBhdGggaWQ9J1dhbGxldENvbm5lY3QnIGNsYXNzPSdzdDAnIGQ9J00xMDIuNywxNjJjODEuNS03OS44LDIxMy42LTc5LjgsMjk1LjEsMGw5LjgsOS42YzQuMSw0LDQuMSwxMC41LDAsMTQuNEwzNzQsMjE4LjkgYy0yLDItNS4zLDItNy40LDBsLTEzLjUtMTMuMmMtNTYuOC01NS43LTE0OS01NS43LTIwNS44LDBsLTE0LjUsMTQuMWMtMiwyLTUuMywyLTcuNCwwTDkxLjksMTg3Yy00LjEtNC00LjEtMTAuNSwwLTE0LjQgTDEwMi43LDE2MnogTTQ2Ny4xLDIyOS45bDI5LjksMjkuMmM0LjEsNCw0LjEsMTAuNSwwLDE0LjRMMzYyLjMsNDA1LjRjLTQuMSw0LTEwLjcsNC0xNC44LDBjMCwwLDAsMCwwLDBMMjUyLDMxMS45IGMtMS0xLTIuNy0xLTMuNywwaDBsLTk1LjUsOTMuNWMtNC4xLDQtMTAuNyw0LTE0LjgsMGMwLDAsMCwwLDAsMEwzLjQsMjczLjZjLTQuMS00LTQuMS0xMC41LDAtMTQuNGwyOS45LTI5LjIgYzQuMS00LDEwLjctNCwxNC44LDBsOTUuNSw5My41YzEsMSwyLjcsMSwzLjcsMGMwLDAsMCwwLDAsMGw5NS41LTkzLjVjNC4xLTQsMTAuNy00LDE0LjgsMGMwLDAsMCwwLDAsMGw5NS41LDkzLjUgYzEsMSwyLjcsMSwzLjcsMGw5NS41LTkzLjVDNDU2LjQsMjI1LjksNDYzLDIyNS45LDQ2Ny4xLDIyOS45eicvPjwvZz48L2c+PC9zdmc+Cg==",
1336
+ blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
1337
+ };}
1338
+
1339
+ static __initStatic2() {this.isAvailable = ()=>{
1340
+ return getConnectedInstance$1() != undefined
1341
+ };}
1342
+
1343
+ constructor() {
1344
+ this.name = this.constructor.info.name;
1345
+ this.logo = this.constructor.info.logo;
1346
+ this.blockchains = this.constructor.info.blockchains;
1347
+ this.connector = WalletConnect.instance || this.newWalletConnectInstance();
1348
+ WalletConnect.instance = this.connector;
1349
+ this.sendTransaction = (transaction)=>{
1350
+ return sendTransaction$1({
1351
+ wallet: this,
1352
+ transaction
1353
+ })
1354
+ };
1355
+ }
1356
+
1357
+ newWalletConnectInstance() {
1358
+ return new walletconnectV2.Core({ projectId: window._walletConnectProjectId })
1359
+ }
1360
+
1361
+ async account() {
1362
+ if(this.connectedAccount == undefined) { return }
1363
+ return this.connectedAccount
1364
+ }
1365
+
1366
+ async connect({ connect, blockchain }) {
1367
+
1368
+ if(!connect || typeof connect != 'function') { throw('Provided connect paremeters is not present or not a function!') }
1369
+
1370
+ try {
1371
+
1372
+ delete localStorage[`wc@2:core:${this.connector.pairing.version}//subscription`]; // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
1373
+ this.signClient = await walletconnectV2.SignClient.init({ core: this.connector });
1374
+
1375
+ this.signClient.on("session_delete", () => {
1376
+ console.log('WALLETCONNECT DISCONNECT');
1377
+ this.connector = undefined;
1378
+ WalletConnect.instance = undefined;
1379
+ this.connectedAccount = undefined;
1380
+ this.signClient = undefined;
1381
+ this.session = undefined;
1382
+ });
1383
+
1384
+ blockchain = web3Blockchains.Blockchain.findByName(blockchain);
1385
+
1386
+ let namespaces = {};
1387
+
1388
+ namespaces[blockchain.namespace] = {
1389
+ methods: [
1390
+ "eth_sendTransaction",
1391
+ "personal_sign",
1392
+ ],
1393
+ chains: [`${blockchain.namespace}:${blockchain.networkId}`],
1394
+ events: [],
1395
+ };
1396
+
1397
+ const { uri, approval } = await this.signClient.connect({ requiredNamespaces: namespaces });
1398
+
1399
+ await connect({ uri });
1400
+ this.session = await approval();
1401
+ this.session.chainId = `${blockchain.namespace}:${blockchain.networkId}`;
1402
+
1403
+ let meta = _optionalChain([this, 'access', _ => _.session, 'optionalAccess', _2 => _2.peer, 'optionalAccess', _3 => _3.metadata]);
1404
+ if(meta && meta.name) {
1405
+ this.name = meta.name;
1406
+ if(_optionalChain([meta, 'optionalAccess', _4 => _4.icons]) && meta.icons.length) { this.logo = meta.icons[0]; }
1407
+ }
1408
+
1409
+ const account = Object.values(this.session.namespaces)[0].accounts[0].split(":")[2];
1410
+ this.connectedAccount = account;
1411
+ this.connectedBlockchain = blockchain.name;
1412
+
1413
+ return account
1414
+
1415
+ } catch (error) {
1416
+ console.log('WALLETCONNECT ERROR', error);
1417
+ }
1418
+ }
1419
+
1420
+ async connectedTo(input) {
1421
+ if(input) {
1422
+ return input === this.connectedBlockchain
1423
+ } else {
1424
+ const blockchain = web3Blockchains.Blockchain.findByName(this.connectedBlockchain);
1425
+ return blockchain.name
1426
+ }
1427
+ }
1428
+
1429
+ switchTo(blockchainName) {
1430
+ return new Promise((resolve, reject)=>{
1431
+ reject({ code: 'NOT_SUPPORTED' });
1432
+ })
1433
+ }
1434
+
1435
+ addNetwork(blockchainName) {
1436
+ return new Promise((resolve, reject)=>{
1437
+ reject({ code: 'NOT_SUPPORTED' });
1438
+ })
1439
+ }
1440
+
1441
+ on(event, callback) {
1442
+ // currently not supported
1443
+ }
1444
+
1445
+ off(event, callback) {
1446
+ // currently not supported
1447
+ }
1448
+
1449
+ async sign(message) {
1450
+ let address = await this.account();
1451
+ var params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
1452
+ let signature = await this.signClient.request({
1453
+ topic: this.session.topic,
1454
+ chainId: this.session.chainId,
1455
+ request:{
1456
+ id: 1,
1457
+ jsonrpc: '2.0',
1458
+ method: 'personal_sign',
1459
+ params
1460
+ }
1461
+ });
1462
+ if(typeof signature == 'object') {
1463
+ signature = ethers.ethers.utils.hexlify(signature);
1464
+ }
1465
+ return signature
1466
+ }
1467
+ } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
1197
1468
 
1198
- WalletConnect.getConnectedInstance = getConnectedInstance$1;
1199
- WalletConnect.setConnectedInstance = setConnectedInstance$1;
1469
+ WalletConnectV2.getConnectedInstance = getConnectedInstance$1;
1470
+ WalletConnectV2.setConnectedInstance = setConnectedInstance$1;
1200
1471
 
1201
1472
  const sendTransaction = async ({ transaction, wallet })=> {
1202
1473
  transaction = new Transaction(transaction);
@@ -1414,7 +1685,8 @@
1414
1685
  Coinbase,
1415
1686
  WindowEthereum,
1416
1687
  WindowSolana,
1417
- WalletConnect,
1688
+ WalletConnectV1,
1689
+ WalletConnectV2,
1418
1690
  WalletLink
1419
1691
  };
1420
1692
 
@@ -1457,7 +1729,8 @@
1457
1729
  wallets.MetaMask,
1458
1730
  wallets.Phantom,
1459
1731
  wallets.Coinbase,
1460
- wallets.WalletConnect,
1732
+ wallets.WalletConnectV1,
1733
+ wallets.WalletConnectV2,
1461
1734
  wallets.WalletLink
1462
1735
  ];
1463
1736