39 word-break: break-all;
63 text-overflow: ellipsis;
75 <div class="warp bg-gray">
76 <section class="header bg-header">
77 <i class="iconfont icon-back" @click="close"></i>
78 <p>{{ $t('transfer.confirmTransaction') }}</p>
81 <section class="content bg-white">
85 <td class="col label">{{ $t('transfer.from') }}</td>
86 <td class="col value">{{currentAccount.alias}}</td>
88 <div class="divider"></div>
90 <td class="col label">Input</td>
91 <td class="col value" v-bind:class="{ hide: !full }" >{{transaction.input}}</td>
94 <td class="col label">Output</td>
95 <td class="col value" v-bind:class="{ hide: !full }" >{{transaction.output}}</td>
97 <tr v-if="transaction.args" class="row">
98 <td class="col label">Args</td>
99 <td class="col value" v-bind:class="{ hide: !full }" >{{transaction.args}}</td>
102 <td colspan="2" class="center-text">
103 <a v-on:click="full = !full" class="view-link">
104 {{ full? $t('transfer.hideAll'): $t('transfer.viewAll') }} >>
109 <div class="divider"></div>
111 <td class="col label">{{ $t('transfer.types') }}</td>
112 <td class="col value">{{transaction.types}}</td>
115 <tr v-for="(amountInput, index) in transaction.amounts" :key="index" class="row">
116 <td class="col label">{{index ==0 && $t('transfer.transferAmount') }}</td>
117 <td class="col value">{{amountInput.amount}}<span class="uint uppercase">{{amountInput.alias || amountInput.asset}}</span></td>
121 <td class="col label">{{ $t('transfer.fee') }}</td>
122 <td class="col value">{{transaction.fee}}<span class="uint">BTM</span></td>
128 <section class="content bg-white">
130 <div class="form-item">
131 <label class="form-item-label">{{ $t('transfer.confirmPassword') }}</label>
132 <div class="form-item-content">
133 <input type="password" v-model="password" autofocus>
139 <div class="row" style="margin: 20px;">
140 <div class="btn bg-green" @click="transfer">{{ $t('transfer.confirm') }}</div>
147 import transaction from "@/models/transaction";
148 import getLang from "@/assets/language/sdk";
149 import {apis} from '@/utils/BrowserApis';
150 import NotificationService from '../../services/NotificationService'
151 import { mapActions, mapGetters, mapState } from 'vuex'
152 import _ from 'lodash';
153 import account from "@/models/account";
154 import { camelize, removeFromArray } from "@/utils/utils";
155 import { decimalsMap } from "@/utils/constants"
156 import BigNumber from "bignumber.js"
157 // import bytomjslib from 'bytomjs-lib'
191 NotificationService.close();
193 transfer: function () {
194 let loader = this.$loading.show({
195 // Optional parameters
198 onCancel: this.onCancel
201 if(Array.isArray(this.prompt.data)){
202 Promise.all(this.prompt.data.map( (rawdata) => transaction.signTransaction(this.currentAccount.guid, rawdata, this.password, this)))
205 this.prompt.responder(result);
208 body: this.$t("transfer.success")
210 NotificationService.close();
215 body: getLang(error.message)
219 transaction.signTransaction(this.currentAccount.guid, this.prompt.data, this.password, this).then( (result) => {
221 this.prompt.responder(result);
224 body: this.$t("transfer.success")
226 NotificationService.close();
231 body: getLang(error.message)
237 queryAsset: function(assetID){
238 return transaction.asset(assetID)
241 this.prompt = window.data || apis.extension.getBackgroundPage().notification || null;
242 if(this.prompt.data !== undefined){
243 const param = Array.isArray(this.prompt.data)? this.prompt.data[0] : this.prompt.data
244 const _tx = camelize(param)
245 const rawTransaction = _tx.rawTransaction
246 const currentAddress = this.netType === 'vapor'?
247 this.currentAccount.vpAddress:
248 this.currentAccount.address
250 account.setupNet(`${this.net}${this.netType}`)
252 // const tx = this.netType === 'vapor'?
253 // bytomjslib.vapor.Transaction.decodeRawTransaction(rawTransaction):
254 // bytomjslib.bytom.Transaction.decodeRawTransaction(rawTransaction)
255 this.transaction.fee = tx.fee/100000000
256 this.transaction.input = tx.inputs
257 this.transaction.output = tx.outputs
259 const inputs = tx.inputs.filter(i => i.address === currentAddress)
260 const outputs = tx.outputs.filter(i => i.address === currentAddress)
261 const inputAsset = inputs.map(i => i.assetID);
262 const outputAsset = outputs.map(i => i.assetID);
264 const asset = _.union(inputAsset, outputAsset)
266 let types = ["transfer"]
270 return this.queryAsset(assetId).then(resp =>{
271 const assetInput = inputs.filter(i => i.assetID ===assetId)
272 const assetOutput = outputs.filter(o => o.assetID ===assetId)
273 const inputAmount = new BigNumber(_.sumBy(assetInput, 'amount'))
274 const outputAmount = new BigNumber(_.sumBy(assetOutput, 'amount'))
276 const decimals = decimalsMap[this.net][assetId]
277 const amount = inputAmount.minus(outputAmount).shiftedBy(-decimals)
281 'alias': resp.symbol,
282 'amount': amount.toString()
288 Promise.all(promise).then(function(output) {
289 that.transaction.amounts = output
292 const inputType = inputs.map(i => i.type);
293 const outputType = outputs.map(o => o.type);
294 types = _.union(inputType, outputType, types);
296 const remove = ['spend','control'];
297 types = removeFromArray(types, remove);
298 types = types.map(ty => this.$t(`common.${ty}`)).join(', ');
300 this.transaction.types = types