Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function preparePage() {
let sessions = await fluence.connect(contractAddress, appId);
let client = new DbClient(sessions);
function updateStatus() {
client.status().then((r) => {
let addrs = client.appSession.workerSessions.map((s) => s.session.tm.addr);
statusField.innerHTML = r.map((status, idx) => {
let addr = addrs[idx];
// if there is a response from a node
if (isAvailable(status)) {
let info = status.workers[0];
if (info.WorkerRunning !== undefined) {
let runningInfo = info.WorkerRunning.info;
let status: Status = {
addr: addr,
block_hash: shorten(runningInfo.lastBlock as string, 10),
};
const iconEl = function (): HTMLElement {
return window.document.getElementById(iconId) as HTMLElement;
};
const buttonEl = function (): HTMLButtonElement {
return window.document.getElementById(buttonId) as HTMLButtonElement;
};
let session: AppSession;
let auth = undefined;
if (shortName.toLowerCase() === 'llamadb fork') {
auth = llamaPrivateKey;
}
fluence.connect(defaultContractAddress, appId.toString(), fluenceNodeAddr, auth).then(s => {
session = s;
buttonEl().disabled = false;
buttonEl().onclick = function (): any {
if (inputField().value.trim().length !== 0) {
iconEl().style.display = 'inline-block';
buttonEl().disabled = true;
const queries = inputField().value.trim().split('\n').filter(s => {
return s.trim().length !== 0;
});
const results = queries.map(q => {
const res = session.request(q);
return res.then(r => {
return parser(r.asString().trim());
});
});