OSDN Git Service

add the convertArguement for the chrome extenstion
authorZhiting Lin <zlin035@uottawa.ca>
Fri, 15 Feb 2019 02:30:16 +0000 (10:30 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Fri, 15 Feb 2019 02:30:16 +0000 (10:30 +0800)
src/dapp.js
src/models/transaction.js
src/views/advancedTransfer.vue

index 464c11a..e14eb62 100644 (file)
@@ -88,12 +88,13 @@ export default class Bytomdapp {
     })
   }
 
-  advancedTransfer(account, input, output, gas) {
+  advancedTransfer(account, input, output, gas, args) {
     return _send(MsgTypes.ADVTRANSFER, {
       account,
       input,
       output,
-      gas
+      gas,
+      args
     })
   }
 
index d75786b..a60b513 100644 (file)
@@ -6,6 +6,19 @@ transaction.list = function(guid, address, start, limit) {
   return bytom.transaction.list(guid, address, start, limit);
 };
 
+transaction.convertArgument = function(argArray) {
+  let fn = function asyncConvert(object){
+    const type = object.type
+    const value = object.value
+    return bytom.transaction.convertArgument(type, value)
+      .then(resp => resp.value);
+  };
+
+  let actionFunction = argArray.map(fn)
+  console.log(actionFunction)
+  return Promise.all(actionFunction);
+};
+
 transaction.blockCount = function() {
   return bytom.query.getblockcount();
 };
index 5eab6a7..53904ce 100644 (file)
@@ -139,16 +139,21 @@ export default {
             const inout = JSON.parse(this.$route.query.object)
 
             transaction.buildTransaction(this.account.guid,  inout.input, inout.output, inout.gas).then(ret => {
-                const arrayData = ret.result.data.signing_instructions[0].data
-                return transaction.advancedTransfer(this.account.guid, ret.result.data, passwd, arrayData)
-                  .then((resp) => {
-                    loader.hide();
-                    LocalStream.send({method:'advanced-transfer',action:'success', message:resp});
-                    this.$dialog.show({
-                      body: this.$t("transfer.success")
-                    });
-                    this.$router.push('/');
-                  })
+                return transaction.convertArgument(inout.args)
+                    .then((arrayData) =>{
+                        return transaction.advancedTransfer(this.account.guid, ret.result.data, passwd, arrayData)
+                            .then((resp) => {
+                                loader.hide();
+                                LocalStream.send({method:'advanced-transfer',action:'success', message:resp});
+                                this.$dialog.show({
+                                    body: this.$t("transfer.success")
+                                });
+                                this.$router.push('/');
+                            })
+                            .catch(error => {
+                                 throw error
+                            });
+                     })
                   .catch(error => {
                     throw error
                   });