diff --git a/app/ajax/service.js b/app/ajax/service.js index b026d93b..f7de16e1 100644 --- a/app/ajax/service.js +++ b/app/ajax/service.js @@ -26,7 +26,7 @@ export default AjaxService.extend({ } finally { promise.xhr.abort(); } - }).enqueue().maxConcurrency(5), + }).enqueue().maxConcurrency(10), request(...args) { const originalFn = this._super; diff --git a/app/index/route.js b/app/index/route.js index a8edfbc2..a8a0f690 100644 --- a/app/index/route.js +++ b/app/index/route.js @@ -12,7 +12,6 @@ export default Route.extend({ if (!wallet) { transaction.abort(); wallet = await this.store.createRecord('wallet').save(); - settings.setProperties(this.store.serialize(wallet, { includeId: true })); return this.transitionTo('wallets', wallet); } diff --git a/app/rpc/service.js b/app/rpc/service.js index ab8704b3..600d178e 100644 --- a/app/rpc/service.js +++ b/app/rpc/service.js @@ -6,12 +6,13 @@ import { service } from 'ember-decorators/service'; export const actions = { WALLET_CREATE: 'wallet_create', + WALLET_BALANCE_TOTAL: 'wallet_balance_total', + WALLET_CHANGE_SEED: 'wallet_change_seed', ACCOUNT_CREATE: 'account_create', ACCOUNT_INFO: 'account_info', - WALLET_BALANCE_TOTAL: 'wallet_balance_total', ACCOUNT_LIST: 'account_list', - SEND: 'send', ACCOUNT_HISTORY: 'account_history', + SEND: 'send', PEERS: 'peers', BLOCK_COUNT: 'block_count', }; @@ -28,6 +29,15 @@ export default Service.extend({ return this.call(actions.WALLET_CREATE); }, + walletBalanceTotal(wallet) { + return this.call(actions.WALLET_BALANCE_TOTAL, { wallet }); + }, + + async walletChangeSeed() { + const { success } = this.call(actions.WALLET_CHANGE_SEED); + return success === ''; + }, + accountCreate(wallet) { return this.call(actions.ACCOUNT_CREATE, { wallet }); }, @@ -50,23 +60,10 @@ export default Service.extend({ return info; }, - walletBalanceTotal(wallet) { - return this.call(actions.WALLET_BALANCE_TOTAL, { wallet }); - }, - accountList(wallet) { return this.call(actions.ACCOUNT_LIST, { wallet }); }, - send(wallet, source, destination, amount) { - return this.call(actions.SEND, { - wallet, - source, - destination, - amount, - }); - }, - async accountHistory(account, count = 1) { const { history } = await this.call(actions.ACCOUNT_HISTORY, { account, @@ -76,18 +73,19 @@ export default Service.extend({ return A(history); }, - async peers() { - const { peers } = await this.call(actions.PEERS); + send(wallet, source, destination, amount) { + return this.call(actions.SEND, { + wallet, + source, + destination, + amount, + }); + }, + async peers() { // When there are no peers, the RPC replies with an empty string. - if (!peers) { - return Object.create(null); - } - - return Object.entries(peers).reduce((acc, [key, value]) => { - acc[key] = parseInt(value, 10); - return acc; - }, Object.create(null)); + const { peers } = await this.call(actions.PEERS); + return peers || {}; }, blockCount() { diff --git a/app/wallet/model.js b/app/wallet/model.js index d15b62d9..1658fbab 100644 --- a/app/wallet/model.js +++ b/app/wallet/model.js @@ -6,4 +6,5 @@ export default DS.Model.extend({ @hasMany('account', { async: true }) accounts: null, @attr('big-number') balance: null, + @attr('big-number') pending: null, }); diff --git a/app/wallets/route.js b/app/wallets/route.js index 6c74252a..cf32ff8e 100644 --- a/app/wallets/route.js +++ b/app/wallets/route.js @@ -1,4 +1,13 @@ import Route from '@ember/routing/route'; +import { service } from 'ember-decorators/service'; + export default Route.extend({ + @service settings: null, + + async afterModel(model) { + const settings = this.get('settings'); + const serialized = this.store.serialize(model, { includeId: true }); + settings.setProperties(serialized); + }, });