const domain = payload.domain;
const currentAccount = bytom.currentAccount
- let account
- if(bytom.settings.netType === 'vapor'){
- let vote = 0
- const votes = currentAccount.votes
- if(votes && votes.length >0 ){
- vote = _.sumBy(votes,'total')
- }
+ if(!currentAccount){
+ sendResponse(Error.signatureAccountMissing())
+ }else{
+ let account
+ if(bytom.settings.netType === 'vapor'){
+ let vote = 0
+ const votes = currentAccount.votes
+ if(votes && votes.length >0 ){
+ vote = _.sumBy(votes,'total')
+ }
- let balances = currentAccount.vpBalances ||[]
- balances = balances.map(({ inBtc, inCny, inUsd, name, ...keepAttrs}) => {
- if(keepAttrs.asset === BTM)
- return {availableBalance: (keepAttrs.balance-vote),...keepAttrs}
- else
- return keepAttrs
- })
+ let balances = currentAccount.vpBalances ||[]
+ balances = balances.map(({ inBtc, inCny, inUsd, name, ...keepAttrs}) => {
+ if(keepAttrs.asset === BTM)
+ return {availableBalance: (keepAttrs.balance-vote),...keepAttrs}
+ else
+ return keepAttrs
+ })
- account ={
- address: currentAccount.vpAddress,
- alias:currentAccount.alias,
- balances: balances || [],
- accountId: currentAccount.guid,
- rootXPub: currentAccount.rootXPub
- };
+ account ={
+ address: currentAccount.vpAddress,
+ alias:currentAccount.alias,
+ balances: balances || [],
+ accountId: currentAccount.guid,
+ rootXPub: currentAccount.rootXPub
+ };
- }else{
- let balances = currentAccount.balances ||[]
- balances = balances.map(({ inBtc, inCny, inUsd, name, ...keepAttrs}) => keepAttrs)
-
- account ={
- address: currentAccount.address,
- alias:currentAccount.alias,
- balances: balances|| [],
- accountId: currentAccount.guid,
- rootXPub: currentAccount.rootXPub
- };
- }
+ }else{
+ let balances = currentAccount.balances ||[]
+ balances = balances.map(({ inBtc, inCny, inUsd, name, ...keepAttrs}) => keepAttrs)
- if(bytom.settings.domains.find(_domain => _domain === domain)) {
- sendResponse(account);
- } else{
- NotificationService.open(new Prompt(PromptTypes.REQUEST_AUTH, payload.domain, {}, approved => {
- if(approved === false || approved.hasOwnProperty('isError')) sendResponse(approved);
- else {
- bytom.settings.domains.unshift(domain);
- if(approved === true){
- this.update(() => sendResponse(account), bytom);
- }else{
- this.update(() => sendResponse(approved), bytom);
+ account ={
+ address: currentAccount.address,
+ alias:currentAccount.alias,
+ balances: balances|| [],
+ accountId: currentAccount.guid,
+ rootXPub: currentAccount.rootXPub
+ };
+ }
+
+ if(bytom.settings.domains.find(_domain => _domain === domain)) {
+ sendResponse(account);
+ } else{
+ NotificationService.open(new Prompt(PromptTypes.REQUEST_AUTH, payload.domain, {}, approved => {
+ if(approved === false || approved.hasOwnProperty('isError')) sendResponse(approved);
+ else {
+ bytom.settings.domains.unshift(domain);
+ if(approved === true){
+ this.update(() => sendResponse(account), bytom);
+ }else{
+ this.update(() => sendResponse(approved), bytom);
+ }
}
- }
- }));
+ }));
+ }
}
})
}