How to use the fluence.connect function in fluence

To help you get started, we’ve selected a few fluence examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fluencelabs / fluence / fluence-js / src / examples / fluence-sqldb / index.ts View on Github external
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),
github fluencelabs / fluence / dashboard / src / front / components / fluence-app-snippet / index.tsx View on Github external
};
        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());
                        });
                    });

fluence

the browser js-libp2p client for the Fluence network

Apache-2.0
Latest version published 3 years ago

Package Health Score

40 / 100
Full package analysis