2021-09-30 09:43:29 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
2021-10-21 14:46:24 +00:00
|
|
|
property var web3ProviderInst: providerModule
|
2021-09-30 09:43:29 +00:00
|
|
|
property var urlENSDictionary: ({})
|
|
|
|
|
2021-11-15 15:06:25 +00:00
|
|
|
property int networkId: providerModule.networkId
|
|
|
|
|
2021-11-18 23:40:49 +00:00
|
|
|
function revokeAllPermissions(){
|
|
|
|
dappPermissionsModule.revokeAllPermissions()
|
|
|
|
}
|
|
|
|
|
2021-09-30 09:43:29 +00:00
|
|
|
function determineRealURL(text){
|
|
|
|
var url = RootStore.getUrlFromUserInput(text);
|
2021-10-21 14:46:24 +00:00
|
|
|
var host = providerModule.getHost(url);
|
2021-09-30 09:43:29 +00:00
|
|
|
if(host.endsWith(".eth")){
|
2021-10-26 14:36:31 +00:00
|
|
|
var ensResource = providerModule.ensResourceURL(host, url);
|
2021-09-30 09:43:29 +00:00
|
|
|
|
|
|
|
if(/^https\:\/\/swarm\-gateways\.net\/bzz:\/([0-9a-fA-F]{64}|.+\.eth)(\/?)/.test(ensResource)){
|
|
|
|
// TODO: populate urlENSDictionary for prettier url instead of swarm-gateway big URL
|
|
|
|
return ensResource;
|
|
|
|
} else {
|
2021-10-21 14:46:24 +00:00
|
|
|
urlENSDictionary[providerModule.getHost(ensResource)] = host;
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
url = ensResource;
|
|
|
|
}
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
function obtainAddress(url) {
|
2021-10-21 14:46:24 +00:00
|
|
|
var ensAddr = urlENSDictionary[providerModule.getHost(url)];
|
|
|
|
return ensAddr ? providerModule.replaceHostByENS( url, ensAddr) : url;
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
}
|