• R/O
  • HTTP
  • SSH
  • HTTPS

Byone: Commit

Bytom Wallet for Chrome


Commit MetaInfo

Révisionff52d96d1b46daba97209f71ce0e316ce20e6711 (tree)
l'heure2019-09-20 14:41:16
AuteurZhiting Lin <zlin035@uott...>
CommiterZhiting Lin

Message de Log

update available balance

Change Summary

Modification

--- a/src/background.js
+++ b/src/background.js
@@ -6,7 +6,9 @@ import StorageService from './services/StorageService'
66 import Prompt from './prompts/Prompt';
77 import * as PromptTypes from './prompts/PromptTypes'
88
9+import _ from 'lodash'
910 import Error from './utils/errors/Error'
11+import { BTM } from './utils/constants'
1012
1113 let prompt = null;
1214
@@ -179,20 +181,35 @@ export default class Background {
179181 const currentAccount = bytom.currentAccount
180182 let account
181183 if(bytom.settings.netType === 'vapor'){
184+ let vote
185+ const votes = currentAccount.votes
186+ if(votes && votes.length >0 ){
187+ vote = _.sumBy(votes,'total')
188+ }
189+
190+ let balances = currentAccount.vpBalances ||[]
191+ balances = balances.map(({ in_btc, in_cny, in_usd, name, ...keepAttrs}) => {
192+ if(keepAttrs.asset === BTM)
193+ return {availableBalance: (keepAttrs.balance-vote),...keepAttrs}
194+ else
195+ return keepAttrs
196+ })
197+
182198 account = {
183199 address: currentAccount.vpAddress,
184200 alias:currentAccount.alias,
185- balances: currentAccount.vpBalances|| [],
201+ balances: balances|| [],
186202 accountId: currentAccount.guid,
187203 rootXPub: currentAccount.rootXPub
188204 };
189205 }else{
190206 let balances = currentAccount.balances ||[]
207+ balances = balances.map(({ in_btc, in_cny, in_usd, name, ...keepAttrs}) => keepAttrs)
191208
192209 account ={
193210 address: currentAccount.address,
194211 alias:currentAccount.alias,
195- balances: currentAccount.balances|| [],
212+ balances: balances|| [],
196213 accountId: currentAccount.guid,
197214 rootXPub: currentAccount.rootXPub
198215 };
@@ -269,22 +286,36 @@ export default class Background {
269286
270287 let account
271288 if(bytom.settings.netType === 'vapor'){
272- let balances = currentAccount.vpBalances ||[]
289+ let vote = 0
290+ const votes = currentAccount.votes
291+ if(votes && votes.length >0 ){
292+ vote = _.sumBy(votes,'total')
293+ }
273294
295+ let balances = currentAccount.vpBalances ||[]
296+ balances = balances.map(({ in_btc, in_cny, in_usd, name, ...keepAttrs}) => {
297+ if(keepAttrs.asset === BTM)
298+ return {availableBalance: (keepAttrs.balance-vote),...keepAttrs}
299+ else
300+ return keepAttrs
301+ })
274302
275303 account ={
276304 address: currentAccount.vpAddress,
277305 alias:currentAccount.alias,
278- balances: currentAccount.vpBalances || [],
306+ balances: balances || [],
279307 accountId: currentAccount.guid,
280308 rootXPub: currentAccount.rootXPub
281309 };
282310
283311 }else{
312+ let balances = currentAccount.balances ||[]
313+ balances = balances.map(({ in_btc, in_cny, in_usd, name, ...keepAttrs}) => keepAttrs)
314+
284315 account ={
285316 address: currentAccount.address,
286317 alias:currentAccount.alias,
287- balances: currentAccount.balances|| [],
318+ balances: balances|| [],
288319 accountId: currentAccount.guid,
289320 rootXPub: currentAccount.rootXPub
290321 };
Afficher sur ancien navigateur de dépôt.