Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into bitshares
Browse files Browse the repository at this point in the history
  • Loading branch information
valzav committed Dec 16, 2015
2 parents dc90808 + 5af33cb commit e125422
Show file tree
Hide file tree
Showing 162 changed files with 2,065 additions and 3,162 deletions.
2 changes: 1 addition & 1 deletion dl/src/actions/AccountActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ class AccountActions {
}
}

module.exports = alt.createActions(AccountActions);
export default alt.createActions(AccountActions);
2 changes: 1 addition & 1 deletion dl/src/actions/AssetActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,4 @@ class AssetActions {
}
}

module.exports = alt.createActions(AssetActions);
export default alt.createActions(AssetActions);
2 changes: 1 addition & 1 deletion dl/src/actions/BlockchainActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ class BlockchainActions {
const BlockchainActionsInstance = alt.createActions(BlockchainActions);
Apis.setRpcConnectionStatusCallback(BlockchainActionsInstance.updateRpcConnectionStatus);

module.exports = BlockchainActionsInstance;
export default BlockchainActionsInstance;
2 changes: 1 addition & 1 deletion dl/src/actions/MarketsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ class MarketsActions {

}

module.exports = alt.createActions(MarketsActions);
export default alt.createActions(MarketsActions);
8 changes: 8 additions & 0 deletions dl/src/actions/SettingsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ class SettingsActions {
this.dispatch({quote, base});
}

addStarAccount(account) {
this.dispatch(account);
}

removeStarAccount(account) {
this.dispatch(account);
}

addWS(ws) {
this.dispatch(ws);
}
Expand Down
4 changes: 2 additions & 2 deletions dl/src/actions/WalletActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class WalletActions {
}
// With a lot of balance claims the signing can take so Long
// the transaction will expire. This will increase the timeout...
tr.set_expire_seconds(config.expire_in_secs + balance_claims.length)
tr.set_expire_seconds( (15 * 60) + balance_claims.length)

return WalletDb.process_transaction(
tr, Object.keys(signer_pubkeys), broadcast ).then(
Expand All @@ -197,4 +197,4 @@ class WalletActions {
}
}

module.exports = alt.createActions(WalletActions)
export default alt.createActions(WalletActions)
134 changes: 87 additions & 47 deletions dl/src/api/ChainStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,21 @@ class ChainStore
let obj = updated_objects[a][i]

if( utils.is_object_id( obj ) ) { /// the object was removed

// Cancelled limit order, emit event for MarketStore to update it's state
if( obj.search( order_prefix ) == 0 ) {
let old_obj = this.objects_by_id.get(obj);
if (!old_obj) {
return;
}
emitter.emit('cancel-order', old_obj.get("id"));
let account = this.objects_by_id.get(old_obj.get("seller"));
if (account && account.has("orders")) {
let limit_orders = account.get("orders");
if (account.get("orders").has(obj)) {
account = account.set("orders", limit_orders.delete(obj));
this.objects_by_id = this.objects_by_id.set( account.get("id"), account );
}
}
}

// Update nested call_order inside account object
Expand Down Expand Up @@ -695,7 +702,7 @@ class ChainStore
account.lifetime_referrer_name = lifetime_referrer_name
account.registrar_name = registrar_name
account.balances = {}
account.orders = new Immutable.Set(limit_orders)
account.orders = new Immutable.Set()
account.vesting_balances = new Immutable.Set()
account.balances = new Immutable.Map()
account.call_orders = new Immutable.Set()
Expand All @@ -716,6 +723,13 @@ class ChainStore
});
});

account.orders = account.orders.withMutations(set => {
limit_orders.forEach(order => {
this._updateObject( order, false )
set.add( order.id )
});
});

account.call_orders = account.call_orders.withMutations(set => {
call_orders.forEach(co => {
this._updateObject( co, false )
Expand Down Expand Up @@ -869,50 +883,50 @@ class ChainStore
* then updates the account object with relevant meta-info depending
* upon the type of account
*/
_updateAccount( account_id, payload )
{
let updates = payload[0]

for( let i = 0; i < updates.length; ++i )
{
let update = updates[i]
if( typeof update == 'string' )
{
let old_obj = this._removeObject( update )

if( update.search( order_prefix ) == 0 )
{
acnt = acnt.setIn( ['orders'], set => set.delete(update) )
}
else if( update.search( vesting_balance_prefix ) == 0 )
{
acnt = acnt.setIn( ['vesting_balances'], set => set.delete(update) )
}
}
else
{
let updated_obj = this._updateObject( update )
if( update.id.search( balance_prefix ) == 0 )
{
if( update.owner == account_id )
acnt = acnt.setIn( ['balances'], map => map.set(update.asset_type,update.id) )
}
else if( update.id.search( order_prefix ) == 0 )
{
if( update.owner == account_id )
acnt = acnt.setIn( ['orders'], set => set.add(update.id) )
}
else if( update.id.search( vesting_balance_prefix ) == 0 )
{
if( update.owner == account_id )
acnt = acnt.setIn( ['vesting_balances'], set => set.add(update.id) )
}

this.objects_by_id = this.objects_by_id.set( acnt.id, acnt )
}
}
this.fetchRecentHistory( acnt )
}
// _updateAccount( account_id, payload )
// {
// let updates = payload[0]

// for( let i = 0; i < updates.length; ++i )
// {
// let update = updates[i]
// if( typeof update == 'string' )
// {
// let old_obj = this._removeObject( update )

// if( update.search( order_prefix ) == 0 )
// {
// acnt = acnt.setIn( ['orders'], set => set.delete(update) )
// }
// else if( update.search( vesting_balance_prefix ) == 0 )
// {
// acnt = acnt.setIn( ['vesting_balances'], set => set.delete(update) )
// }
// }
// else
// {
// let updated_obj = this._updateObject( update )
// if( update.id.search( balance_prefix ) == 0 )
// {
// if( update.owner == account_id )
// acnt = acnt.setIn( ['balances'], map => map.set(update.asset_type,update.id) )
// }
// else if( update.id.search( order_prefix ) == 0 )
// {
// if( update.owner == account_id )
// acnt = acnt.setIn( ['orders'], set => set.add(update.id) )
// }
// else if( update.id.search( vesting_balance_prefix ) == 0 )
// {
// if( update.owner == account_id )
// acnt = acnt.setIn( ['vesting_balances'], set => set.add(update.id) )
// }

// this.objects_by_id = this.objects_by_id.set( acnt.id, acnt )
// }
// }
// this.fetchRecentHistory( acnt )
// }


/**
Expand All @@ -933,6 +947,8 @@ class ChainStore
// if (!(object.id.split(".")[0] == 2) && !(object.id.split(".")[1] == 6)) {
// console.log( "update: ", object )
// }

// DYNAMIC GLOBAL OBJECT
if( object.id == "2.1.0" ) {
object.participation = 100*(BigInteger(object.recent_slots_filled).bitCount() / 128.0)
this.head_block_time_string = object.time
Expand All @@ -952,6 +968,7 @@ class ChainStore
}


// BALANCE OBJECT
if( object.id.substring(0,balance_prefix.length) == balance_prefix )
{
let owner = this.objects_by_id.get( object.owner )
Expand All @@ -973,6 +990,7 @@ class ChainStore
}
this.objects_by_id = this.objects_by_id.set( object.owner, owner )
}
// ACCOUNT STATS OBJECT
else if( object.id.substring(0,account_stats_prefix.length) == account_stats_prefix )
{
// console.log( "HISTORY CHANGED" )
Expand All @@ -982,16 +1000,19 @@ class ChainStore
this.fetchRecentHistory( object.owner );
}
}
// WITNESS OBJECT
else if( object.id.substring(0,witness_prefix.length) == witness_prefix )
{
this.witness_by_account_id.set( object.witness_account, object.id )
this.objects_by_vote_id.set( object.vote_id, object.id )
}
// COMMITTEE MEMBER OBJECT
else if( object.id.substring(0,committee_prefix.length) == committee_prefix )
{
this.committee_by_account_id.set( object.committee_member_account, object.id )
this.objects_by_vote_id.set( object.vote_id, object.id )
}
// ACCOUNT OBJECT
else if( object.id.substring(0,account_prefix.length) == account_prefix )
{
current = current.set( 'active', Immutable.fromJS( object.active ) );
Expand All @@ -1004,6 +1025,7 @@ class ChainStore
this.objects_by_id = this.objects_by_id.set( object.id, current );
this.accounts_by_name = this.accounts_by_name.set( object.name, object.id )
}
// ASSET OBJECT
else if( object.id.substring(0,asset_prefix.length) == asset_prefix )
{
this.assets_by_symbol = this.assets_by_symbol.set( object.symbol, object.id )
Expand Down Expand Up @@ -1036,6 +1058,7 @@ class ChainStore
this.objects_by_id = this.objects_by_id.set( object.id, current );
}
}
// ASSET DYNAMIC DATA OBJECT
else if( object.id.substring(0,asset_dynamic_data_prefix.length) == asset_dynamic_data_prefix )
{
// let asset_id = asset_prefix + object.id.substring( asset_dynamic_data_prefix.length )
Expand All @@ -1049,11 +1072,13 @@ class ChainStore
}

}
// WORKER OBJECT
else if( object.id.substring(0,worker_prefix.length ) == worker_prefix )
{
this.objects_by_vote_id.set( object.vote_for, object.id );
this.objects_by_vote_id.set( object.vote_against, object.id );
}
// BITASSET DATA OBJECT
else if( object.id.substring(0,bitasset_data_prefix.length) == bitasset_data_prefix )
{
let asset_id = current.get( "asset_id" );
Expand All @@ -1065,21 +1090,36 @@ class ChainStore
}
}
}
// CALL ORDER OBJECT
else if( object.id.substring(0,call_order_prefix.length ) == call_order_prefix )
{
// Update nested call_orders inside account object
if (emit) {
emitter.emit("call-order-update", object);
}

let account = this.objects_by_id.get(object.borrower);
if (account && account.has("call_orders")) {
let call_orders = account.get("call_orders");
if (!account.get("call_orders").has(object.id)) {
if (!call_orders.has(object.id)) {
account = account.set("call_orders", call_orders.add(object.id));
this.objects_by_id = this.objects_by_id.set( account.get("id"), account );
}
}
}
// LIMIT ORDER OBJECT
else if( object.id.substring(0,order_prefix.length ) == order_prefix ) {
let account = this.objects_by_id.get(object.seller);
if (account && account.has("orders")) {
let limit_orders = account.get("orders");
if (!limit_orders.has(object.id)) {
account = account.set("orders", limit_orders.add(object.id));
this.objects_by_id = this.objects_by_id.set( account.get("id"), account );
}
}
}



if( notify_subscribers )
this.notifySubscribers()
Expand Down
8 changes: 6 additions & 2 deletions dl/src/common/market_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class MarketUtils {
let price_full = utils.get_asset_price(order.receives.amount, receivesAsset, order.pays.amount, paysAsset, isAsk);
// price_full = !flipped ? (1 / price_full) : price_full;
// let {int, dec} = this.split_price(price_full, isAsk ? receivesAsset.get("precision") : paysAsset.get("precision"));

let {int, dec, trailing} = utils.price_to_text(price_full, isAsk ? receivesAsset : paysAsset, isAsk ? paysAsset : receivesAsset);
let className = isCall ? "orderHistoryCall" : isAsk ? "orderHistoryBid" : "orderHistoryAsk";

Expand All @@ -155,17 +156,20 @@ class MarketUtils {
time = order.time.split("T")[1];
let now = new Date();
let offset = now.getTimezoneOffset() / 60;
let date = utils.format_date(order.time + "Z").split("/");
let hour = time.substr(0, 2);
let hourNumber = parseInt(hour, 10);
let localHour = hourNumber - offset
let localHour = hourNumber - offset;
if (localHour >= 24) {
localHour -= 24;
} else if (localHour < 0) {
localHour += 24;
}
let hourString = localHour.toString();
if (parseInt(hourString, 10) < 10) {
hourString = "0" + hourString;
}
time = time.replace(hour, hourString);
time = date[0] + "/" + date[1] + " " + time.replace(hour, hourString);
}
return {
receives: isAsk ? receives : pays,
Expand Down
Loading

0 comments on commit e125422

Please sign in to comment.