OSDN Git Service

update the sign message for bapp prompt
authorZhiting Lin <zlin035@uottawa.ca>
Thu, 20 Aug 2020 08:35:51 +0000 (16:35 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Thu, 20 Aug 2020 08:35:51 +0000 (16:35 +0800)
src/models/transaction.js
src/views/prompts/bappPrompt.vue

index 5dbcbb6..564e1c8 100644 (file)
@@ -187,8 +187,11 @@ function signSubmit (txObject, password, address, context) {
 };
 
 
-transaction.signMessage = function(message, password, address) {
-  return bytom.keys.signMessage(message, password,address);
+transaction.signMessage = function(message, password, address, context) {
+  const keyArray = context.bytom.keychain.findByAddress(address);
+  const key = JSON.stringify(keyArray.keystore)
+
+  return bytom.keys.signMessage(message, password,key);
 };
 
 transaction.advancedTransfer = function(address, transaction, password, arrayData, context) {
index 8768b03..2508343 100644 (file)
@@ -26,6 +26,7 @@
     border-radius: 8px;
     margin-bottom: 12px;
     font-size: 14px;
+    word-break: break-all;
   }
 
   .content-black{
@@ -79,8 +80,8 @@
     }
 
     .logo {
-      width: 32px;
-      height: 32px;
+      width: 26px;
+      height: 26px;
       -webkit-border-radius: 16px;
       -moz-border-radius: 16px;
       border-radius: 16px;
@@ -91,6 +92,7 @@
       font-size: 16px;
       text-transform: uppercase;
       color: black;
+      padding: 3px;
     }
   }
 
             </div>
           </div>
 
-          <!--types-->
+          <!--transaction types-->
           <div v-if="prompt.data && prompt.data.type ==='signTransaction'" class="amount-list">
             <div >{{ $t('transfer.types') }}</div>
             <div class="color-black font-bold">{{transaction.types}}</div>
           </div>
 
+          <!--sign message-->
+          <div v-if="prompt.data && prompt.data.type ==='message'" class="amount-list">
+            <div style="min-width: 78px;" >{{ $t('signMessage.message') }}</div>
+            <div class="color-black font-bold">{{transaction.message}}</div>
+          </div>
+
           <!--amounts-->
           <div v-if="prompt.data && prompt.data.type ==='transfer'" class="amount-list">
             <div>{{ $t('transfer.amount') }}</div>
       shortAddress: function () {
         if(this.prompt.data && this.prompt.data.type ==='transfer') {
           return add.short(this.transaction.from);
+        }else if(this.prompt.data && this.prompt.data.type ==='message'){
+          return add.short(this.transaction.address);
         }else{
           if (this.netType === 'vapor') {
             return add.short(this.currentAccount.vpAddress);
             signingInstructions
           }
           return JSON.stringify(obj, null, 2);
+        }else if(this.prompt.data && this.prompt.data.type ==='message'){
+          const {confirmations, ...Attr} = this.transaction
+          return JSON.stringify(Attr, null, 2);
         }else{
           return JSON.stringify(this.transaction, null, 2);
         }
       currentWallet(){
         if(this.prompt.data && this.prompt.data.type ==='transfer'){
           return this.bytom.keychain.findByAddress(this.transaction.from);
+        }else if(this.prompt.data && this.prompt.data.type ==='message'){
+          return this.bytom.keychain.findByAddress(this.transaction.address);
         }else{
           return this.currentAccount
         }
               getLang(error.message) || error.message || error
             );
           });
+        } else if(this.prompt.data.type ==='message'){
+          transaction.signMessage(this.transaction.message, this.password, this.address, this).then((resp) => {
+            loader.hide();
+            this.prompt.responder(resp);
+            this.$toast.success(
+              this.$t("transfer.success")
+            );
+            NotificationService.close();
+          }).catch(error => {
+            loader.hide();
+
+            this.$toast.error( getLang(error.message));
+          });
         }
         else{
           loader.hide();
             })
 
 
+            break
+          }
+          case "message":{
+            if(data.address !== undefined){
+              this.transaction.address = data.address;
+            }
+            if(data.message !== undefined){
+              this.transaction.message = data.message
+            }
+
+            this.dataReady = true
 
             break
           }