@depay/web3-wallets-evm 16.2.7 → 16.2.9
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 +17 -16
- package/dist/esm/index.js +17 -16
- package/dist/umd/index.evm.js +17 -16
- package/dist/umd/index.js +17 -16
- package/package.json +1 -1
package/dist/esm/index.evm.js
CHANGED
|
@@ -1326,7 +1326,8 @@ const getLastSession = async(walletName)=>{
|
|
|
1326
1326
|
if(!localStorage[KEY+":projectId"]) { return }
|
|
1327
1327
|
if(walletName !== localStorage[KEY+":lastSessionWalletName"]) { return }
|
|
1328
1328
|
let signClient = await getSignClient();
|
|
1329
|
-
|
|
1329
|
+
let existingSessions;
|
|
1330
|
+
try { existingSessions = signClient.find(getWalletConnectV2Config(walletName)); } catch (e) {}
|
|
1330
1331
|
const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
|
|
1331
1332
|
if(lastSession && localStorage[KEY+":lastExpiredSessionTopic"] !== lastSession.topic && lastSession.expiry > Math.ceil(Date.now()/1000)) {
|
|
1332
1333
|
const result = await Promise.race([signClient.ping({ topic: lastSession.topic }), new Promise((resolve)=>setTimeout(resolve, 1500))]);
|
|
@@ -1420,13 +1421,13 @@ class WalletConnectV2 {
|
|
|
1420
1421
|
}
|
|
1421
1422
|
|
|
1422
1423
|
async setSessionBlockchains() {
|
|
1423
|
-
if(!this.session) { return }
|
|
1424
|
-
if(_optionalChain$2([CONFIGURATIONS, 'access',
|
|
1425
|
-
this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$2([Blockchains, 'access',
|
|
1424
|
+
if(!this.session || !_optionalChain$2([this, 'access', _27 => _27.session, 'optionalAccess', _28 => _28.namespaces, 'optionalAccess', _29 => _29.eip155])) { return }
|
|
1425
|
+
if(_optionalChain$2([CONFIGURATIONS, 'access', _30 => _30[this.walletName], 'optionalAccess', _31 => _31.methods, 'optionalAccess', _32 => _32.includes, 'call', _33 => _33('wallet_switchEthereumChain')])) {
|
|
1426
|
+
this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$2([Blockchains, 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
|
|
1426
1427
|
} else if(this.session.namespaces.eip155.chains) {
|
|
1427
|
-
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$2([Blockchains, 'access',
|
|
1428
|
+
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$2([Blockchains, 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(chainIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
|
|
1428
1429
|
} else if(this.session.namespaces.eip155.accounts) {
|
|
1429
|
-
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$2([Blockchains, 'access',
|
|
1430
|
+
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$2([Blockchains, 'access', _40 => _40.findByNetworkId, 'call', _41 => _41(accountIdentifier.split(':')[1]), 'optionalAccess', _42 => _42.name])).filter(Boolean);
|
|
1430
1431
|
}
|
|
1431
1432
|
}
|
|
1432
1433
|
|
|
@@ -1436,13 +1437,13 @@ class WalletConnectV2 {
|
|
|
1436
1437
|
|
|
1437
1438
|
try {
|
|
1438
1439
|
|
|
1439
|
-
this.walletName = _optionalChain$2([options, 'optionalAccess',
|
|
1440
|
+
this.walletName = _optionalChain$2([options, 'optionalAccess', _43 => _43.name]);
|
|
1440
1441
|
|
|
1441
1442
|
// delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
|
|
1442
1443
|
this.signClient = await getSignClient();
|
|
1443
1444
|
|
|
1444
1445
|
this.signClient.on("session_delete", (session)=> {
|
|
1445
|
-
if(_optionalChain$2([session, 'optionalAccess',
|
|
1446
|
+
if(_optionalChain$2([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$2([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
|
|
1446
1447
|
localStorage[KEY+':name'] = undefined;
|
|
1447
1448
|
localStorage[KEY+':logo'] = undefined;
|
|
1448
1449
|
this.signClient = undefined;
|
|
@@ -1451,14 +1452,14 @@ class WalletConnectV2 {
|
|
|
1451
1452
|
});
|
|
1452
1453
|
|
|
1453
1454
|
this.signClient.on("session_update", async(session)=> {
|
|
1454
|
-
if(_optionalChain$2([session, 'optionalAccess',
|
|
1455
|
+
if(_optionalChain$2([session, 'optionalAccess', _47 => _47.topic]) === _optionalChain$2([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {
|
|
1455
1456
|
this.session = this.signClient.session.get(session.topic);
|
|
1456
1457
|
await this.setSessionBlockchains();
|
|
1457
1458
|
}
|
|
1458
1459
|
});
|
|
1459
1460
|
|
|
1460
1461
|
this.signClient.on("session_event", (event)=> {
|
|
1461
|
-
if(_optionalChain$2([event, 'optionalAccess',
|
|
1462
|
+
if(_optionalChain$2([event, 'optionalAccess', _50 => _50.topic]) === _optionalChain$2([this, 'access', _51 => _51.session, 'optionalAccess', _52 => _52.topic])) {}
|
|
1462
1463
|
});
|
|
1463
1464
|
|
|
1464
1465
|
const connectWallet = async()=>{
|
|
@@ -1469,24 +1470,24 @@ class WalletConnectV2 {
|
|
|
1469
1470
|
await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
|
|
1470
1471
|
};
|
|
1471
1472
|
|
|
1472
|
-
const lastSession = _optionalChain$2([this, 'optionalAccess',
|
|
1473
|
+
const lastSession = _optionalChain$2([this, 'optionalAccess', _53 => _53.walletName, 'optionalAccess', _54 => _54.length]) ? await getLastSession(this.walletName) : undefined;
|
|
1473
1474
|
if(lastSession) {
|
|
1474
1475
|
this.session = lastSession;
|
|
1475
1476
|
} else {
|
|
1476
1477
|
await connectWallet();
|
|
1477
1478
|
}
|
|
1478
1479
|
|
|
1479
|
-
let meta = _optionalChain$2([this, 'access',
|
|
1480
|
+
let meta = _optionalChain$2([this, 'access', _55 => _55.session, 'optionalAccess', _56 => _56.peer, 'optionalAccess', _57 => _57.metadata]);
|
|
1480
1481
|
if(meta && meta.name) {
|
|
1481
1482
|
this.name = meta.name;
|
|
1482
1483
|
localStorage[KEY+':name'] = meta.name;
|
|
1483
|
-
if(_optionalChain$2([meta, 'optionalAccess',
|
|
1484
|
+
if(_optionalChain$2([meta, 'optionalAccess', _58 => _58.icons]) && meta.icons.length) {
|
|
1484
1485
|
this.logo = meta.icons[0];
|
|
1485
1486
|
localStorage[KEY+':logo'] = this.logo;
|
|
1486
1487
|
}
|
|
1487
1488
|
}
|
|
1488
|
-
if(_optionalChain$2([options, 'optionalAccess',
|
|
1489
|
-
if(_optionalChain$2([options, 'optionalAccess',
|
|
1489
|
+
if(_optionalChain$2([options, 'optionalAccess', _59 => _59.name])) { localStorage[KEY+':name'] = this.name = options.name; }
|
|
1490
|
+
if(_optionalChain$2([options, 'optionalAccess', _60 => _60.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
|
|
1490
1491
|
|
|
1491
1492
|
await this.setSessionBlockchains();
|
|
1492
1493
|
|
|
@@ -1543,7 +1544,7 @@ class WalletConnectV2 {
|
|
|
1543
1544
|
switch (event) {
|
|
1544
1545
|
case 'account':
|
|
1545
1546
|
internalCallback = async(event)=> {
|
|
1546
|
-
if(_optionalChain$2([event, 'optionalAccess',
|
|
1547
|
+
if(_optionalChain$2([event, 'optionalAccess', _61 => _61.topic]) === _optionalChain$2([this, 'access', _62 => _62.session, 'optionalAccess', _63 => _63.topic]) && event.params.event.name === 'accountsChanged') {
|
|
1547
1548
|
callback(await this.account());
|
|
1548
1549
|
}
|
|
1549
1550
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1798,7 +1798,8 @@ const getLastSession = async(walletName)=>{
|
|
|
1798
1798
|
if(!localStorage[KEY+":projectId"]) { return }
|
|
1799
1799
|
if(walletName !== localStorage[KEY+":lastSessionWalletName"]) { return }
|
|
1800
1800
|
let signClient = await getSignClient();
|
|
1801
|
-
|
|
1801
|
+
let existingSessions;
|
|
1802
|
+
try { existingSessions = signClient.find(getWalletConnectV2Config(walletName)); } catch (e) {}
|
|
1802
1803
|
const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
|
|
1803
1804
|
if(lastSession && localStorage[KEY+":lastExpiredSessionTopic"] !== lastSession.topic && lastSession.expiry > Math.ceil(Date.now()/1000)) {
|
|
1804
1805
|
const result = await Promise.race([signClient.ping({ topic: lastSession.topic }), new Promise((resolve)=>setTimeout(resolve, 1500))]);
|
|
@@ -1892,13 +1893,13 @@ class WalletConnectV2 {
|
|
|
1892
1893
|
}
|
|
1893
1894
|
|
|
1894
1895
|
async setSessionBlockchains() {
|
|
1895
|
-
if(!this.session) { return }
|
|
1896
|
-
if(_optionalChain$2([CONFIGURATIONS, 'access',
|
|
1897
|
-
this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$2([Blockchains, 'access',
|
|
1896
|
+
if(!this.session || !_optionalChain$2([this, 'access', _27 => _27.session, 'optionalAccess', _28 => _28.namespaces, 'optionalAccess', _29 => _29.eip155])) { return }
|
|
1897
|
+
if(_optionalChain$2([CONFIGURATIONS, 'access', _30 => _30[this.walletName], 'optionalAccess', _31 => _31.methods, 'optionalAccess', _32 => _32.includes, 'call', _33 => _33('wallet_switchEthereumChain')])) {
|
|
1898
|
+
this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$2([Blockchains, 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
|
|
1898
1899
|
} else if(this.session.namespaces.eip155.chains) {
|
|
1899
|
-
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$2([Blockchains, 'access',
|
|
1900
|
+
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$2([Blockchains, 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(chainIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
|
|
1900
1901
|
} else if(this.session.namespaces.eip155.accounts) {
|
|
1901
|
-
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$2([Blockchains, 'access',
|
|
1902
|
+
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$2([Blockchains, 'access', _40 => _40.findByNetworkId, 'call', _41 => _41(accountIdentifier.split(':')[1]), 'optionalAccess', _42 => _42.name])).filter(Boolean);
|
|
1902
1903
|
}
|
|
1903
1904
|
}
|
|
1904
1905
|
|
|
@@ -1908,13 +1909,13 @@ class WalletConnectV2 {
|
|
|
1908
1909
|
|
|
1909
1910
|
try {
|
|
1910
1911
|
|
|
1911
|
-
this.walletName = _optionalChain$2([options, 'optionalAccess',
|
|
1912
|
+
this.walletName = _optionalChain$2([options, 'optionalAccess', _43 => _43.name]);
|
|
1912
1913
|
|
|
1913
1914
|
// delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
|
|
1914
1915
|
this.signClient = await getSignClient();
|
|
1915
1916
|
|
|
1916
1917
|
this.signClient.on("session_delete", (session)=> {
|
|
1917
|
-
if(_optionalChain$2([session, 'optionalAccess',
|
|
1918
|
+
if(_optionalChain$2([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$2([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
|
|
1918
1919
|
localStorage[KEY+':name'] = undefined;
|
|
1919
1920
|
localStorage[KEY+':logo'] = undefined;
|
|
1920
1921
|
this.signClient = undefined;
|
|
@@ -1923,14 +1924,14 @@ class WalletConnectV2 {
|
|
|
1923
1924
|
});
|
|
1924
1925
|
|
|
1925
1926
|
this.signClient.on("session_update", async(session)=> {
|
|
1926
|
-
if(_optionalChain$2([session, 'optionalAccess',
|
|
1927
|
+
if(_optionalChain$2([session, 'optionalAccess', _47 => _47.topic]) === _optionalChain$2([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {
|
|
1927
1928
|
this.session = this.signClient.session.get(session.topic);
|
|
1928
1929
|
await this.setSessionBlockchains();
|
|
1929
1930
|
}
|
|
1930
1931
|
});
|
|
1931
1932
|
|
|
1932
1933
|
this.signClient.on("session_event", (event)=> {
|
|
1933
|
-
if(_optionalChain$2([event, 'optionalAccess',
|
|
1934
|
+
if(_optionalChain$2([event, 'optionalAccess', _50 => _50.topic]) === _optionalChain$2([this, 'access', _51 => _51.session, 'optionalAccess', _52 => _52.topic])) {}
|
|
1934
1935
|
});
|
|
1935
1936
|
|
|
1936
1937
|
const connectWallet = async()=>{
|
|
@@ -1941,24 +1942,24 @@ class WalletConnectV2 {
|
|
|
1941
1942
|
await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
|
|
1942
1943
|
};
|
|
1943
1944
|
|
|
1944
|
-
const lastSession = _optionalChain$2([this, 'optionalAccess',
|
|
1945
|
+
const lastSession = _optionalChain$2([this, 'optionalAccess', _53 => _53.walletName, 'optionalAccess', _54 => _54.length]) ? await getLastSession(this.walletName) : undefined;
|
|
1945
1946
|
if(lastSession) {
|
|
1946
1947
|
this.session = lastSession;
|
|
1947
1948
|
} else {
|
|
1948
1949
|
await connectWallet();
|
|
1949
1950
|
}
|
|
1950
1951
|
|
|
1951
|
-
let meta = _optionalChain$2([this, 'access',
|
|
1952
|
+
let meta = _optionalChain$2([this, 'access', _55 => _55.session, 'optionalAccess', _56 => _56.peer, 'optionalAccess', _57 => _57.metadata]);
|
|
1952
1953
|
if(meta && meta.name) {
|
|
1953
1954
|
this.name = meta.name;
|
|
1954
1955
|
localStorage[KEY+':name'] = meta.name;
|
|
1955
|
-
if(_optionalChain$2([meta, 'optionalAccess',
|
|
1956
|
+
if(_optionalChain$2([meta, 'optionalAccess', _58 => _58.icons]) && meta.icons.length) {
|
|
1956
1957
|
this.logo = meta.icons[0];
|
|
1957
1958
|
localStorage[KEY+':logo'] = this.logo;
|
|
1958
1959
|
}
|
|
1959
1960
|
}
|
|
1960
|
-
if(_optionalChain$2([options, 'optionalAccess',
|
|
1961
|
-
if(_optionalChain$2([options, 'optionalAccess',
|
|
1961
|
+
if(_optionalChain$2([options, 'optionalAccess', _59 => _59.name])) { localStorage[KEY+':name'] = this.name = options.name; }
|
|
1962
|
+
if(_optionalChain$2([options, 'optionalAccess', _60 => _60.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
|
|
1962
1963
|
|
|
1963
1964
|
await this.setSessionBlockchains();
|
|
1964
1965
|
|
|
@@ -2015,7 +2016,7 @@ class WalletConnectV2 {
|
|
|
2015
2016
|
switch (event) {
|
|
2016
2017
|
case 'account':
|
|
2017
2018
|
internalCallback = async(event)=> {
|
|
2018
|
-
if(_optionalChain$2([event, 'optionalAccess',
|
|
2019
|
+
if(_optionalChain$2([event, 'optionalAccess', _61 => _61.topic]) === _optionalChain$2([this, 'access', _62 => _62.session, 'optionalAccess', _63 => _63.topic]) && event.params.event.name === 'accountsChanged') {
|
|
2019
2020
|
callback(await this.account());
|
|
2020
2021
|
}
|
|
2021
2022
|
};
|
package/dist/umd/index.evm.js
CHANGED
|
@@ -1329,7 +1329,8 @@
|
|
|
1329
1329
|
if(!localStorage[KEY+":projectId"]) { return }
|
|
1330
1330
|
if(walletName !== localStorage[KEY+":lastSessionWalletName"]) { return }
|
|
1331
1331
|
let signClient = await getSignClient();
|
|
1332
|
-
|
|
1332
|
+
let existingSessions;
|
|
1333
|
+
try { existingSessions = signClient.find(getWalletConnectV2Config(walletName)); } catch (e) {}
|
|
1333
1334
|
const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
|
|
1334
1335
|
if(lastSession && localStorage[KEY+":lastExpiredSessionTopic"] !== lastSession.topic && lastSession.expiry > Math.ceil(Date.now()/1000)) {
|
|
1335
1336
|
const result = await Promise.race([signClient.ping({ topic: lastSession.topic }), new Promise((resolve)=>setTimeout(resolve, 1500))]);
|
|
@@ -1423,13 +1424,13 @@
|
|
|
1423
1424
|
}
|
|
1424
1425
|
|
|
1425
1426
|
async setSessionBlockchains() {
|
|
1426
|
-
if(!this.session) { return }
|
|
1427
|
-
if(_optionalChain$2([CONFIGURATIONS, 'access',
|
|
1428
|
-
this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access',
|
|
1427
|
+
if(!this.session || !_optionalChain$2([this, 'access', _27 => _27.session, 'optionalAccess', _28 => _28.namespaces, 'optionalAccess', _29 => _29.eip155])) { return }
|
|
1428
|
+
if(_optionalChain$2([CONFIGURATIONS, 'access', _30 => _30[this.walletName], 'optionalAccess', _31 => _31.methods, 'optionalAccess', _32 => _32.includes, 'call', _33 => _33('wallet_switchEthereumChain')])) {
|
|
1429
|
+
this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
|
|
1429
1430
|
} else if(this.session.namespaces.eip155.chains) {
|
|
1430
|
-
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access',
|
|
1431
|
+
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(chainIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
|
|
1431
1432
|
} else if(this.session.namespaces.eip155.accounts) {
|
|
1432
|
-
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access',
|
|
1433
|
+
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access', _40 => _40.findByNetworkId, 'call', _41 => _41(accountIdentifier.split(':')[1]), 'optionalAccess', _42 => _42.name])).filter(Boolean);
|
|
1433
1434
|
}
|
|
1434
1435
|
}
|
|
1435
1436
|
|
|
@@ -1439,13 +1440,13 @@
|
|
|
1439
1440
|
|
|
1440
1441
|
try {
|
|
1441
1442
|
|
|
1442
|
-
this.walletName = _optionalChain$2([options, 'optionalAccess',
|
|
1443
|
+
this.walletName = _optionalChain$2([options, 'optionalAccess', _43 => _43.name]);
|
|
1443
1444
|
|
|
1444
1445
|
// delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
|
|
1445
1446
|
this.signClient = await getSignClient();
|
|
1446
1447
|
|
|
1447
1448
|
this.signClient.on("session_delete", (session)=> {
|
|
1448
|
-
if(_optionalChain$2([session, 'optionalAccess',
|
|
1449
|
+
if(_optionalChain$2([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$2([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
|
|
1449
1450
|
localStorage[KEY+':name'] = undefined;
|
|
1450
1451
|
localStorage[KEY+':logo'] = undefined;
|
|
1451
1452
|
this.signClient = undefined;
|
|
@@ -1454,14 +1455,14 @@
|
|
|
1454
1455
|
});
|
|
1455
1456
|
|
|
1456
1457
|
this.signClient.on("session_update", async(session)=> {
|
|
1457
|
-
if(_optionalChain$2([session, 'optionalAccess',
|
|
1458
|
+
if(_optionalChain$2([session, 'optionalAccess', _47 => _47.topic]) === _optionalChain$2([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {
|
|
1458
1459
|
this.session = this.signClient.session.get(session.topic);
|
|
1459
1460
|
await this.setSessionBlockchains();
|
|
1460
1461
|
}
|
|
1461
1462
|
});
|
|
1462
1463
|
|
|
1463
1464
|
this.signClient.on("session_event", (event)=> {
|
|
1464
|
-
if(_optionalChain$2([event, 'optionalAccess',
|
|
1465
|
+
if(_optionalChain$2([event, 'optionalAccess', _50 => _50.topic]) === _optionalChain$2([this, 'access', _51 => _51.session, 'optionalAccess', _52 => _52.topic])) {}
|
|
1465
1466
|
});
|
|
1466
1467
|
|
|
1467
1468
|
const connectWallet = async()=>{
|
|
@@ -1472,24 +1473,24 @@
|
|
|
1472
1473
|
await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
|
|
1473
1474
|
};
|
|
1474
1475
|
|
|
1475
|
-
const lastSession = _optionalChain$2([this, 'optionalAccess',
|
|
1476
|
+
const lastSession = _optionalChain$2([this, 'optionalAccess', _53 => _53.walletName, 'optionalAccess', _54 => _54.length]) ? await getLastSession(this.walletName) : undefined;
|
|
1476
1477
|
if(lastSession) {
|
|
1477
1478
|
this.session = lastSession;
|
|
1478
1479
|
} else {
|
|
1479
1480
|
await connectWallet();
|
|
1480
1481
|
}
|
|
1481
1482
|
|
|
1482
|
-
let meta = _optionalChain$2([this, 'access',
|
|
1483
|
+
let meta = _optionalChain$2([this, 'access', _55 => _55.session, 'optionalAccess', _56 => _56.peer, 'optionalAccess', _57 => _57.metadata]);
|
|
1483
1484
|
if(meta && meta.name) {
|
|
1484
1485
|
this.name = meta.name;
|
|
1485
1486
|
localStorage[KEY+':name'] = meta.name;
|
|
1486
|
-
if(_optionalChain$2([meta, 'optionalAccess',
|
|
1487
|
+
if(_optionalChain$2([meta, 'optionalAccess', _58 => _58.icons]) && meta.icons.length) {
|
|
1487
1488
|
this.logo = meta.icons[0];
|
|
1488
1489
|
localStorage[KEY+':logo'] = this.logo;
|
|
1489
1490
|
}
|
|
1490
1491
|
}
|
|
1491
|
-
if(_optionalChain$2([options, 'optionalAccess',
|
|
1492
|
-
if(_optionalChain$2([options, 'optionalAccess',
|
|
1492
|
+
if(_optionalChain$2([options, 'optionalAccess', _59 => _59.name])) { localStorage[KEY+':name'] = this.name = options.name; }
|
|
1493
|
+
if(_optionalChain$2([options, 'optionalAccess', _60 => _60.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
|
|
1493
1494
|
|
|
1494
1495
|
await this.setSessionBlockchains();
|
|
1495
1496
|
|
|
@@ -1546,7 +1547,7 @@
|
|
|
1546
1547
|
switch (event) {
|
|
1547
1548
|
case 'account':
|
|
1548
1549
|
internalCallback = async(event)=> {
|
|
1549
|
-
if(_optionalChain$2([event, 'optionalAccess',
|
|
1550
|
+
if(_optionalChain$2([event, 'optionalAccess', _61 => _61.topic]) === _optionalChain$2([this, 'access', _62 => _62.session, 'optionalAccess', _63 => _63.topic]) && event.params.event.name === 'accountsChanged') {
|
|
1550
1551
|
callback(await this.account());
|
|
1551
1552
|
}
|
|
1552
1553
|
};
|
package/dist/umd/index.js
CHANGED
|
@@ -1800,7 +1800,8 @@
|
|
|
1800
1800
|
if(!localStorage[KEY+":projectId"]) { return }
|
|
1801
1801
|
if(walletName !== localStorage[KEY+":lastSessionWalletName"]) { return }
|
|
1802
1802
|
let signClient = await getSignClient();
|
|
1803
|
-
|
|
1803
|
+
let existingSessions;
|
|
1804
|
+
try { existingSessions = signClient.find(getWalletConnectV2Config(walletName)); } catch (e) {}
|
|
1804
1805
|
const lastSession = existingSessions ? existingSessions[existingSessions.length-1] : undefined;
|
|
1805
1806
|
if(lastSession && localStorage[KEY+":lastExpiredSessionTopic"] !== lastSession.topic && lastSession.expiry > Math.ceil(Date.now()/1000)) {
|
|
1806
1807
|
const result = await Promise.race([signClient.ping({ topic: lastSession.topic }), new Promise((resolve)=>setTimeout(resolve, 1500))]);
|
|
@@ -1894,13 +1895,13 @@
|
|
|
1894
1895
|
}
|
|
1895
1896
|
|
|
1896
1897
|
async setSessionBlockchains() {
|
|
1897
|
-
if(!this.session) { return }
|
|
1898
|
-
if(_optionalChain$2([CONFIGURATIONS, 'access',
|
|
1899
|
-
this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access',
|
|
1898
|
+
if(!this.session || !_optionalChain$2([this, 'access', _27 => _27.session, 'optionalAccess', _28 => _28.namespaces, 'optionalAccess', _29 => _29.eip155])) { return }
|
|
1899
|
+
if(_optionalChain$2([CONFIGURATIONS, 'access', _30 => _30[this.walletName], 'optionalAccess', _31 => _31.methods, 'optionalAccess', _32 => _32.includes, 'call', _33 => _33('wallet_switchEthereumChain')])) {
|
|
1900
|
+
this.blockchains = [this.session.namespaces.eip155.chains[this.session.namespaces.eip155.chains.length-1]].map((chainIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access', _34 => _34.findByNetworkId, 'call', _35 => _35(chainIdentifier.split(':')[1]), 'optionalAccess', _36 => _36.name])).filter(Boolean);
|
|
1900
1901
|
} else if(this.session.namespaces.eip155.chains) {
|
|
1901
|
-
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access',
|
|
1902
|
+
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access', _37 => _37.findByNetworkId, 'call', _38 => _38(chainIdentifier.split(':')[1]), 'optionalAccess', _39 => _39.name])).filter(Boolean);
|
|
1902
1903
|
} else if(this.session.namespaces.eip155.accounts) {
|
|
1903
|
-
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access',
|
|
1904
|
+
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$2([Blockchains__default['default'], 'access', _40 => _40.findByNetworkId, 'call', _41 => _41(accountIdentifier.split(':')[1]), 'optionalAccess', _42 => _42.name])).filter(Boolean);
|
|
1904
1905
|
}
|
|
1905
1906
|
}
|
|
1906
1907
|
|
|
@@ -1910,13 +1911,13 @@
|
|
|
1910
1911
|
|
|
1911
1912
|
try {
|
|
1912
1913
|
|
|
1913
|
-
this.walletName = _optionalChain$2([options, 'optionalAccess',
|
|
1914
|
+
this.walletName = _optionalChain$2([options, 'optionalAccess', _43 => _43.name]);
|
|
1914
1915
|
|
|
1915
1916
|
// delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
|
|
1916
1917
|
this.signClient = await getSignClient();
|
|
1917
1918
|
|
|
1918
1919
|
this.signClient.on("session_delete", (session)=> {
|
|
1919
|
-
if(_optionalChain$2([session, 'optionalAccess',
|
|
1920
|
+
if(_optionalChain$2([session, 'optionalAccess', _44 => _44.topic]) === _optionalChain$2([this, 'access', _45 => _45.session, 'optionalAccess', _46 => _46.topic])) {
|
|
1920
1921
|
localStorage[KEY+':name'] = undefined;
|
|
1921
1922
|
localStorage[KEY+':logo'] = undefined;
|
|
1922
1923
|
this.signClient = undefined;
|
|
@@ -1925,14 +1926,14 @@
|
|
|
1925
1926
|
});
|
|
1926
1927
|
|
|
1927
1928
|
this.signClient.on("session_update", async(session)=> {
|
|
1928
|
-
if(_optionalChain$2([session, 'optionalAccess',
|
|
1929
|
+
if(_optionalChain$2([session, 'optionalAccess', _47 => _47.topic]) === _optionalChain$2([this, 'access', _48 => _48.session, 'optionalAccess', _49 => _49.topic])) {
|
|
1929
1930
|
this.session = this.signClient.session.get(session.topic);
|
|
1930
1931
|
await this.setSessionBlockchains();
|
|
1931
1932
|
}
|
|
1932
1933
|
});
|
|
1933
1934
|
|
|
1934
1935
|
this.signClient.on("session_event", (event)=> {
|
|
1935
|
-
if(_optionalChain$2([event, 'optionalAccess',
|
|
1936
|
+
if(_optionalChain$2([event, 'optionalAccess', _50 => _50.topic]) === _optionalChain$2([this, 'access', _51 => _51.session, 'optionalAccess', _52 => _52.topic])) {}
|
|
1936
1937
|
});
|
|
1937
1938
|
|
|
1938
1939
|
const connectWallet = async()=>{
|
|
@@ -1943,24 +1944,24 @@
|
|
|
1943
1944
|
await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
|
|
1944
1945
|
};
|
|
1945
1946
|
|
|
1946
|
-
const lastSession = _optionalChain$2([this, 'optionalAccess',
|
|
1947
|
+
const lastSession = _optionalChain$2([this, 'optionalAccess', _53 => _53.walletName, 'optionalAccess', _54 => _54.length]) ? await getLastSession(this.walletName) : undefined;
|
|
1947
1948
|
if(lastSession) {
|
|
1948
1949
|
this.session = lastSession;
|
|
1949
1950
|
} else {
|
|
1950
1951
|
await connectWallet();
|
|
1951
1952
|
}
|
|
1952
1953
|
|
|
1953
|
-
let meta = _optionalChain$2([this, 'access',
|
|
1954
|
+
let meta = _optionalChain$2([this, 'access', _55 => _55.session, 'optionalAccess', _56 => _56.peer, 'optionalAccess', _57 => _57.metadata]);
|
|
1954
1955
|
if(meta && meta.name) {
|
|
1955
1956
|
this.name = meta.name;
|
|
1956
1957
|
localStorage[KEY+':name'] = meta.name;
|
|
1957
|
-
if(_optionalChain$2([meta, 'optionalAccess',
|
|
1958
|
+
if(_optionalChain$2([meta, 'optionalAccess', _58 => _58.icons]) && meta.icons.length) {
|
|
1958
1959
|
this.logo = meta.icons[0];
|
|
1959
1960
|
localStorage[KEY+':logo'] = this.logo;
|
|
1960
1961
|
}
|
|
1961
1962
|
}
|
|
1962
|
-
if(_optionalChain$2([options, 'optionalAccess',
|
|
1963
|
-
if(_optionalChain$2([options, 'optionalAccess',
|
|
1963
|
+
if(_optionalChain$2([options, 'optionalAccess', _59 => _59.name])) { localStorage[KEY+':name'] = this.name = options.name; }
|
|
1964
|
+
if(_optionalChain$2([options, 'optionalAccess', _60 => _60.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
|
|
1964
1965
|
|
|
1965
1966
|
await this.setSessionBlockchains();
|
|
1966
1967
|
|
|
@@ -2017,7 +2018,7 @@
|
|
|
2017
2018
|
switch (event) {
|
|
2018
2019
|
case 'account':
|
|
2019
2020
|
internalCallback = async(event)=> {
|
|
2020
|
-
if(_optionalChain$2([event, 'optionalAccess',
|
|
2021
|
+
if(_optionalChain$2([event, 'optionalAccess', _61 => _61.topic]) === _optionalChain$2([this, 'access', _62 => _62.session, 'optionalAccess', _63 => _63.topic]) && event.params.event.name === 'accountsChanged') {
|
|
2021
2022
|
callback(await this.account());
|
|
2022
2023
|
}
|
|
2023
2024
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depay/web3-wallets-evm",
|
|
3
3
|
"moduleName": "Web3Wallets",
|
|
4
|
-
"version": "16.2.
|
|
4
|
+
"version": "16.2.9",
|
|
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",
|