get ltc balance

This commit is contained in:
2024-07-17 17:00:43 -04:00
parent f6c0afbc40
commit 0399c9d147
3 changed files with 101 additions and 5 deletions

View File

@@ -121,6 +121,35 @@ document.addEventListener('qortalExtensionRequests', async (event) => {
}));
}
});
} else if(type === 'REQUEST_LTC_BALANCE'){
const hostname = window.location.hostname
const res = await connection(hostname)
if(!res){
document.dispatchEvent(new CustomEvent('qortalExtensionResponses', {
detail: { type: "USER_INFO", data: {
error: "Not authorized"
}, requestId }
}));
return
}
chrome.runtime.sendMessage({ action: "ltcBalance", payload: {
hostname
}, timeout }, (response) => {
if (response.error) {
document.dispatchEvent(new CustomEvent('qortalExtensionResponses', {
detail: { type: "LTC_BALANCE", data: {
error: response.error
}, requestId }
}));
} else {
// Include the requestId in the detail when dispatching the response
document.dispatchEvent(new CustomEvent('qortalExtensionResponses', {
detail: { type: "LTC_BALANCE", data: response, requestId }
}));
}
});
} else if (type === 'REQUEST_AUTHENTICATION') {
const hostname = window.location.hostname
const res = await connection(hostname)