Skip to content

Commit

Permalink
add enough amount check when send via file
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojay committed Jul 4, 2019
1 parent 8bc8796 commit ec3cee5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ const messages = {
createTxFile: 'Create new transcation file',
WrongAmount: 'Wrong amount',
saveMsg: 'Save transcation file created',
CreateFailed: 'Failed to create new transcation file'
CreateFailed: 'Failed to create new transcation file',
NotEnough: 'Not enough amount. Keep 0.01 as fee'
},

httpSend:{
Expand Down
3 changes: 2 additions & 1 deletion src/lang/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ const messages = {
createTxFile: 'Создать новый файл транзакции',
WrongAmount: 'Неверная сумма',
saveMsg: 'Сохранить созданный файл транзакции',
CreateFailed: 'Не удалось создать новый файл транзакции'
CreateFailed: 'Не удалось создать новый файл транзакции',
NotEnough: 'Недостаточно средств. Оставьте 0.01 для комиссии'
},

httpSend:{
Expand Down
3 changes: 2 additions & 1 deletion src/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ const messages = {
createTxFile: '生成交易文件',
WrongAmount: '发送数量错误',
saveMsg: '保存新生成的交易文件',
CreateFailed: '生成交易文件错误'
CreateFailed: '生成交易文件错误',
NotEnough: '没有足够的余额,请至少留下0.01作为手续费',
},

httpSend:{
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/components/FileSend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,20 @@ export default {
if (!this.amount || !this.validAmount(this.amount)) {
this.errors.push(this.$t('msg.fileSend.WrongAmount'));
}
if (this.amount && this.validAmount(this.amount) && !this.enough(this.amount)) {
this.errors.push(this.$t('msg.fileSend.NotEnough'));
}
if (!this.errors.length) {
return true;
}
},
enough(amount){
let spendable = this.$dbService.getSpendable()
if(spendable){
return spendable >= parseFloat(amount) + 0.01 //0.008
}
return true
},
send(){
if(this.checkForm()){
let fn_output = this.$electron.remote.dialog.showSaveDialog({
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/HttpSend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
enough(amount){
let spendable = this.$dbService.getSpendable()
if(spendable){
return spendable > parseFloat(amount) + 0.01 //0.008
return spendable >= parseFloat(amount) + 0.01 //0.008
}
return true
},
Expand All @@ -113,7 +113,7 @@ export default {
if (!this.amount || !this.validAmount(this.amount)) {
this.errors.push(this.$t('msg.httpSend.WrongAmount'));
}
if (this.validAmount(this.amount) && !this.enough(this.amount)) {
if (this.amount && this.validAmount(this.amount) && !this.enough(this.amount)) {
this.errors.push(this.$t('msg.httpSend.NotEnough'));
}
if (!this.errors.length) {
Expand Down

0 comments on commit ec3cee5

Please sign in to comment.