Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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");
}
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;
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();
}
}
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
}
}
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();
});
});
return new Promise(function(resolve, reject) {
Apis.instance("wss://bitshares.openledger.info/ws", true)
.init_promise.then(resolve)
.catch(reject);
});
});
before(function() {
return Apis.instance(
"wss://eu.nodes.bitshares.ws",
true
).init_promise;
});
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"
}
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);
});
}
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;
});
}