@depay/web3-wallets-evm 12.4.2 → 13.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/esm/index.evm.js +39 -17
- package/dist/esm/index.js +16 -12
- package/dist/umd/index.evm.js +39 -17
- package/dist/umd/index.js +16 -12
- package/package.json +1 -1
package/dist/esm/index.evm.js
CHANGED
|
@@ -12,8 +12,8 @@ class Transaction {
|
|
|
12
12
|
|
|
13
13
|
// required
|
|
14
14
|
this.blockchain = blockchain;
|
|
15
|
-
this.from = from;
|
|
16
|
-
this.to = to;
|
|
15
|
+
this.from = (from && from.match('0x')) ? ethers.utils.getAddress(from) : from;
|
|
16
|
+
this.to = (to && to.match('0x')) ? ethers.utils.getAddress(to) : to;
|
|
17
17
|
|
|
18
18
|
// optional
|
|
19
19
|
this.value = _optionalChain$5([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
@@ -213,13 +213,13 @@ class WindowEthereum {
|
|
|
213
213
|
|
|
214
214
|
async account() {
|
|
215
215
|
if(!_optionalChain$4([window, 'optionalAccess', _15 => _15.ethereum])) { return undefined }
|
|
216
|
-
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
216
|
+
const accounts = (await window.ethereum.request({ method: 'eth_accounts' })).map((address)=>ethers.utils.getAddress(address));
|
|
217
217
|
return accounts[0]
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
async connect() {
|
|
221
221
|
if(!_optionalChain$4([window, 'optionalAccess', _16 => _16.ethereum])) { return undefined }
|
|
222
|
-
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
|
|
222
|
+
const accounts = (await window.ethereum.request({ method: 'eth_requestAccounts' })).map((address)=>ethers.utils.getAddress(address));
|
|
223
223
|
return accounts[0]
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -227,7 +227,7 @@ class WindowEthereum {
|
|
|
227
227
|
let internalCallback;
|
|
228
228
|
switch (event) {
|
|
229
229
|
case 'account':
|
|
230
|
-
internalCallback = (accounts) => callback(accounts[0]);
|
|
230
|
+
internalCallback = (accounts) => callback(ethers.utils.getAddress(accounts[0]));
|
|
231
231
|
window.ethereum.on('accountsChanged', internalCallback);
|
|
232
232
|
break
|
|
233
233
|
}
|
|
@@ -462,14 +462,14 @@ class WalletConnect {
|
|
|
462
462
|
instance.on("connect", (error, payload) => {
|
|
463
463
|
if (error) { throw error }
|
|
464
464
|
const { accounts, chainId } = payload.params[0];
|
|
465
|
-
this.connectedAccounts = accounts;
|
|
465
|
+
this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
466
466
|
this.connectedChainId = chainId;
|
|
467
467
|
});
|
|
468
468
|
|
|
469
469
|
instance.on("session_update", (error, payload) => {
|
|
470
470
|
if (error) { throw error }
|
|
471
471
|
const { accounts, chainId } = payload.params[0];
|
|
472
|
-
this.connectedAccounts = accounts;
|
|
472
|
+
this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
473
473
|
this.connectedChainId = chainId;
|
|
474
474
|
});
|
|
475
475
|
|
|
@@ -505,12 +505,13 @@ class WalletConnect {
|
|
|
505
505
|
this.connector = this.newWalletConnectInstance();
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
-
|
|
508
|
+
let { accounts, chainId } = await this.connector.connect({ chainId: _optionalChain([options, 'optionalAccess', _ => _.chainId]) });
|
|
509
509
|
|
|
510
510
|
if(accounts instanceof Array && accounts.length) {
|
|
511
511
|
setConnectedInstance$1(this);
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
+
accounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
514
515
|
this.connectedAccounts = accounts;
|
|
515
516
|
this.connectedChainId = chainId;
|
|
516
517
|
|
|
@@ -533,17 +534,35 @@ class WalletConnect {
|
|
|
533
534
|
|
|
534
535
|
switchTo(blockchainName) {
|
|
535
536
|
return new Promise((resolve, reject)=>{
|
|
537
|
+
let resolved, rejected;
|
|
536
538
|
const blockchain = Blockchain.findByName(blockchainName);
|
|
539
|
+
setTimeout(async()=>{
|
|
540
|
+
if(!(await this.connectedTo(blockchainName)) && !resolved && !rejected){
|
|
541
|
+
reject({ code: 'NOT_SUPPORTED' });
|
|
542
|
+
} else {
|
|
543
|
+
resolve();
|
|
544
|
+
}
|
|
545
|
+
}, 3000);
|
|
537
546
|
this.connector.sendCustomRequest({
|
|
538
547
|
method: 'wallet_switchEthereumChain',
|
|
539
548
|
params: [{ chainId: blockchain.id }],
|
|
540
|
-
}).then(
|
|
541
|
-
|
|
549
|
+
}).then(()=>{
|
|
550
|
+
resolved = true;
|
|
551
|
+
resolve();
|
|
552
|
+
}).catch((error)=> {
|
|
553
|
+
if(error && typeof error.message == 'string' && error.message.match('addEthereumChain')){ // chain not yet added
|
|
542
554
|
this.addNetwork(blockchainName)
|
|
543
|
-
.then(()=>this.switchTo(blockchainName).then(
|
|
544
|
-
|
|
555
|
+
.then(()=>this.switchTo(blockchainName).then(()=>{
|
|
556
|
+
resolved = true;
|
|
557
|
+
resolve();
|
|
558
|
+
}))
|
|
559
|
+
.catch(()=>{
|
|
560
|
+
rejected = true;
|
|
561
|
+
reject({ code: 'NOT_SUPPORTED' });
|
|
562
|
+
});
|
|
545
563
|
} else {
|
|
546
|
-
|
|
564
|
+
rejected = true;
|
|
565
|
+
reject({ code: 'NOT_SUPPORTED' });
|
|
547
566
|
}
|
|
548
567
|
});
|
|
549
568
|
})
|
|
@@ -575,8 +594,10 @@ class WalletConnect {
|
|
|
575
594
|
switch (event) {
|
|
576
595
|
case 'account':
|
|
577
596
|
internalCallback = (error, payload) => {
|
|
578
|
-
|
|
579
|
-
|
|
597
|
+
if(payload && payload.params && payload.params[0].accounts && payload.params[0].accounts instanceof Array) {
|
|
598
|
+
const accounts = payload.params[0].accounts.map((account)=>ethers.utils.getAddress(account));
|
|
599
|
+
callback(accounts[0]);
|
|
600
|
+
}
|
|
580
601
|
};
|
|
581
602
|
this.connector.on("session_update", internalCallback);
|
|
582
603
|
break
|
|
@@ -716,7 +737,7 @@ class WalletLink {
|
|
|
716
737
|
|
|
717
738
|
async account() {
|
|
718
739
|
if(this.connectedAccounts == undefined) { return }
|
|
719
|
-
return this.connectedAccounts[0]
|
|
740
|
+
return ethers.utils.getAddress(this.connectedAccounts[0])
|
|
720
741
|
}
|
|
721
742
|
|
|
722
743
|
async connect(options) {
|
|
@@ -726,6 +747,7 @@ class WalletLink {
|
|
|
726
747
|
if(accounts instanceof Array && accounts.length) {
|
|
727
748
|
setConnectedInstance(this);
|
|
728
749
|
}
|
|
750
|
+
accounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
729
751
|
this.connectedAccounts = accounts;
|
|
730
752
|
this.connectedChainId = await this.connector.getChainId();
|
|
731
753
|
return accounts[0]
|
|
@@ -784,7 +806,7 @@ class WalletLink {
|
|
|
784
806
|
let internalCallback;
|
|
785
807
|
switch (event) {
|
|
786
808
|
case 'account':
|
|
787
|
-
internalCallback = (accounts) => callback(accounts[0]);
|
|
809
|
+
internalCallback = (accounts) => callback(ethers.utils.getAddress(accounts[0]));
|
|
788
810
|
this.connector.on('accountsChanged', internalCallback);
|
|
789
811
|
break
|
|
790
812
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -13,8 +13,8 @@ class Transaction {
|
|
|
13
13
|
|
|
14
14
|
// required
|
|
15
15
|
this.blockchain = blockchain;
|
|
16
|
-
this.from = from;
|
|
17
|
-
this.to = to;
|
|
16
|
+
this.from = (from && from.match('0x')) ? ethers.utils.getAddress(from) : from;
|
|
17
|
+
this.to = (to && to.match('0x')) ? ethers.utils.getAddress(to) : to;
|
|
18
18
|
|
|
19
19
|
// optional
|
|
20
20
|
this.value = _optionalChain$8([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
@@ -214,13 +214,13 @@ class WindowEthereum {
|
|
|
214
214
|
|
|
215
215
|
async account() {
|
|
216
216
|
if(!_optionalChain$7([window, 'optionalAccess', _15 => _15.ethereum])) { return undefined }
|
|
217
|
-
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
217
|
+
const accounts = (await window.ethereum.request({ method: 'eth_accounts' })).map((address)=>ethers.utils.getAddress(address));
|
|
218
218
|
return accounts[0]
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
async connect() {
|
|
222
222
|
if(!_optionalChain$7([window, 'optionalAccess', _16 => _16.ethereum])) { return undefined }
|
|
223
|
-
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
|
|
223
|
+
const accounts = (await window.ethereum.request({ method: 'eth_requestAccounts' })).map((address)=>ethers.utils.getAddress(address));
|
|
224
224
|
return accounts[0]
|
|
225
225
|
}
|
|
226
226
|
|
|
@@ -228,7 +228,7 @@ class WindowEthereum {
|
|
|
228
228
|
let internalCallback;
|
|
229
229
|
switch (event) {
|
|
230
230
|
case 'account':
|
|
231
|
-
internalCallback = (accounts) => callback(accounts[0]);
|
|
231
|
+
internalCallback = (accounts) => callback(ethers.utils.getAddress(accounts[0]));
|
|
232
232
|
window.ethereum.on('accountsChanged', internalCallback);
|
|
233
233
|
break
|
|
234
234
|
}
|
|
@@ -650,14 +650,14 @@ class WalletConnect {
|
|
|
650
650
|
instance.on("connect", (error, payload) => {
|
|
651
651
|
if (error) { throw error }
|
|
652
652
|
const { accounts, chainId } = payload.params[0];
|
|
653
|
-
this.connectedAccounts = accounts;
|
|
653
|
+
this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
654
654
|
this.connectedChainId = chainId;
|
|
655
655
|
});
|
|
656
656
|
|
|
657
657
|
instance.on("session_update", (error, payload) => {
|
|
658
658
|
if (error) { throw error }
|
|
659
659
|
const { accounts, chainId } = payload.params[0];
|
|
660
|
-
this.connectedAccounts = accounts;
|
|
660
|
+
this.connectedAccounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
661
661
|
this.connectedChainId = chainId;
|
|
662
662
|
});
|
|
663
663
|
|
|
@@ -693,12 +693,13 @@ class WalletConnect {
|
|
|
693
693
|
this.connector = this.newWalletConnectInstance();
|
|
694
694
|
}
|
|
695
695
|
|
|
696
|
-
|
|
696
|
+
let { accounts, chainId } = await this.connector.connect({ chainId: _optionalChain([options, 'optionalAccess', _ => _.chainId]) });
|
|
697
697
|
|
|
698
698
|
if(accounts instanceof Array && accounts.length) {
|
|
699
699
|
setConnectedInstance$1(this);
|
|
700
700
|
}
|
|
701
701
|
|
|
702
|
+
accounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
702
703
|
this.connectedAccounts = accounts;
|
|
703
704
|
this.connectedChainId = chainId;
|
|
704
705
|
|
|
@@ -781,8 +782,10 @@ class WalletConnect {
|
|
|
781
782
|
switch (event) {
|
|
782
783
|
case 'account':
|
|
783
784
|
internalCallback = (error, payload) => {
|
|
784
|
-
|
|
785
|
-
|
|
785
|
+
if(payload && payload.params && payload.params[0].accounts && payload.params[0].accounts instanceof Array) {
|
|
786
|
+
const accounts = payload.params[0].accounts.map((account)=>ethers.utils.getAddress(account));
|
|
787
|
+
callback(accounts[0]);
|
|
788
|
+
}
|
|
786
789
|
};
|
|
787
790
|
this.connector.on("session_update", internalCallback);
|
|
788
791
|
break
|
|
@@ -922,7 +925,7 @@ class WalletLink {
|
|
|
922
925
|
|
|
923
926
|
async account() {
|
|
924
927
|
if(this.connectedAccounts == undefined) { return }
|
|
925
|
-
return this.connectedAccounts[0]
|
|
928
|
+
return ethers.utils.getAddress(this.connectedAccounts[0])
|
|
926
929
|
}
|
|
927
930
|
|
|
928
931
|
async connect(options) {
|
|
@@ -932,6 +935,7 @@ class WalletLink {
|
|
|
932
935
|
if(accounts instanceof Array && accounts.length) {
|
|
933
936
|
setConnectedInstance(this);
|
|
934
937
|
}
|
|
938
|
+
accounts = accounts.map((account)=>ethers.utils.getAddress(account));
|
|
935
939
|
this.connectedAccounts = accounts;
|
|
936
940
|
this.connectedChainId = await this.connector.getChainId();
|
|
937
941
|
return accounts[0]
|
|
@@ -990,7 +994,7 @@ class WalletLink {
|
|
|
990
994
|
let internalCallback;
|
|
991
995
|
switch (event) {
|
|
992
996
|
case 'account':
|
|
993
|
-
internalCallback = (accounts) => callback(accounts[0]);
|
|
997
|
+
internalCallback = (accounts) => callback(ethers.utils.getAddress(accounts[0]));
|
|
994
998
|
this.connector.on('accountsChanged', internalCallback);
|
|
995
999
|
break
|
|
996
1000
|
}
|
package/dist/umd/index.evm.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
// required
|
|
13
13
|
this.blockchain = blockchain;
|
|
14
|
-
this.from = from;
|
|
15
|
-
this.to = to;
|
|
14
|
+
this.from = (from && from.match('0x')) ? ethers.ethers.utils.getAddress(from) : from;
|
|
15
|
+
this.to = (to && to.match('0x')) ? ethers.ethers.utils.getAddress(to) : to;
|
|
16
16
|
|
|
17
17
|
// optional
|
|
18
18
|
this.value = _optionalChain$5([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
@@ -212,13 +212,13 @@
|
|
|
212
212
|
|
|
213
213
|
async account() {
|
|
214
214
|
if(!_optionalChain$4([window, 'optionalAccess', _15 => _15.ethereum])) { return undefined }
|
|
215
|
-
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
215
|
+
const accounts = (await window.ethereum.request({ method: 'eth_accounts' })).map((address)=>ethers.ethers.utils.getAddress(address));
|
|
216
216
|
return accounts[0]
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
async connect() {
|
|
220
220
|
if(!_optionalChain$4([window, 'optionalAccess', _16 => _16.ethereum])) { return undefined }
|
|
221
|
-
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
|
|
221
|
+
const accounts = (await window.ethereum.request({ method: 'eth_requestAccounts' })).map((address)=>ethers.ethers.utils.getAddress(address));
|
|
222
222
|
return accounts[0]
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
let internalCallback;
|
|
227
227
|
switch (event) {
|
|
228
228
|
case 'account':
|
|
229
|
-
internalCallback = (accounts) => callback(accounts[0]);
|
|
229
|
+
internalCallback = (accounts) => callback(ethers.ethers.utils.getAddress(accounts[0]));
|
|
230
230
|
window.ethereum.on('accountsChanged', internalCallback);
|
|
231
231
|
break
|
|
232
232
|
}
|
|
@@ -461,14 +461,14 @@
|
|
|
461
461
|
instance.on("connect", (error, payload) => {
|
|
462
462
|
if (error) { throw error }
|
|
463
463
|
const { accounts, chainId } = payload.params[0];
|
|
464
|
-
this.connectedAccounts = accounts;
|
|
464
|
+
this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
465
465
|
this.connectedChainId = chainId;
|
|
466
466
|
});
|
|
467
467
|
|
|
468
468
|
instance.on("session_update", (error, payload) => {
|
|
469
469
|
if (error) { throw error }
|
|
470
470
|
const { accounts, chainId } = payload.params[0];
|
|
471
|
-
this.connectedAccounts = accounts;
|
|
471
|
+
this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
472
472
|
this.connectedChainId = chainId;
|
|
473
473
|
});
|
|
474
474
|
|
|
@@ -504,12 +504,13 @@
|
|
|
504
504
|
this.connector = this.newWalletConnectInstance();
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
-
|
|
507
|
+
let { accounts, chainId } = await this.connector.connect({ chainId: _optionalChain([options, 'optionalAccess', _ => _.chainId]) });
|
|
508
508
|
|
|
509
509
|
if(accounts instanceof Array && accounts.length) {
|
|
510
510
|
setConnectedInstance$1(this);
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
513
514
|
this.connectedAccounts = accounts;
|
|
514
515
|
this.connectedChainId = chainId;
|
|
515
516
|
|
|
@@ -532,17 +533,35 @@
|
|
|
532
533
|
|
|
533
534
|
switchTo(blockchainName) {
|
|
534
535
|
return new Promise((resolve, reject)=>{
|
|
536
|
+
let resolved, rejected;
|
|
535
537
|
const blockchain = web3Blockchains.Blockchain.findByName(blockchainName);
|
|
538
|
+
setTimeout(async()=>{
|
|
539
|
+
if(!(await this.connectedTo(blockchainName)) && !resolved && !rejected){
|
|
540
|
+
reject({ code: 'NOT_SUPPORTED' });
|
|
541
|
+
} else {
|
|
542
|
+
resolve();
|
|
543
|
+
}
|
|
544
|
+
}, 3000);
|
|
536
545
|
this.connector.sendCustomRequest({
|
|
537
546
|
method: 'wallet_switchEthereumChain',
|
|
538
547
|
params: [{ chainId: blockchain.id }],
|
|
539
|
-
}).then(
|
|
540
|
-
|
|
548
|
+
}).then(()=>{
|
|
549
|
+
resolved = true;
|
|
550
|
+
resolve();
|
|
551
|
+
}).catch((error)=> {
|
|
552
|
+
if(error && typeof error.message == 'string' && error.message.match('addEthereumChain')){ // chain not yet added
|
|
541
553
|
this.addNetwork(blockchainName)
|
|
542
|
-
.then(()=>this.switchTo(blockchainName).then(
|
|
543
|
-
|
|
554
|
+
.then(()=>this.switchTo(blockchainName).then(()=>{
|
|
555
|
+
resolved = true;
|
|
556
|
+
resolve();
|
|
557
|
+
}))
|
|
558
|
+
.catch(()=>{
|
|
559
|
+
rejected = true;
|
|
560
|
+
reject({ code: 'NOT_SUPPORTED' });
|
|
561
|
+
});
|
|
544
562
|
} else {
|
|
545
|
-
|
|
563
|
+
rejected = true;
|
|
564
|
+
reject({ code: 'NOT_SUPPORTED' });
|
|
546
565
|
}
|
|
547
566
|
});
|
|
548
567
|
})
|
|
@@ -574,8 +593,10 @@
|
|
|
574
593
|
switch (event) {
|
|
575
594
|
case 'account':
|
|
576
595
|
internalCallback = (error, payload) => {
|
|
577
|
-
|
|
578
|
-
|
|
596
|
+
if(payload && payload.params && payload.params[0].accounts && payload.params[0].accounts instanceof Array) {
|
|
597
|
+
const accounts = payload.params[0].accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
598
|
+
callback(accounts[0]);
|
|
599
|
+
}
|
|
579
600
|
};
|
|
580
601
|
this.connector.on("session_update", internalCallback);
|
|
581
602
|
break
|
|
@@ -715,7 +736,7 @@
|
|
|
715
736
|
|
|
716
737
|
async account() {
|
|
717
738
|
if(this.connectedAccounts == undefined) { return }
|
|
718
|
-
return this.connectedAccounts[0]
|
|
739
|
+
return ethers.ethers.utils.getAddress(this.connectedAccounts[0])
|
|
719
740
|
}
|
|
720
741
|
|
|
721
742
|
async connect(options) {
|
|
@@ -725,6 +746,7 @@
|
|
|
725
746
|
if(accounts instanceof Array && accounts.length) {
|
|
726
747
|
setConnectedInstance(this);
|
|
727
748
|
}
|
|
749
|
+
accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
728
750
|
this.connectedAccounts = accounts;
|
|
729
751
|
this.connectedChainId = await this.connector.getChainId();
|
|
730
752
|
return accounts[0]
|
|
@@ -783,7 +805,7 @@
|
|
|
783
805
|
let internalCallback;
|
|
784
806
|
switch (event) {
|
|
785
807
|
case 'account':
|
|
786
|
-
internalCallback = (accounts) => callback(accounts[0]);
|
|
808
|
+
internalCallback = (accounts) => callback(ethers.ethers.utils.getAddress(accounts[0]));
|
|
787
809
|
this.connector.on('accountsChanged', internalCallback);
|
|
788
810
|
break
|
|
789
811
|
}
|
package/dist/umd/index.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
// required
|
|
13
13
|
this.blockchain = blockchain;
|
|
14
|
-
this.from = from;
|
|
15
|
-
this.to = to;
|
|
14
|
+
this.from = (from && from.match('0x')) ? ethers.ethers.utils.getAddress(from) : from;
|
|
15
|
+
this.to = (to && to.match('0x')) ? ethers.ethers.utils.getAddress(to) : to;
|
|
16
16
|
|
|
17
17
|
// optional
|
|
18
18
|
this.value = _optionalChain$8([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
@@ -212,13 +212,13 @@
|
|
|
212
212
|
|
|
213
213
|
async account() {
|
|
214
214
|
if(!_optionalChain$7([window, 'optionalAccess', _15 => _15.ethereum])) { return undefined }
|
|
215
|
-
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
215
|
+
const accounts = (await window.ethereum.request({ method: 'eth_accounts' })).map((address)=>ethers.ethers.utils.getAddress(address));
|
|
216
216
|
return accounts[0]
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
async connect() {
|
|
220
220
|
if(!_optionalChain$7([window, 'optionalAccess', _16 => _16.ethereum])) { return undefined }
|
|
221
|
-
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
|
|
221
|
+
const accounts = (await window.ethereum.request({ method: 'eth_requestAccounts' })).map((address)=>ethers.ethers.utils.getAddress(address));
|
|
222
222
|
return accounts[0]
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
let internalCallback;
|
|
227
227
|
switch (event) {
|
|
228
228
|
case 'account':
|
|
229
|
-
internalCallback = (accounts) => callback(accounts[0]);
|
|
229
|
+
internalCallback = (accounts) => callback(ethers.ethers.utils.getAddress(accounts[0]));
|
|
230
230
|
window.ethereum.on('accountsChanged', internalCallback);
|
|
231
231
|
break
|
|
232
232
|
}
|
|
@@ -648,14 +648,14 @@
|
|
|
648
648
|
instance.on("connect", (error, payload) => {
|
|
649
649
|
if (error) { throw error }
|
|
650
650
|
const { accounts, chainId } = payload.params[0];
|
|
651
|
-
this.connectedAccounts = accounts;
|
|
651
|
+
this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
652
652
|
this.connectedChainId = chainId;
|
|
653
653
|
});
|
|
654
654
|
|
|
655
655
|
instance.on("session_update", (error, payload) => {
|
|
656
656
|
if (error) { throw error }
|
|
657
657
|
const { accounts, chainId } = payload.params[0];
|
|
658
|
-
this.connectedAccounts = accounts;
|
|
658
|
+
this.connectedAccounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
659
659
|
this.connectedChainId = chainId;
|
|
660
660
|
});
|
|
661
661
|
|
|
@@ -691,12 +691,13 @@
|
|
|
691
691
|
this.connector = this.newWalletConnectInstance();
|
|
692
692
|
}
|
|
693
693
|
|
|
694
|
-
|
|
694
|
+
let { accounts, chainId } = await this.connector.connect({ chainId: _optionalChain([options, 'optionalAccess', _ => _.chainId]) });
|
|
695
695
|
|
|
696
696
|
if(accounts instanceof Array && accounts.length) {
|
|
697
697
|
setConnectedInstance$1(this);
|
|
698
698
|
}
|
|
699
699
|
|
|
700
|
+
accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
700
701
|
this.connectedAccounts = accounts;
|
|
701
702
|
this.connectedChainId = chainId;
|
|
702
703
|
|
|
@@ -779,8 +780,10 @@
|
|
|
779
780
|
switch (event) {
|
|
780
781
|
case 'account':
|
|
781
782
|
internalCallback = (error, payload) => {
|
|
782
|
-
|
|
783
|
-
|
|
783
|
+
if(payload && payload.params && payload.params[0].accounts && payload.params[0].accounts instanceof Array) {
|
|
784
|
+
const accounts = payload.params[0].accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
785
|
+
callback(accounts[0]);
|
|
786
|
+
}
|
|
784
787
|
};
|
|
785
788
|
this.connector.on("session_update", internalCallback);
|
|
786
789
|
break
|
|
@@ -920,7 +923,7 @@
|
|
|
920
923
|
|
|
921
924
|
async account() {
|
|
922
925
|
if(this.connectedAccounts == undefined) { return }
|
|
923
|
-
return this.connectedAccounts[0]
|
|
926
|
+
return ethers.ethers.utils.getAddress(this.connectedAccounts[0])
|
|
924
927
|
}
|
|
925
928
|
|
|
926
929
|
async connect(options) {
|
|
@@ -930,6 +933,7 @@
|
|
|
930
933
|
if(accounts instanceof Array && accounts.length) {
|
|
931
934
|
setConnectedInstance(this);
|
|
932
935
|
}
|
|
936
|
+
accounts = accounts.map((account)=>ethers.ethers.utils.getAddress(account));
|
|
933
937
|
this.connectedAccounts = accounts;
|
|
934
938
|
this.connectedChainId = await this.connector.getChainId();
|
|
935
939
|
return accounts[0]
|
|
@@ -988,7 +992,7 @@
|
|
|
988
992
|
let internalCallback;
|
|
989
993
|
switch (event) {
|
|
990
994
|
case 'account':
|
|
991
|
-
internalCallback = (accounts) => callback(accounts[0]);
|
|
995
|
+
internalCallback = (accounts) => callback(ethers.ethers.utils.getAddress(accounts[0]));
|
|
992
996
|
this.connector.on('accountsChanged', internalCallback);
|
|
993
997
|
break
|
|
994
998
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depay/web3-wallets-evm",
|
|
3
3
|
"moduleName": "Web3Wallets",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "13.0.0",
|
|
5
5
|
"description": "One-Stop-Shop JavaScript library to integrate various web3 crypto wallets and multiple blockchains at once with a single interface.",
|
|
6
6
|
"main": "dist/umd/index.evm.js",
|
|
7
7
|
"module": "dist/esm/index.evm.js",
|