Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cancelLimitOrder(accountID, orderID) {
// Set the fee asset to use
let fee_asset_id = accountUtils.getFinalFeeAsset(
accountID,
"limit_order_cancel"
);
var tr = WalletApi.new_transaction();
tr.add_type_operation("limit_order_cancel", {
fee: {
amount: 0,
asset_id: fee_asset_id
},
fee_paying_account: accountID,
order: orderID
});
return WalletDb.process_transaction(tr, null, true).catch(error => {
console.log("cancel error:", error);
});
}
createPredictionShort(
order,
collateral,
account,
sellAmount,
sellAsset,
buyAmount,
collateralAmount,
buyAsset,
expiration,
isFillOrKill,
fee_asset_id = "1.3.0"
) {
var tr = WalletApi.new_transaction();
// Set the fee asset to use
fee_asset_id = accountUtils.getFinalFeeAsset(
order.seller,
"call_order_update",
order.fee.asset_id
);
order.setExpiration();
tr.add_type_operation("call_order_update", {
fee: {
amount: 0,
asset_id: fee_asset_id
},
funding_account: order.seller,
upgradeAccount(account_id, lifetime) {
// Set the fee asset to use
let fee_asset_id = accountUtils.getFinalFeeAsset(
account_id,
"account_upgrade"
);
var tr = WalletApi.new_transaction();
tr.add_type_operation("account_upgrade", {
fee: {
amount: 0,
asset_id: fee_asset_id
},
account_to_upgrade: account_id,
upgrade_to_lifetime_member: lifetime
});
return WalletDb.process_transaction(tr, null, true);
}
claimPoolFees(account_id, asset, amount) {
let tr = WalletApi.new_transaction();
tr.add_type_operation("asset_claim_fees", {
fee: {
amount: 0,
asset_id: 0
},
issuer: account_id,
amount_to_claim: {
asset_id: asset.get("id"),
amount: amount.getAmount()
}
});
return dispatch => {
return WalletDb.process_transaction(tr, null, true)
.then(() => {
dispatch(true);
updateFeedProducers(account, asset, producers) {
let tr = WalletApi.new_transaction();
tr.add_type_operation("asset_update_feed_producers", {
fee: {
amount: 0,
asset_id: "1.3.0"
},
issuer: account,
asset_to_update: asset.get("id"),
new_feed_producers: producers
});
return dispatch => {
return WalletDb.process_transaction(tr, null, true)
.then(() => {
dispatch(true);
})
.catch(error => {
createWitness({url, account, signingKey}) {
const account_id = account.get("id");
var tr = WalletApi.new_transaction();
tr.add_type_operation("witness_create", {
fee: {
amount: 0,
asset_id: "1.3.0"
},
witness_account: account_id,
url: url,
block_signing_key: signingKey
});
return dispatch => {
return WalletDb.process_transaction(tr, null, true)
.then(() => {
dispatch(true);
})
.catch(error => {
_onRemove(listing, account, e) {
if (account) {
let currentState = this.props.getCurrentState(account);
let tr = WalletApi.new_transaction();
tr.add_type_operation("account_whitelist", {
fee: {
amount: 0,
asset_id:
ChainStore.assets_by_symbol.get(
this.props.settings.get("fee_asset")
) || "1.3.0"
},
authorizing_account: this.props.account.get("id"),
account_to_list: account,
new_listing: currentState - constants.account_listing[listing]
});
WalletDb.process_transaction(tr, null, true);
}
}
extend({htlc_id, user_id, seconds_to_add}) {
let tr = WalletApi.new_transaction();
tr.add_type_operation("htlc_extend", {
fee: {
amount: 0,
asset_id: "1.3.0"
},
htlc_id: htlc_id,
update_issuer: user_id,
seconds_to_add: seconds_to_add
});
return dispatch => {
return WalletDb.process_transaction(tr, null, true)
.then(() => {
dispatch(true);
})
bidCollateral(account_id, core, asset, coll, debt) {
let core_precision = utils.get_asset_precision(core.get("precision"));
let asset_precision = utils.get_asset_precision(asset.get("precision"));
var tr = WalletApi.new_transaction();
tr.add_type_operation("bid_collateral", {
fee: {
amount: 0,
asset_id: "1.3.0"
},
bidder: account_id,
additional_collateral: {
amount: coll * core_precision,
asset_id: core.get("id")
},
debt_covered: {
amount: debt * asset_precision,
asset_id: asset.get("id")
},
extensions: []
});
publishFeed({publisher, asset_id, mcr, mssr, feedPrice, cer}) {
let tr = WalletApi.new_transaction();
/**
* The naming convention is confusing!
*
* bitshares-core knows only settlement_price, which is the feed price as known from UI!
*
* UI definition:
* - Feed Price: Witness fed price, given by backend as settlement_price
* - Settlement Price: feed price * force settlement offset factor
*
*/
tr.add_type_operation("asset_publish_feed", {
publisher,
asset_id,
feed: {
settlement_price: feedPrice.toObject(),
maintenance_collateral_ratio: mcr,