@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/README.md +7 -39
- package/dist/esm/index.evm.js +96 -384
- package/dist/esm/index.js +117 -405
- package/dist/umd/index.evm.js +99 -387
- package/dist/umd/index.js +120 -408
- package/package.json +1 -1
package/dist/esm/index.evm.js
CHANGED
|
@@ -3,7 +3,6 @@ import { ethers } from 'ethers';
|
|
|
3
3
|
import { CONSTANTS } from '@depay/web3-constants';
|
|
4
4
|
import { request as request$3 } from '@depay/web3-client-evm';
|
|
5
5
|
import { WalletConnectClient } from '@depay/walletconnect-v1';
|
|
6
|
-
import { Core, SignClient } from '@depay/walletconnect-v2';
|
|
7
6
|
import { CoinbaseWalletSDK } from '@depay/coinbase-wallet-sdk';
|
|
8
7
|
|
|
9
8
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -59485,7 +59484,7 @@ const getProvider = async (blockchain)=>{
|
|
|
59485
59484
|
}
|
|
59486
59485
|
};
|
|
59487
59486
|
|
|
59488
|
-
function _optionalChain$
|
|
59487
|
+
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; }
|
|
59489
59488
|
class Transaction {
|
|
59490
59489
|
|
|
59491
59490
|
constructor({ blockchain, from, to, value, api, method, params, instructions, sent, succeeded, failed }) {
|
|
@@ -59496,7 +59495,7 @@ class Transaction {
|
|
|
59496
59495
|
this.to = (to && to.match('0x')) ? ethers.utils.getAddress(to) : to;
|
|
59497
59496
|
|
|
59498
59497
|
// optional
|
|
59499
|
-
this.value = _optionalChain$
|
|
59498
|
+
this.value = _optionalChain$c([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
59500
59499
|
this.api = api;
|
|
59501
59500
|
this.method = method;
|
|
59502
59501
|
this.params = params;
|
|
@@ -59583,7 +59582,7 @@ class Transaction {
|
|
|
59583
59582
|
}
|
|
59584
59583
|
}
|
|
59585
59584
|
|
|
59586
|
-
const sendTransaction$
|
|
59585
|
+
const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
59587
59586
|
transaction = new Transaction(transaction);
|
|
59588
59587
|
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
59589
59588
|
await wallet.switchTo(transaction.blockchain);
|
|
@@ -59596,7 +59595,7 @@ const sendTransaction$4 = async ({ transaction, wallet })=> {
|
|
|
59596
59595
|
transaction.nonce = transactionCount;
|
|
59597
59596
|
let provider = new ethers.providers.Web3Provider(wallet.getProvider(), 'any');
|
|
59598
59597
|
let signer = provider.getSigner(0);
|
|
59599
|
-
await submit$
|
|
59598
|
+
await submit$3({ transaction, provider, signer }).then((sentTransaction)=>{
|
|
59600
59599
|
if (sentTransaction) {
|
|
59601
59600
|
transaction.id = sentTransaction.hash;
|
|
59602
59601
|
transaction.nonce = sentTransaction.nonce || transactionCount;
|
|
@@ -59630,15 +59629,15 @@ const sendTransaction$4 = async ({ transaction, wallet })=> {
|
|
|
59630
59629
|
return transaction
|
|
59631
59630
|
};
|
|
59632
59631
|
|
|
59633
|
-
const submit$
|
|
59632
|
+
const submit$3 = ({ transaction, provider, signer }) => {
|
|
59634
59633
|
if(transaction.method) {
|
|
59635
|
-
return submitContractInteraction$
|
|
59634
|
+
return submitContractInteraction$2({ transaction, signer, provider })
|
|
59636
59635
|
} else {
|
|
59637
|
-
return submitSimpleTransfer$
|
|
59636
|
+
return submitSimpleTransfer$3({ transaction, signer })
|
|
59638
59637
|
}
|
|
59639
59638
|
};
|
|
59640
59639
|
|
|
59641
|
-
const submitContractInteraction$
|
|
59640
|
+
const submitContractInteraction$2 = ({ transaction, signer, provider })=>{
|
|
59642
59641
|
let contract = new ethers.Contract(transaction.to, transaction.api, provider);
|
|
59643
59642
|
let contractArguments = transaction.getContractArguments({ contract });
|
|
59644
59643
|
let method = contract.connect(signer)[transaction.method];
|
|
@@ -59653,7 +59652,7 @@ const submitContractInteraction$3 = ({ transaction, signer, provider })=>{
|
|
|
59653
59652
|
}
|
|
59654
59653
|
};
|
|
59655
59654
|
|
|
59656
|
-
const submitSimpleTransfer$
|
|
59655
|
+
const submitSimpleTransfer$3 = ({ transaction, signer })=>{
|
|
59657
59656
|
return signer.sendTransaction({
|
|
59658
59657
|
to: transaction.to,
|
|
59659
59658
|
value: Transaction.bigNumberify(transaction.value, transaction.blockchain)
|
|
@@ -59664,7 +59663,7 @@ let supported$2 = ['ethereum', 'bsc', 'polygon', 'velas'];
|
|
|
59664
59663
|
supported$2.evm = ['ethereum', 'bsc', 'polygon', 'velas'];
|
|
59665
59664
|
supported$2.solana = [];
|
|
59666
59665
|
|
|
59667
|
-
function _optionalChain$
|
|
59666
|
+
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; }
|
|
59668
59667
|
class WindowEthereum {
|
|
59669
59668
|
|
|
59670
59669
|
static __initStatic() {this.info = {
|
|
@@ -59675,12 +59674,12 @@ class WindowEthereum {
|
|
|
59675
59674
|
|
|
59676
59675
|
static __initStatic2() {this.isAvailable = ()=>{
|
|
59677
59676
|
return (
|
|
59678
|
-
_optionalChain$
|
|
59677
|
+
_optionalChain$b([window, 'optionalAccess', _13 => _13.ethereum]) &&
|
|
59679
59678
|
Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)/)).length != 1 && // MetaMask
|
|
59680
|
-
!_optionalChain$
|
|
59681
|
-
!(_optionalChain$
|
|
59682
|
-
!_optionalChain$
|
|
59683
|
-
!(_optionalChain$
|
|
59679
|
+
!_optionalChain$b([window, 'optionalAccess', _14 => _14.coin98]) && // Coin98
|
|
59680
|
+
!(_optionalChain$b([window, 'optionalAccess', _15 => _15.ethereum, 'optionalAccess', _16 => _16.isTrust]) || _optionalChain$b([window, 'optionalAccess', _17 => _17.ethereum, 'optionalAccess', _18 => _18.isTrustWallet])) && // Trust Wallet
|
|
59681
|
+
!_optionalChain$b([window, 'optionalAccess', _19 => _19.ethereum, 'optionalAccess', _20 => _20.isDeficonnectProvider]) && // crypto.com
|
|
59682
|
+
!(_optionalChain$b([window, 'optionalAccess', _21 => _21.ethereum, 'optionalAccess', _22 => _22.isCoinbaseWallet]) || _optionalChain$b([window, 'optionalAccess', _23 => _23.ethereum, 'optionalAccess', _24 => _24.isWalletLink]))
|
|
59684
59683
|
)
|
|
59685
59684
|
};}
|
|
59686
59685
|
|
|
@@ -59689,7 +59688,7 @@ class WindowEthereum {
|
|
|
59689
59688
|
this.logo = this.constructor.info.logo;
|
|
59690
59689
|
this.blockchains = this.constructor.info.blockchains;
|
|
59691
59690
|
this.sendTransaction = (transaction)=>{
|
|
59692
|
-
return sendTransaction$
|
|
59691
|
+
return sendTransaction$3({
|
|
59693
59692
|
wallet: this,
|
|
59694
59693
|
transaction
|
|
59695
59694
|
})
|
|
@@ -59791,7 +59790,7 @@ class WindowEthereum {
|
|
|
59791
59790
|
}
|
|
59792
59791
|
} WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
|
|
59793
59792
|
|
|
59794
|
-
function _optionalChain$
|
|
59793
|
+
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; }
|
|
59795
59794
|
class Binance extends WindowEthereum {
|
|
59796
59795
|
|
|
59797
59796
|
static __initStatic() {this.info = {
|
|
@@ -59801,7 +59800,7 @@ class Binance extends WindowEthereum {
|
|
|
59801
59800
|
};}
|
|
59802
59801
|
|
|
59803
59802
|
static __initStatic2() {this.isAvailable = ()=>{
|
|
59804
|
-
return _optionalChain$
|
|
59803
|
+
return _optionalChain$a([window, 'optionalAccess', _2 => _2.BinanceChain]) &&
|
|
59805
59804
|
!window.coin98
|
|
59806
59805
|
};}
|
|
59807
59806
|
|
|
@@ -59809,7 +59808,7 @@ class Binance extends WindowEthereum {
|
|
|
59809
59808
|
|
|
59810
59809
|
} Binance.__initStatic(); Binance.__initStatic2();
|
|
59811
59810
|
|
|
59812
|
-
function _optionalChain$
|
|
59811
|
+
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; }
|
|
59813
59812
|
class Brave extends WindowEthereum {
|
|
59814
59813
|
|
|
59815
59814
|
static __initStatic() {this.info = {
|
|
@@ -59818,10 +59817,10 @@ class Brave extends WindowEthereum {
|
|
|
59818
59817
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
59819
59818
|
};}
|
|
59820
59819
|
|
|
59821
|
-
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$
|
|
59820
|
+
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$9([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isBraveWallet]) };}
|
|
59822
59821
|
} Brave.__initStatic(); Brave.__initStatic2();
|
|
59823
59822
|
|
|
59824
|
-
function _optionalChain$
|
|
59823
|
+
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; }
|
|
59825
59824
|
class Coin98 extends WindowEthereum {
|
|
59826
59825
|
|
|
59827
59826
|
static __initStatic() {this.info = {
|
|
@@ -59830,10 +59829,10 @@ class Coin98 extends WindowEthereum {
|
|
|
59830
59829
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
59831
59830
|
};}
|
|
59832
59831
|
|
|
59833
|
-
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$
|
|
59832
|
+
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$8([window, 'optionalAccess', _2 => _2.coin98]) };}
|
|
59834
59833
|
} Coin98.__initStatic(); Coin98.__initStatic2();
|
|
59835
59834
|
|
|
59836
|
-
function _optionalChain$
|
|
59835
|
+
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; }
|
|
59837
59836
|
class Coinbase extends WindowEthereum {
|
|
59838
59837
|
|
|
59839
59838
|
static __initStatic() {this.info = {
|
|
@@ -59842,10 +59841,10 @@ class Coinbase extends WindowEthereum {
|
|
|
59842
59841
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
59843
59842
|
};}
|
|
59844
59843
|
|
|
59845
|
-
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$
|
|
59844
|
+
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$7([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isCoinbaseWallet]) || _optionalChain$7([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isWalletLink])) };}
|
|
59846
59845
|
} Coinbase.__initStatic(); Coinbase.__initStatic2();
|
|
59847
59846
|
|
|
59848
|
-
function _optionalChain$
|
|
59847
|
+
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; }
|
|
59849
59848
|
class CryptoCom extends WindowEthereum {
|
|
59850
59849
|
|
|
59851
59850
|
static __initStatic() {this.info = {
|
|
@@ -59854,10 +59853,10 @@ class CryptoCom extends WindowEthereum {
|
|
|
59854
59853
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
59855
59854
|
};}
|
|
59856
59855
|
|
|
59857
|
-
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$
|
|
59856
|
+
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$6([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isDeficonnectProvider]) };}
|
|
59858
59857
|
} CryptoCom.__initStatic(); CryptoCom.__initStatic2();
|
|
59859
59858
|
|
|
59860
|
-
function _optionalChain$
|
|
59859
|
+
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; }
|
|
59861
59860
|
class MetaMask extends WindowEthereum {
|
|
59862
59861
|
|
|
59863
59862
|
static __initStatic() {this.info = {
|
|
@@ -59867,11 +59866,11 @@ class MetaMask extends WindowEthereum {
|
|
|
59867
59866
|
};}
|
|
59868
59867
|
|
|
59869
59868
|
static __initStatic2() {this.isAvailable = ()=>{
|
|
59870
|
-
return _optionalChain$
|
|
59869
|
+
return _optionalChain$5([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isMetaMask]) && Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)/)).length == 1
|
|
59871
59870
|
};}
|
|
59872
59871
|
} MetaMask.__initStatic(); MetaMask.__initStatic2();
|
|
59873
59872
|
|
|
59874
|
-
function _optionalChain$
|
|
59873
|
+
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; }
|
|
59875
59874
|
class Opera extends WindowEthereum {
|
|
59876
59875
|
|
|
59877
59876
|
static __initStatic() {this.info = {
|
|
@@ -59880,10 +59879,10 @@ class Opera extends WindowEthereum {
|
|
|
59880
59879
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
59881
59880
|
};}
|
|
59882
59881
|
|
|
59883
|
-
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$
|
|
59882
|
+
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$4([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isOpera]) };}
|
|
59884
59883
|
} Opera.__initStatic(); Opera.__initStatic2();
|
|
59885
59884
|
|
|
59886
|
-
function _optionalChain$
|
|
59885
|
+
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; }
|
|
59887
59886
|
class Trust extends WindowEthereum {
|
|
59888
59887
|
|
|
59889
59888
|
static __initStatic() {this.info = {
|
|
@@ -59892,7 +59891,7 @@ class Trust extends WindowEthereum {
|
|
|
59892
59891
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
59893
59892
|
};}
|
|
59894
59893
|
|
|
59895
|
-
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$
|
|
59894
|
+
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])) };}
|
|
59896
59895
|
} Trust.__initStatic(); Trust.__initStatic2();
|
|
59897
59896
|
|
|
59898
59897
|
class Argent {
|
|
@@ -60007,7 +60006,7 @@ const getSmartContractWallet = async(blockchain, address)=> {
|
|
|
60007
60006
|
}
|
|
60008
60007
|
};
|
|
60009
60008
|
|
|
60010
|
-
const sendTransaction$
|
|
60009
|
+
const sendTransaction$2 = async ({ transaction, wallet })=> {
|
|
60011
60010
|
transaction = new Transaction(transaction);
|
|
60012
60011
|
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
60013
60012
|
await wallet.switchTo(transaction.blockchain);
|
|
@@ -60019,13 +60018,13 @@ const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
|
60019
60018
|
const smartContractWallet = await getSmartContractWallet(transaction.blockchain, transaction.from);
|
|
60020
60019
|
let transactionCount = await wallet.transactionCount({ blockchain: transaction.blockchain, address: transaction.from });
|
|
60021
60020
|
transaction.nonce = transactionCount;
|
|
60022
|
-
await submit$
|
|
60021
|
+
await submit$2({ transaction, wallet }).then((tx)=>{
|
|
60023
60022
|
if (tx) {
|
|
60024
60023
|
let blockchain = Blockchain.findByName(transaction.blockchain);
|
|
60025
60024
|
transaction.id = tx;
|
|
60026
60025
|
transaction.url = smartContractWallet && smartContractWallet.explorerUrlFor ? smartContractWallet.explorerUrlFor({ transaction }) : blockchain.explorerUrlFor({ transaction });
|
|
60027
60026
|
if (transaction.sent) transaction.sent(transaction);
|
|
60028
|
-
retrieveTransaction
|
|
60027
|
+
retrieveTransaction({ blockchain: transaction.blockchain, tx, smartContractWallet }).then((sentTransaction)=>{
|
|
60029
60028
|
transaction.id = sentTransaction.hash || transaction.id;
|
|
60030
60029
|
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
60031
60030
|
transaction.nonce = sentTransaction.nonce || transactionCount;
|
|
@@ -60056,7 +60055,7 @@ const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
|
60056
60055
|
return transaction
|
|
60057
60056
|
};
|
|
60058
60057
|
|
|
60059
|
-
const retrieveTransaction
|
|
60058
|
+
const retrieveTransaction = async ({ blockchain, tx, smartContractWallet })=>{
|
|
60060
60059
|
const provider = await getProvider(blockchain);
|
|
60061
60060
|
let retrieve = async()=>{
|
|
60062
60061
|
try {
|
|
@@ -60077,15 +60076,15 @@ const retrieveTransaction$1 = async ({ blockchain, tx, smartContractWallet })=>{
|
|
|
60077
60076
|
return sentTransaction
|
|
60078
60077
|
};
|
|
60079
60078
|
|
|
60080
|
-
const submit$
|
|
60079
|
+
const submit$2 = ({ transaction, wallet }) => {
|
|
60081
60080
|
if(transaction.method) {
|
|
60082
|
-
return submitContractInteraction$
|
|
60081
|
+
return submitContractInteraction$1({ transaction, wallet })
|
|
60083
60082
|
} else {
|
|
60084
|
-
return submitSimpleTransfer$
|
|
60083
|
+
return submitSimpleTransfer$2({ transaction, wallet })
|
|
60085
60084
|
}
|
|
60086
60085
|
};
|
|
60087
60086
|
|
|
60088
|
-
const submitContractInteraction$
|
|
60087
|
+
const submitContractInteraction$1 = async ({ transaction, wallet })=>{
|
|
60089
60088
|
const provider = await getProvider(transaction.blockchain);
|
|
60090
60089
|
const gasPrice = await provider.getGasPrice();
|
|
60091
60090
|
const gas = await estimate(transaction);
|
|
@@ -60103,7 +60102,7 @@ const submitContractInteraction$2 = async ({ transaction, wallet })=>{
|
|
|
60103
60102
|
})
|
|
60104
60103
|
};
|
|
60105
60104
|
|
|
60106
|
-
const submitSimpleTransfer$
|
|
60105
|
+
const submitSimpleTransfer$2 = async ({ transaction, wallet })=>{
|
|
60107
60106
|
const provider = await getProvider(transaction.blockchain);
|
|
60108
60107
|
const gasPrice = await provider.getGasPrice();
|
|
60109
60108
|
const gas = await estimate(transaction);
|
|
@@ -60120,17 +60119,30 @@ const submitSimpleTransfer$3 = async ({ transaction, wallet })=>{
|
|
|
60120
60119
|
})
|
|
60121
60120
|
};
|
|
60122
60121
|
|
|
60123
|
-
function _optionalChain$
|
|
60124
|
-
const KEY
|
|
60122
|
+
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; }
|
|
60123
|
+
const KEY = '_DePayWeb3WalletsConnectedWalletConnectV1Instance';
|
|
60124
|
+
|
|
60125
|
+
let currentPlainInstance;
|
|
60126
|
+
|
|
60127
|
+
const getPlainInstance = ()=>{
|
|
60128
|
+
if(currentPlainInstance) { return currentPlainInstance }
|
|
60129
|
+
currentPlainInstance = getWalletConnectInstance(()=>{});
|
|
60130
|
+
};
|
|
60125
60131
|
|
|
60126
|
-
const
|
|
60127
|
-
|
|
60128
|
-
let
|
|
60129
|
-
|
|
60132
|
+
const isConnected = async()=>{
|
|
60133
|
+
let connector = getPlainInstance();
|
|
60134
|
+
let account;
|
|
60135
|
+
try { account = await connector.sendCustomRequest({ method: 'eth_chainId' }); } catch (e) {}
|
|
60136
|
+
return !!account
|
|
60130
60137
|
};
|
|
60131
60138
|
|
|
60132
|
-
const
|
|
60133
|
-
window[KEY
|
|
60139
|
+
const getConnectedInstance$1 = async()=>{
|
|
60140
|
+
if(window[KEY]) { return window[KEY] }
|
|
60141
|
+
if(await isConnected()) { return new WalletConnectV1() }
|
|
60142
|
+
};
|
|
60143
|
+
|
|
60144
|
+
const setConnectedInstance$1 = (value)=>{
|
|
60145
|
+
window[KEY] = value;
|
|
60134
60146
|
};
|
|
60135
60147
|
|
|
60136
60148
|
const getWalletConnectInstance = (connect)=>{
|
|
@@ -60152,16 +60164,15 @@ class WalletConnectV1 {
|
|
|
60152
60164
|
};}
|
|
60153
60165
|
|
|
60154
60166
|
static __initStatic2() {this.isAvailable = ()=>{
|
|
60155
|
-
|
|
60156
|
-
return getConnectedInstance$2() != undefined || connector.connected
|
|
60167
|
+
return getConnectedInstance$1() != undefined
|
|
60157
60168
|
};}
|
|
60158
60169
|
|
|
60159
60170
|
constructor() {
|
|
60160
|
-
this.name = localStorage[KEY
|
|
60161
|
-
this.logo = localStorage[KEY
|
|
60171
|
+
this.name = (localStorage[KEY+'_name'] && localStorage[KEY+'_name'] != 'undefined') ? localStorage[KEY+'_name'] : this.constructor.info.name;
|
|
60172
|
+
this.logo = (localStorage[KEY+'_logo'] && localStorage[KEY+'_logo'] != 'undefined') ? localStorage[KEY+'_logo'] : this.constructor.info.logo;
|
|
60162
60173
|
this.blockchains = this.constructor.info.blockchains;
|
|
60163
60174
|
this.sendTransaction = (transaction)=>{
|
|
60164
|
-
return sendTransaction$
|
|
60175
|
+
return sendTransaction$2({
|
|
60165
60176
|
wallet: this,
|
|
60166
60177
|
transaction
|
|
60167
60178
|
})
|
|
@@ -60186,14 +60197,14 @@ class WalletConnectV1 {
|
|
|
60186
60197
|
});
|
|
60187
60198
|
|
|
60188
60199
|
instance.on("disconnect", (error, payload) => {
|
|
60189
|
-
setConnectedInstance$
|
|
60190
|
-
localStorage[KEY
|
|
60191
|
-
localStorage[KEY
|
|
60200
|
+
setConnectedInstance$1(undefined);
|
|
60201
|
+
localStorage[KEY+'_name'] = undefined;
|
|
60202
|
+
localStorage[KEY+'_logo'] = undefined;
|
|
60192
60203
|
if (error) { throw error }
|
|
60193
60204
|
});
|
|
60194
60205
|
|
|
60195
60206
|
instance.on("modal_closed", ()=>{
|
|
60196
|
-
setConnectedInstance$
|
|
60207
|
+
setConnectedInstance$1(undefined);
|
|
60197
60208
|
this.connector = undefined;
|
|
60198
60209
|
});
|
|
60199
60210
|
|
|
@@ -60226,11 +60237,11 @@ class WalletConnectV1 {
|
|
|
60226
60237
|
|
|
60227
60238
|
let { accounts, chainId } = await this.connector.connect();
|
|
60228
60239
|
|
|
60229
|
-
if(_optionalChain$
|
|
60230
|
-
if(_optionalChain$
|
|
60240
|
+
if(_optionalChain$2([options, 'optionalAccess', _ => _.name])) { localStorage[KEY+'_name'] = this.name = options.name; }
|
|
60241
|
+
if(_optionalChain$2([options, 'optionalAccess', _2 => _2.logo])) { localStorage[KEY+'_logo'] = this.logo = options.logo; }
|
|
60231
60242
|
|
|
60232
60243
|
if(accounts instanceof Array && accounts.length) {
|
|
60233
|
-
setConnectedInstance$
|
|
60244
|
+
setConnectedInstance$1(this);
|
|
60234
60245
|
accounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
60235
60246
|
this.connectedChainId = chainId;
|
|
60236
60247
|
|
|
@@ -60354,298 +60365,8 @@ class WalletConnectV1 {
|
|
|
60354
60365
|
}
|
|
60355
60366
|
} WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
|
|
60356
60367
|
|
|
60357
|
-
WalletConnectV1.getConnectedInstance = getConnectedInstance$
|
|
60358
|
-
WalletConnectV1.setConnectedInstance = setConnectedInstance$
|
|
60359
|
-
|
|
60360
|
-
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; }
|
|
60361
|
-
const sendTransaction$2 = async ({ transaction, wallet })=> {
|
|
60362
|
-
transaction = new Transaction(transaction);
|
|
60363
|
-
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
60364
|
-
await wallet.switchTo(transaction.blockchain);
|
|
60365
|
-
}
|
|
60366
|
-
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
60367
|
-
throw({ code: 'WRONG_NETWORK' })
|
|
60368
|
-
}
|
|
60369
|
-
await transaction.prepare({ wallet });
|
|
60370
|
-
let transactionCount = await request$1({ blockchain: transaction.blockchain, method: 'transactionCount', address: transaction.from });
|
|
60371
|
-
transaction.nonce = transactionCount;
|
|
60372
|
-
await submit$2({ transaction, wallet }).then(async (response)=>{
|
|
60373
|
-
if(typeof response == 'string') {
|
|
60374
|
-
let blockchain = Blockchain.findByName(transaction.blockchain);
|
|
60375
|
-
transaction.id = response;
|
|
60376
|
-
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
60377
|
-
if (transaction.sent) transaction.sent(transaction);
|
|
60378
|
-
let sentTransaction = await retrieveTransaction(transaction.id, transaction.blockchain);
|
|
60379
|
-
transaction.nonce = sentTransaction.nonce || transactionCount;
|
|
60380
|
-
if(!sentTransaction) {
|
|
60381
|
-
transaction._failed = true;
|
|
60382
|
-
console.log('Error retrieving transaction');
|
|
60383
|
-
if(transaction.failed) transaction.failed(transaction, 'Error retrieving transaction');
|
|
60384
|
-
} else {
|
|
60385
|
-
sentTransaction.wait(1).then(() => {
|
|
60386
|
-
transaction._succeeded = true;
|
|
60387
|
-
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
60388
|
-
}).catch((error)=>{
|
|
60389
|
-
if(error && error.code && error.code == 'TRANSACTION_REPLACED') {
|
|
60390
|
-
if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) {
|
|
60391
|
-
transaction.id = error.replacement.hash;
|
|
60392
|
-
transaction._succeeded = true;
|
|
60393
|
-
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
60394
|
-
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
60395
|
-
transaction.id = error.replacement.hash;
|
|
60396
|
-
transaction._failed = true;
|
|
60397
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
60398
|
-
}
|
|
60399
|
-
} else {
|
|
60400
|
-
transaction._failed = true;
|
|
60401
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
60402
|
-
}
|
|
60403
|
-
});
|
|
60404
|
-
}
|
|
60405
|
-
} else {
|
|
60406
|
-
throw(response)
|
|
60407
|
-
}
|
|
60408
|
-
});
|
|
60409
|
-
return transaction
|
|
60410
|
-
};
|
|
60411
|
-
|
|
60412
|
-
const retrieveTransaction = async (tx, blockchain)=>{
|
|
60413
|
-
let sentTransaction;
|
|
60414
|
-
const provider = await getProvider(blockchain);
|
|
60415
|
-
sentTransaction = await provider.getTransaction(tx);
|
|
60416
|
-
const maxRetries = 120;
|
|
60417
|
-
let attempt = 1;
|
|
60418
|
-
while (attempt <= maxRetries && !sentTransaction) {
|
|
60419
|
-
sentTransaction = await provider.getTransaction(tx);
|
|
60420
|
-
await (new Promise((resolve)=>setTimeout(resolve, 5000)));
|
|
60421
|
-
attempt++;
|
|
60422
|
-
}
|
|
60423
|
-
return sentTransaction
|
|
60424
|
-
};
|
|
60425
|
-
|
|
60426
|
-
const submit$2 = ({ transaction, wallet }) => {
|
|
60427
|
-
if(transaction.method) {
|
|
60428
|
-
return submitContractInteraction$1({ transaction, wallet })
|
|
60429
|
-
} else {
|
|
60430
|
-
return submitSimpleTransfer$2({ transaction, wallet })
|
|
60431
|
-
}
|
|
60432
|
-
};
|
|
60433
|
-
|
|
60434
|
-
const submitContractInteraction$1 = async ({ transaction, wallet })=>{
|
|
60435
|
-
const provider = await getProvider(transaction.blockchain);
|
|
60436
|
-
return wallet.signClient.request({
|
|
60437
|
-
topic: wallet.session.topic,
|
|
60438
|
-
chainId: wallet.session.chainId,
|
|
60439
|
-
request: {
|
|
60440
|
-
method: 'eth_sendTransaction',
|
|
60441
|
-
params: [{
|
|
60442
|
-
from: transaction.from,
|
|
60443
|
-
to: transaction.to,
|
|
60444
|
-
value: _optionalChain$3([transaction, 'access', _ => _.value, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()]),
|
|
60445
|
-
data: await transaction.getData(),
|
|
60446
|
-
gas: (await estimate(transaction)).toString(),
|
|
60447
|
-
gasPrice: (await provider.getGasPrice()).toString(),
|
|
60448
|
-
nonce: transaction.nonce,
|
|
60449
|
-
}]
|
|
60450
|
-
}
|
|
60451
|
-
})
|
|
60452
|
-
};
|
|
60453
|
-
|
|
60454
|
-
const submitSimpleTransfer$2 = async ({ transaction, wallet })=>{
|
|
60455
|
-
const provider = await getProvider(transaction.blockchain);
|
|
60456
|
-
let blockchain = Blockchain.findByName(transaction.blockchain);
|
|
60457
|
-
return wallet.signClient.request({
|
|
60458
|
-
topic: wallet.session.topic,
|
|
60459
|
-
chainId: wallet.session.chainId,
|
|
60460
|
-
request: {
|
|
60461
|
-
method: 'eth_sendTransaction',
|
|
60462
|
-
params: [{
|
|
60463
|
-
chainId: blockchain.id,
|
|
60464
|
-
from: transaction.from,
|
|
60465
|
-
to: transaction.to,
|
|
60466
|
-
value: _optionalChain$3([transaction, 'access', _4 => _4.value, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]),
|
|
60467
|
-
gas: (await estimate(transaction)).toString(),
|
|
60468
|
-
gasPrice: (await provider.getGasPrice()).toString(),
|
|
60469
|
-
nonce: transaction.nonce
|
|
60470
|
-
}]
|
|
60471
|
-
}
|
|
60472
|
-
}).catch((e)=>{console.log('ERROR', e);})
|
|
60473
|
-
};
|
|
60474
|
-
|
|
60475
|
-
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; }
|
|
60476
|
-
const KEY = '_DePayWeb3WalletsConnectedWalletConnectV2Instance';
|
|
60477
|
-
|
|
60478
|
-
const getConnectedInstance$1 = ()=>{
|
|
60479
|
-
return window[KEY]
|
|
60480
|
-
};
|
|
60481
|
-
|
|
60482
|
-
const setConnectedInstance$1 = (value)=>{
|
|
60483
|
-
window[KEY] = value;
|
|
60484
|
-
};
|
|
60485
|
-
|
|
60486
|
-
class WalletConnectV2 {
|
|
60487
|
-
|
|
60488
|
-
static __initStatic() {this.info = {
|
|
60489
|
-
name: 'WalletConnect',
|
|
60490
|
-
logo: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMjUuNC4xLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAtLT48c3ZnIHZlcnNpb249JzEuMScgaWQ9J0xheWVyXzEnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZycgeG1sbnM6eGxpbms9J2h0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsnIHg9JzBweCcgeT0nMHB4JyB2aWV3Qm94PScwIDAgNTAwIDUwMCcgc3R5bGU9J2VuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTAwIDUwMDsnIHhtbDpzcGFjZT0ncHJlc2VydmUnPjxzdHlsZSB0eXBlPSd0ZXh0L2Nzcyc+IC5zdDB7ZmlsbDojNTk5MUNEO30KPC9zdHlsZT48ZyBpZD0nUGFnZS0xJz48ZyBpZD0nd2FsbGV0Y29ubmVjdC1sb2dvLWFsdCc+PHBhdGggaWQ9J1dhbGxldENvbm5lY3QnIGNsYXNzPSdzdDAnIGQ9J00xMDIuNywxNjJjODEuNS03OS44LDIxMy42LTc5LjgsMjk1LjEsMGw5LjgsOS42YzQuMSw0LDQuMSwxMC41LDAsMTQuNEwzNzQsMjE4LjkgYy0yLDItNS4zLDItNy40LDBsLTEzLjUtMTMuMmMtNTYuOC01NS43LTE0OS01NS43LTIwNS44LDBsLTE0LjUsMTQuMWMtMiwyLTUuMywyLTcuNCwwTDkxLjksMTg3Yy00LjEtNC00LjEtMTAuNSwwLTE0LjQgTDEwMi43LDE2MnogTTQ2Ny4xLDIyOS45bDI5LjksMjkuMmM0LjEsNCw0LjEsMTAuNSwwLDE0LjRMMzYyLjMsNDA1LjRjLTQuMSw0LTEwLjcsNC0xNC44LDBjMCwwLDAsMCwwLDBMMjUyLDMxMS45IGMtMS0xLTIuNy0xLTMuNywwaDBsLTk1LjUsOTMuNWMtNC4xLDQtMTAuNyw0LTE0LjgsMGMwLDAsMCwwLDAsMEwzLjQsMjczLjZjLTQuMS00LTQuMS0xMC41LDAtMTQuNGwyOS45LTI5LjIgYzQuMS00LDEwLjctNCwxNC44LDBsOTUuNSw5My41YzEsMSwyLjcsMSwzLjcsMGMwLDAsMCwwLDAsMGw5NS41LTkzLjVjNC4xLTQsMTAuNy00LDE0LjgsMGMwLDAsMCwwLDAsMGw5NS41LDkzLjUgYzEsMSwyLjcsMSwzLjcsMGw5NS41LTkzLjVDNDU2LjQsMjI1LjksNDYzLDIyNS45LDQ2Ny4xLDIyOS45eicvPjwvZz48L2c+PC9zdmc+Cg==",
|
|
60491
|
-
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
60492
|
-
};}
|
|
60493
|
-
|
|
60494
|
-
static __initStatic2() {this.isAvailable = ()=>{
|
|
60495
|
-
return getConnectedInstance$1() != undefined
|
|
60496
|
-
};}
|
|
60497
|
-
|
|
60498
|
-
constructor() {
|
|
60499
|
-
this.name = this.constructor.info.name;
|
|
60500
|
-
this.logo = this.constructor.info.logo;
|
|
60501
|
-
this.blockchains = this.constructor.info.blockchains;
|
|
60502
|
-
this.connector = WalletConnect.instance || this.newWalletConnectInstance();
|
|
60503
|
-
WalletConnect.instance = this.connector;
|
|
60504
|
-
this.sendTransaction = (transaction)=>{
|
|
60505
|
-
return sendTransaction$2({
|
|
60506
|
-
wallet: this,
|
|
60507
|
-
transaction
|
|
60508
|
-
})
|
|
60509
|
-
};
|
|
60510
|
-
}
|
|
60511
|
-
|
|
60512
|
-
newWalletConnectInstance() {
|
|
60513
|
-
return new Core({ projectId: window._walletConnectProjectId })
|
|
60514
|
-
}
|
|
60515
|
-
|
|
60516
|
-
async account() {
|
|
60517
|
-
if(this.connectedAccount == undefined) { return }
|
|
60518
|
-
return this.connectedAccount
|
|
60519
|
-
}
|
|
60520
|
-
|
|
60521
|
-
async connect({ connect, blockchain }) {
|
|
60522
|
-
|
|
60523
|
-
if(!connect || typeof connect != 'function') { throw('Provided connect paremeters is not present or not a function!') }
|
|
60524
|
-
|
|
60525
|
-
try {
|
|
60526
|
-
|
|
60527
|
-
delete localStorage[`wc@2:core:${this.connector.pairing.version}//subscription`]; // DO NOT RECOVER AN OTHER SUBSCRIPTION!!!
|
|
60528
|
-
this.signClient = await SignClient.init({ core: this.connector });
|
|
60529
|
-
|
|
60530
|
-
this.signClient.on("session_delete", () => {
|
|
60531
|
-
console.log('WALLETCONNECT DISCONNECT');
|
|
60532
|
-
this.connector = undefined;
|
|
60533
|
-
WalletConnect.instance = undefined;
|
|
60534
|
-
this.connectedAccount = undefined;
|
|
60535
|
-
this.signClient = undefined;
|
|
60536
|
-
this.session = undefined;
|
|
60537
|
-
});
|
|
60538
|
-
|
|
60539
|
-
blockchain = Blockchain.findByName(blockchain);
|
|
60540
|
-
|
|
60541
|
-
let namespaces = {};
|
|
60542
|
-
|
|
60543
|
-
namespaces[blockchain.namespace] = {
|
|
60544
|
-
methods: [
|
|
60545
|
-
"eth_sendTransaction",
|
|
60546
|
-
"personal_sign",
|
|
60547
|
-
"eth_chainId",
|
|
60548
|
-
"wallet_switchEthereumChain",
|
|
60549
|
-
],
|
|
60550
|
-
chains: [`${blockchain.namespace}:${blockchain.networkId}`],
|
|
60551
|
-
events: [],
|
|
60552
|
-
};
|
|
60553
|
-
|
|
60554
|
-
const { uri, approval } = await this.signClient.connect({ requiredNamespaces: namespaces });
|
|
60555
|
-
|
|
60556
|
-
await connect({ uri });
|
|
60557
|
-
this.session = await approval();
|
|
60558
|
-
this.session.chainId = `${blockchain.namespace}:${blockchain.networkId}`;
|
|
60559
|
-
|
|
60560
|
-
let meta = _optionalChain$2([this, 'access', _ => _.session, 'optionalAccess', _2 => _2.peer, 'optionalAccess', _3 => _3.metadata]);
|
|
60561
|
-
if(meta && meta.name) {
|
|
60562
|
-
this.name = meta.name;
|
|
60563
|
-
if(_optionalChain$2([meta, 'optionalAccess', _4 => _4.icons]) && meta.icons.length) { this.logo = meta.icons[0]; }
|
|
60564
|
-
}
|
|
60565
|
-
|
|
60566
|
-
const account = Object.values(this.session.namespaces)[0].accounts[0].split(":")[2];
|
|
60567
|
-
this.connectedAccount = account;
|
|
60568
|
-
this.connectedBlockchain = blockchain.name;
|
|
60569
|
-
|
|
60570
|
-
return account
|
|
60571
|
-
|
|
60572
|
-
} catch (error) {
|
|
60573
|
-
console.log('WALLETCONNECT ERROR', error);
|
|
60574
|
-
}
|
|
60575
|
-
}
|
|
60576
|
-
|
|
60577
|
-
async connectedTo(input) {
|
|
60578
|
-
if(input) {
|
|
60579
|
-
return input === this.connectedBlockchain
|
|
60580
|
-
} else {
|
|
60581
|
-
const blockchain = Blockchain.findByName(this.connectedBlockchain);
|
|
60582
|
-
return blockchain.name
|
|
60583
|
-
}
|
|
60584
|
-
}
|
|
60585
|
-
|
|
60586
|
-
switchTo(blockchainName) {
|
|
60587
|
-
return new Promise((resolve, reject)=>{
|
|
60588
|
-
let resolved, rejected;
|
|
60589
|
-
const blockchain = Blockchain.findByName(blockchainName);
|
|
60590
|
-
setTimeout(async()=>{
|
|
60591
|
-
if(!(await this.connectedTo(blockchainName)) && !resolved && !rejected){
|
|
60592
|
-
reject({ code: 'NOT_SUPPORTED' });
|
|
60593
|
-
} else {
|
|
60594
|
-
resolve();
|
|
60595
|
-
}
|
|
60596
|
-
}, 4000);
|
|
60597
|
-
this.connectedBlockchain = blockchain.name;
|
|
60598
|
-
this.signClient.request({
|
|
60599
|
-
topic: this.session.topic,
|
|
60600
|
-
chainId: this.session.chainId,
|
|
60601
|
-
request:{
|
|
60602
|
-
method: 'wallet_switchEthereumChain',
|
|
60603
|
-
params: [{ chainId: blockchain.id }],
|
|
60604
|
-
}
|
|
60605
|
-
}).then((result)=>{
|
|
60606
|
-
console.log('RESULT ', result);
|
|
60607
|
-
resolved = true;
|
|
60608
|
-
resolve();
|
|
60609
|
-
});
|
|
60610
|
-
})
|
|
60611
|
-
}
|
|
60612
|
-
|
|
60613
|
-
addNetwork(blockchainName) {
|
|
60614
|
-
return new Promise((resolve, reject)=>{
|
|
60615
|
-
reject({ code: 'NOT_SUPPORTED' });
|
|
60616
|
-
})
|
|
60617
|
-
}
|
|
60618
|
-
|
|
60619
|
-
on(event, callback) {
|
|
60620
|
-
// currently not supported
|
|
60621
|
-
}
|
|
60622
|
-
|
|
60623
|
-
off(event, callback) {
|
|
60624
|
-
// currently not supported
|
|
60625
|
-
}
|
|
60626
|
-
|
|
60627
|
-
async sign(message) {
|
|
60628
|
-
let address = await this.account();
|
|
60629
|
-
var params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
|
|
60630
|
-
let signature = await this.signClient.request({
|
|
60631
|
-
topic: this.session.topic,
|
|
60632
|
-
chainId: this.session.chainId,
|
|
60633
|
-
request:{
|
|
60634
|
-
id: 1,
|
|
60635
|
-
jsonrpc: '2.0',
|
|
60636
|
-
method: 'personal_sign',
|
|
60637
|
-
params
|
|
60638
|
-
}
|
|
60639
|
-
});
|
|
60640
|
-
if(typeof signature == 'object') {
|
|
60641
|
-
signature = ethers.utils.hexlify(signature);
|
|
60642
|
-
}
|
|
60643
|
-
return signature
|
|
60644
|
-
}
|
|
60645
|
-
} WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
|
|
60646
|
-
|
|
60647
|
-
WalletConnectV2.getConnectedInstance = getConnectedInstance$1;
|
|
60648
|
-
WalletConnectV2.setConnectedInstance = setConnectedInstance$1;
|
|
60368
|
+
WalletConnectV1.getConnectedInstance = getConnectedInstance$1;
|
|
60369
|
+
WalletConnectV1.setConnectedInstance = setConnectedInstance$1;
|
|
60649
60370
|
|
|
60650
60371
|
const sendTransaction$1 = async ({ transaction, wallet })=> {
|
|
60651
60372
|
transaction = new Transaction(transaction);
|
|
@@ -61052,40 +60773,32 @@ var wallets = {
|
|
|
61052
60773
|
WindowEthereum,
|
|
61053
60774
|
WindowSolana,
|
|
61054
60775
|
WalletConnectV1,
|
|
61055
|
-
WalletConnectV2,
|
|
61056
60776
|
WalletLink
|
|
61057
60777
|
};
|
|
61058
60778
|
|
|
61059
|
-
const getWallets = ()=>{
|
|
61060
|
-
let availableWallets = [];
|
|
60779
|
+
const getWallets = async()=>{
|
|
61061
60780
|
|
|
61062
|
-
|
|
61063
|
-
|
|
61064
|
-
|
|
61065
|
-
|
|
61066
|
-
|
|
61067
|
-
|
|
61068
|
-
|
|
61069
|
-
|
|
61070
|
-
|
|
61071
|
-
|
|
61072
|
-
|
|
61073
|
-
|
|
61074
|
-
|
|
61075
|
-
|
|
61076
|
-
}
|
|
61077
|
-
|
|
61078
|
-
const getConnectedWallets = async()=>{
|
|
61079
|
-
|
|
61080
|
-
let connectedWallets = (await Promise.all(
|
|
61081
|
-
getWallets().map(async(wallet)=>{
|
|
61082
|
-
if(await wallet.account()) {
|
|
61083
|
-
return wallet
|
|
60781
|
+
let availableWallets = await Promise.all(
|
|
60782
|
+
Object.keys(wallets).map(
|
|
60783
|
+
async(key)=>{
|
|
60784
|
+
|
|
60785
|
+
let wallet = wallets[key];
|
|
60786
|
+
|
|
60787
|
+
if(wallet.isAvailable()) {
|
|
60788
|
+
let instance;
|
|
60789
|
+
|
|
60790
|
+
if(wallet.getConnectedInstance) {
|
|
60791
|
+
instance = await wallet.getConnectedInstance();
|
|
60792
|
+
return instance
|
|
60793
|
+
} else {
|
|
60794
|
+
return new wallet
|
|
60795
|
+
}
|
|
60796
|
+
}
|
|
61084
60797
|
}
|
|
61085
|
-
|
|
61086
|
-
)
|
|
60798
|
+
)
|
|
60799
|
+
);
|
|
61087
60800
|
|
|
61088
|
-
return
|
|
60801
|
+
return availableWallets.filter((wallet)=>wallet)
|
|
61089
60802
|
};
|
|
61090
60803
|
|
|
61091
60804
|
const supported = [
|
|
@@ -61098,8 +60811,7 @@ const supported = [
|
|
|
61098
60811
|
wallets.Coin98,
|
|
61099
60812
|
wallets.CryptoCom,
|
|
61100
60813
|
wallets.WalletConnectV1,
|
|
61101
|
-
wallets.WalletConnectV2,
|
|
61102
60814
|
wallets.WalletLink
|
|
61103
60815
|
];
|
|
61104
60816
|
|
|
61105
|
-
export {
|
|
60817
|
+
export { getWallets, supported, wallets };
|