<tbody>
<tr class="row">
<td class="col label">{{ $t('transfer.from') }}</td>
- <td class="col value">{{account.alias}}</td>
+ <td class="col value">{{currentAccount.alias}}</td>
</tr>
<div class="divider"></div>
<tr class="row">
<td class="col label">Output</td>
<td class="col value" v-bind:class="{ hide: !full }" >{{transaction.output}}</td>
</tr>
- <tr class="row">
+ <tr v-if="transaction.args" class="row">
<td class="col label">Args</td>
<td class="col value" v-bind:class="{ hide: !full }" >{{transaction.args}}</td>
</tr>
<tr class="row">
<td colspan="2" class="center-text">
<a v-on:click="full = !full" class="view-link">
- {{ full? $t('transfer.hide'): $t('transfer.view') }} >>
+ {{ full? $t('transfer.hideAll'): $t('transfer.viewAll') }} >>
</a>
</td>
</tr>
<div class="divider"></div>
+ <tr v-for="(amountInput, index) in transaction.amounts" :key="index" class="row">
+ <td class="col label">{{index ==0 && $t('transfer.transferAmount') }}</td>
+ <td class="col value">{{amountInput.amount}}<span class="uint uppercase">{{amountInput.alias || amountInput.asset}}</span></td>
+ </tr>
+
<tr class="row">
<td class="col label">{{ $t('transfer.fee') }}</td>
<td class="col value">{{transaction.fee}}<span class="uint">BTM</span></td>
</tr>
+
</tbody>
</table>
</section>
import transaction from "@/models/transaction";
import getLang from "@/assets/language/sdk";
import { LocalStream } from 'extension-streams';
+import {apis} from '@/utils/BrowserApis';
+import NotificationService from '../../services/NotificationService'
+import { mapActions, mapGetters, mapState } from 'vuex'
+import _ from 'lodash';
+import account from "@/models/account";
+import { Number as Num } from "@/utils/Number"
+
+
export default {
data() {
return {
full: false,
- // full2: false,
- account: {},
transaction: {
input: "",
output: "",
args: "",
fee: "",
- confirmations:"",
+ confirmations:1,
amounts: []
},
- password:''
+ password:'',
+ prompt:''
};
},
computed: {
+ ...mapGetters([
+ 'currentAccount',
+ 'net',
+ 'netType',
+ ])
},
watch: {
},
methods: {
close: function () {
- window.close();
+ NotificationService.close();
},
transfer: function () {
let loader = this.$loading.show({
onCancel: this.onCancel
});
- transaction.buildTransaction(this.account.guid, this.transaction.input, this.transaction.output, this.transaction.fee * 1000000000, this.transaction.confirmations).then(ret => {
- return transaction.convertArgument(this.transaction.args)
- .then((arrayData) =>{
- return transaction.advancedTransfer(this.account.guid, ret.result.data, this.password, arrayData)
- .then((resp) => {
- loader.hide();
- LocalStream.send({method:'advanced-transfer',action:'success', message:resp});
- this.$dialog.show({
- type: 'success',
- body: this.$t("transfer.success")
- });
- window.close();
- })
- .catch(error => {
- throw error
- });
- })
+ transaction.buildTransaction(this.currentAccount.guid, this.transaction.input, this.transaction.output, this.transaction.fee , this.transaction.confirmations).then(async (result) => {
+
+ let arrayData
+ if(this.transaction.args){
+ arrayData = await transaction.convertArgument(this.transaction.args)
+ }
+
+ return transaction.advancedTransfer(this.currentAccount.guid, result, this.password, arrayData)
+ .then((resp) => {
+ loader.hide();
+ this.prompt.responder(resp);
+ this.$dialog.show({
+ type: 'success',
+ body: this.$t("transfer.success")
+ });
+ NotificationService.close();
+ })
.catch(error => {
- throw error
+ throw error
});
}).catch(error => {
loader.hide();
body: getLang(error.message)
});
});
- }
+ },
+ queryAsset: function(assetID){
+ return transaction.asset(assetID)
+ }
}, mounted() {
- this.account = JSON.parse(localStorage.currentAccount);
+ this.prompt = window.data || apis.extension.getBackgroundPage().notification || null;
- if(this.$route.query.object !== undefined){
- const inout = JSON.parse(this.$route.query.object)
+ if(this.prompt.data !== undefined){
+ const inout = this.prompt.data
if(inout.input !== undefined){
this.transaction.input = inout.input
}
this.transaction.args = inout.args
}
if(inout.gas !== undefined){
- this.transaction.fee = inout.gas/1000000000
+ this.transaction.fee = inout.gas
}
if(inout.confirmations !== undefined){
this.transaction.confirmations = inout.confirmations
}
const array = inout.input.filter(action => action.type ==='spend_wallet')
- this.transaction.amounts = array
+
+ if(array.length>0){
+ account.setupNet(`${this.net}${this.netType}`)
+ const promise =
+ _(array)
+ .groupBy('asset')
+ .map((objs, key) => {
+ return this.queryAsset(key).then(resp =>{
+ return {
+ 'asset': key,
+ 'alias':resp.alias,
+ 'amount':Num.formatNue( _.sumBy(objs, 'amount'), resp.decimals)
+ }
+ })
+ })
+
+ let that = this;
+ Promise.all(promise).then(function(output) {
+ that.transaction.amounts = output
+ })
+
+ }
+
+
}
}
};