OSDN Git Service

bapp throw an error if account not exist
authorZhiting Lin <zlin035@uottawa.ca>
Wed, 5 Aug 2020 02:06:48 +0000 (10:06 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Wed, 5 Aug 2020 02:06:48 +0000 (10:06 +0800)
package.json
src/background.js
src/manifest.js
src/utils/errors/Error.js

index 1e77401..dc365db 100644 (file)
@@ -1,7 +1,7 @@
 {
     "name": "Byone",
     "description": "Bytom Chrome Extension Wallet",
-    "version": "2.2.2",
+    "version": "2.2.3",
     "author": "zhiting.fly@8btc.com",
     "license": "MIT",
     "private": true,
index 3528910..81fd277 100644 (file)
@@ -286,57 +286,61 @@ export default class Background {
       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);
+              }
             }
-          }
-        }));
+          }));
+        }
       }
     })
   }
index dd0299d..16657eb 100644 (file)
@@ -2,7 +2,7 @@ module.exports = {
   manifest_version: 2,
   name: 'Byone',
   description: 'Bytom Wallet Chrome extension.',
-  version: '2.2.2',
+  version: '2.2.3',
   author: 'Bytom frontend, zhitinglin',
   web_accessible_resources: ['js/inject.js', 'wasm/main.wasm'],
   browser_action: {
index 063aee5..a604a14 100644 (file)
@@ -49,7 +49,7 @@ export default class Error {
   }
 
   static signatureAccountMissing(){
-    return this.signatureError("account_missing", "Missing required accounts, repull the identity");
+    return this.signatureError("account_missing", "Missing required accounts, please create an account");
   }
 
   static malformedRequiredFields(){