How to use bitsharesjs-ws - 10 common examples

To help you get started, we’ve selected a few bitsharesjs-ws 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 bitshares / bitsharesjs / examples / chainStore.js View on Github external
import {Apis} from "bitsharesjs-ws";
import {ChainStore} from "../lib";

Apis.instance("wss://eu.nodes.bitshares.ws", true).init_promise.then(res => {
    console.log("connected to:", res[0].network);
    ChainStore.init(false).then(() => {
        ChainStore.subscribe(updateState);
    });
});

let dynamicGlobal = null;
function updateState(object) {
    // dynamicGlobal = ChainStore.getObject("2.1.0");

    console.log("ChainStore object update");
}
github bitshares / bitsharesjs / lib / chain / src / TransactionBuilder.js View on Github external
if (!this.signed) {
            this.sign();
        }
        if (!this.tr_buffer) {
            throw new Error("not finalized");
        }
        if (!this.signatures.length) {
            throw new Error("not signed");
        }
        if (!this.operations.length) {
            throw new Error("no operations");
        }

        var tr_object = ops.signed_transaction.toObject(this);
        // console.log('... broadcast_transaction_with_callback !!!')
        Apis.instance()
            .network_api()
            .exec("broadcast_transaction_with_callback", [
                function(res) {
                    return resolve(res);
                },
                tr_object
            ])
            .then(function() {
                //console.log('... broadcast success, waiting for callback')
                if (was_broadcast_callback) was_broadcast_callback();
                return;
            })
            .catch(error => {
                // console.log may be redundant for network errors, other errors could occur
                console.log(error);
                var message = error.message;
github bitshares / bitshares-ui / app / components / Account / BalanceWrapper.jsx View on Github external
componentWillMount() {
        if (
            Apis.instance().chain_id.substr(0, 8) === "4018d784" &&
            !this.props.skipCoinFetch
        ) {
            // Only fetch this when on BTS main net
            GatewayActions.fetchCoins();
            GatewayActions.fetchBridgeCoins();
        }
    }
github bitshares / bitshares-ui / app / components / Account / AccountDepositWithdraw.jsx View on Github external
componentWillMount() {
        if (Apis.instance().chain_id.substr(0, 8) === "4018d784") { // Only fetch this when on BTS main net
            GatewayActions.fetchCoins.defer(); // Openledger
            GatewayActions.fetchCoinsSimple.defer({backer: "RUDEX", url:rudexAPIs.BASE+rudexAPIs.COINS_LIST}); // RuDEX
            GatewayActions.fetchCoins.defer({backer: "TRADE"}); // Blocktrades
        }
    }
github bitshares / bitsharesjs / test / chain / ChainStore.js View on Github external
before(function() {
        return Apis.instance(
            "wss://eu.nodes.bitshares.ws",
            true
        ).init_promise.then(function(result) {
            coreAsset = result[0].network.core_asset;
            return ChainStore.init();
        });
    });
github bitshares / bitsharesjs / test / chain / TransactionBuilder.js View on Github external
return new Promise(function(resolve, reject) {
            Apis.instance("wss://bitshares.openledger.info/ws", true)
                .init_promise.then(resolve)
                .catch(reject);
        });
    });
github bitshares / bitsharesjs / test / serializer / call_order_update.js View on Github external
before(function() {
            return Apis.instance(
                "wss://eu.nodes.bitshares.ws",
                true
            ).init_promise;
        });
github bitshares / bitsharesjs / examples / transfer.js View on Github external
import {Apis} from "bitsharesjs-ws";
import {ChainStore, FetchChain, PrivateKey, TransactionHelper, Aes, TransactionBuilder} from "../lib";

var privKey = "5KBuq5WmHvgePmB7w3onYsqLM8ESomM2Ae7SigYuuwg8MDHW7NN";
let pKey = PrivateKey.fromWif(privKey);

Apis.instance("wss://node.testnet.bitshares.eu", true)
.init_promise.then((res) => {
    console.log("connected to:", res[0].network_name, "network");

    ChainStore.init().then(() => {

        let fromAccount = "bitsharesjs";
        let memoSender = fromAccount;
        let memo = "Testing transfer from node.js";

        let toAccount = "faucet";

        let sendAmount = {
            amount: 10000,
            asset: "TEST"
        }
github bitshares / bitshares-ui / app / components / Account / AccountVesting.jsx View on Github external
retrieveVestingBalances(accountId) {
        accountId = accountId || this.props.account.get("id");
        Apis.instance()
            .db_api()
            .exec("get_vesting_balances", [accountId])
            .then(vbs => {
                this.setState({vbs});
            })
            .catch(err => {
                console.log("error:", err);
            });
    }
github bitshares / bitsharesjs / lib / chain / src / TransactionBuilder.js View on Github external
get_required_signatures(available_keys) {
        if (!available_keys.length) {
            return Promise.resolve([]);
        }
        var tr_object = ops.signed_transaction.toObject(this);
        //DEBUG console.log('... tr_object',tr_object)
        return Apis.instance()
            .db_api()
            .exec("get_required_signatures", [tr_object, available_keys])
            .then(function(required_public_keys) {
                //DEBUG console.log('... get_required_signatures',required_public_keys)
                return required_public_keys;
            });
    }

bitsharesjs-ws

Pure JavaScript BitShares websocket interface for node.js and browsers.

MIT
Latest version published 10 months ago

Package Health Score

66 / 100
Full package analysis

Popular bitsharesjs-ws functions

Similar packages