font-size: 14px;
}
+ .address-list {
+ margin-top: 10px;
+ padding-top: 10px;
+ max-height: 125px;
+ overflow-y: auto;
+ font-size: 12px;
+ border-top: solid 1px #eee;
+
+ .item {
+ display: flex;
+ justify-content: space-between;
+ }
+ }
+
.info {
margin-bottom: 20px;
}
v-if="prompt.domain && domainsMeta[prompt.domain] && domainsMeta[prompt.domain].title ">{{domainsMeta[prompt.domain].title }}</span>
<span class="color-black" v-else-if="prompt.domain ">{{prompt.domain }}</span>
- <div v-if="transaction.to">{{short(transaction.to)}}</div>
+ <!-- <div v-if="transaction.to">{{short(transaction.to)}}</div> -->
+ <div v-if="transaction.to && typeof transaction.to === 'string'">{{short(transaction.to)}}</div>
</div>
</div>
</div>
<!--amounts-->
<div v-if="prompt.data && prompt.data.type ==='transfer'" class="amount-list">
<div>{{ $t('transfer.amount') }}</div>
- <div class="color-black font-bold">{{transaction.amount}}<span class="uint uppercase">{{unit || short(transaction.asset) }}</span>
+ <div class="color-black font-bold">
+ <span>{{transaction.amount}}</span>
+ <span class="uint uppercase">{{unit || short(transaction.asset) }}</span>
</div>
</div>
<div v-else v-for="(amountInput, index) in transaction.amounts" :key="index" class="amount-list">
- <div>{{index ==0 && $t('transfer.amount') }}</div>
+ <div>{{ index ==0 ? $t('transfer.amount'):'' }}</div>
<div class="color-black font-bold">{{amountInput.amount}}<span class="uint uppercase">{{amountInput.alias || short(amountInput.asset) }}</span>
</div>
</div>
<div class="color-black font-bold">{{transaction.fee}}<span class="uint">BTM</span></div>
</div>
+ <!-- multi address -->
+ <div
+ v-if="prompt.data && prompt.data.type ==='transfer' && transaction.to && typeof transaction.to === 'object'"
+ class="address-list"
+ >
+ <div v-for="(amount, address) in transaction.to" :key="address" class="item">
+ <span>{{ short(address) }}</span>
+ <span>{{ amount }} {{ unit || short(transaction.asset) }}</span>
+ </div>
+ </div>
+
</div>
<div v-if="tab ==='inout'" class="content content-black">
<pre>{{detail}}</pre>
import account from "@/models/account";
import add from "@/utils/address";
import { camelize, removeFromArray } from "@/utils/utils";
- import bytomjslib from 'bytomjs-lib'
-
+ // import bytomjslib from 'bytomjs-lib'
+ import BigNumber from "bignumber.js"
export default {
add,
},
currentWallet(){
if(this.prompt.data && this.prompt.data.type ==='transfer'){
- return this.bytom.keychain.findByAddress(this.transaction.from);
+ return this.bytom.keychain.findByAddress(this.transaction.from, this.net);
}else if(this.prompt.data && this.prompt.data.type ==='message'){
- return this.bytom.keychain.findByAddress(this.transaction.address);
+ return this.bytom.keychain.findByAddress(this.transaction.address, this.net);
}else{
return this.currentAccount
}
}).catch(error => {
loader.hide();
- this.$toast.error(
- getLang(error.message) || error.message || error
- );
+ let e = error
+ if (error.code){
+ e = this.$t(`error.${error.code}`)
+ }else if(error.message){
+ e = getLang(error.message)
+ }
+ this.$toast.error(e);
});
} else if(this.prompt.data.type ==='transfer'){
transaction.transfer(this.transaction, this.password, this.address, this).then(result => {
}).catch(error => {
loader.hide();
- this.$toast.error(
- getLang(error.message) || error.message || error
- );
+ let e = error
+ if (error.code){
+ e = this.$t(`error.${error.code}`)
+ }else if(error.message){
+ e = getLang(error.message)
+ }
+ this.$toast.error(e);
});
} else if(this.prompt.data.type ==='signTransaction'){
const data = this.prompt.data.value
}).catch(error => {
loader.hide();
- this.$toast.error(
- getLang(error.message) || error.message || error
- );
+ let e = error
+ if (error.code){
+ e = this.$t(`error.${error.code}`)
+ }else if(error.message){
+ e = getLang(error.message)
+ }
+ this.$toast.error(e);
});
}
}).catch(error => {
loader.hide();
- this.$toast.error( getLang(error.message));
+ let e = error
+ if (error.code){
+ e = this.$t(`error.${error.code}`)
+ }else if(error.message){
+ e = getLang(error.message)
+ }
+ this.$toast.error(e);
});
}
else{
}
}, mounted() {
this.prompt = window.data || apis.extension.getBackgroundPage().notification || null;
+ console.log('mounted')
console.log(this.prompt)
const params = this.prompt.data
})
let that = this;
- Promise.all(promise).then(function (output) {
- that.transaction.amounts = output
+ Promise.all(promise).then((output) => {
+ this.transaction.amounts = output
this.dataReady = true
}).catch(()=>{
this.dataReady = true
})
+ } else {
+ this.dataReady = true
}
break;
}
if (data.asset != undefined) {
this.transaction.asset= data.asset
}
- if (data.to != undefined) {
- this.transaction.to = data.to
- }
if (data.amount != undefined) {
this.transaction.amount = data.amount
}
-
+ if (data.to != undefined) {
+ this.transaction.to = data.to
+ // multi toAddress
+ if (typeof data.to === 'object') {
+ const amount = Object.values(data.to).reduce((a, b) => +a + +b, 0)
+ this.transaction.amount = amount
+ }
+ }
if(data.confirmations != undefined) {
this.transaction.confirmations = data.confirmations
}
- const asset_amounts ={}
- asset_amounts[data.asset] = data.amount
+ let asset_amounts = {
+ [data.asset]: this.transaction.amount.toString()
+ }
transaction.estimateFee( data.from, asset_amounts).then( (resp) =>{
this.transaction.fee = resp.fee
throw e
})
- }).catch(()=>{
+ }).catch((e)=>{
this.dataReady = true
})
+
break;
}
case "signTransaction":{
const _tx = camelize(param)
const rawTransaction = _tx.rawTransaction
- const tx = this.netType === 'vapor'?
- bytomjslib.vapor.Transaction.decodeRawTransaction(rawTransaction):
- bytomjslib.bytom.Transaction.decodeRawTransaction(rawTransaction)
-
+ // const tx = this.netType === 'vapor'?
+ // bytomjslib.vapor.Transaction.decodeRawTransaction(rawTransaction):
+ // bytomjslib.bytom.Transaction.decodeRawTransaction(rawTransaction)
+ const tx = _tx.tx
this.transaction.fee = tx.fee/100000000
this.transaction.input = tx.inputs
this.transaction.output = tx.outputs
const outputAsset = outputs.map(i => i.assetID);
const asset = _.union(inputAsset, outputAsset)
+ let that = this;
- let types = ["transfer"]
+ let types = ["transfer", "vote"]
const promise =
asset
.map((assetId) => {
const inputAmount = new BigNumber(_.sumBy(assetInput, 'amount'))
const outputAmount = new BigNumber(_.sumBy(assetOutput, 'amount'))
- const decimals = decimalsMap[this.net][assetId]
- const amount = inputAmount.minus(outputAmount).shiftedBy(-decimals)
+ const decimals = resp.decimals
+ const amount = inputAmount.minus(outputAmount)
+
+ const balanced_outputs = tx.outputs.find( o => o.amount === amount.toNumber())
+ if(balanced_outputs.type == 'cross_chain_out'){
+ that.transaction.types = (that.$t('common.cross_chain'));
+ }
return {
'asset': assetId,
'alias': resp.symbol,
- 'amount': amount.toString()
+ 'amount': amount.shiftedBy(-decimals).toString()
}
})
})
- let that = this;
const inputType = inputs.map(i => i.type);
const outputType = outputs.map(o => o.type);
types = _.union(inputType, outputType, types);
const remove = ['spend','control'];
+ if(inputs[0] && outputs[0] && inputs[0].amount && outputs[0].amount ){
+ const inAmount = new BigNumber(_.sumBy(inputs, 'amount'))
+ const outAmount = new BigNumber(_.sumBy(outputs, 'amount'))
+
+ if(inAmount.eq(outAmount)){
+ const isVeto = inputs.find(o => o.type ==='veto')
+ const isVote = outputs.find(o => o.type ==='vote')
+ if(isVeto || isVote){
+ remove.push('transfer')
+ }
+ }
+ }
types = removeFromArray(types, remove);
types = types.map(ty => this.$t(`common.${ty}`)).join(', ');
- this.transaction.types = types
+ // this.transaction.types = types
+ this.transaction.types = tx.types.map(ty => this.$t(`common.${ty}`)).join(', ');
Promise.all(promise).then(function(output) {
that.transaction.amounts = output
that.dataReady = true
})
-
break
}
case "message":{