OSDN Git Service

update the radio limits.
authorZhiting Lin <zlin035@uottawa.ca>
Tue, 5 Mar 2019 06:22:30 +0000 (14:22 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Tue, 5 Mar 2019 06:22:30 +0000 (14:22 +0800)
src/components/constants.js
src/components/layout/profit/action.js
src/components/layout/save/action.js

index 3755c04..0823b8d 100644 (file)
@@ -1,4 +1,5 @@
 import config from 'config';
+import BigNumber from "bignumber.js/bignumber";
 
 let depositProgram
 let profitProgram
@@ -10,6 +11,7 @@ let dueBlockHeight
 let expireBlockHeight
 let banker
 let gas
+let radio
 
 const GetContractArgs = function() {
   if(window.bytom && window.bytom.defaultAccount && window.bytom.defaultAccount.net){
@@ -27,6 +29,7 @@ const GetContractArgs = function() {
       expireBlockHeight = object.expireBlockHeight
       banker = object.banker
       gas = object.gas
+      radio =BigNumber(object.totalAmountCapital).div(object.totalAmountBill).toNumber()
     }
   }
 
@@ -40,7 +43,8 @@ const GetContractArgs = function() {
       dueBlockHeight,
       expireBlockHeight,
       banker,
-      gas
+      gas,
+      radio
     };
 }
 
index 50305f7..be49302 100644 (file)
@@ -18,9 +18,11 @@ export function FixedLimitProfit(account, amountBill, saver) {
     }).then(resp => {
       if(resp.length === 0) {
         throw 'Empty UTXO info, it might be that the utxo is locked. Please retry after 60s.'
+      }else if(amountBill < 100000000){
+        throw 'Please enter an amount bigger or equal than 100000000.'
       }
 
-      const radio = BigNumber( GetContractArgs().totalAmountCapital).div(GetContractArgs().totalAmountBill)
+      const radio = BigNumber( GetContractArgs().radio )
       const matchesAmount = radio.multipliedBy(amountBill).toNumber()
 
       const result = matchesUTXO(resp, matchesAmount)
index 2f9c0b5..1a3753b 100644 (file)
@@ -17,8 +17,11 @@ export function FixedLimitDeposit(account, amount, address) {
         "order":"desc"
       }
     }).then(resp => {
+      const limit =  GetContractArgs().radio * 100000000
       if(resp.length === 0) {
         throw 'Empty UTXO info, it might be that the utxo is locked. Please retry after 60s.'
+      }else if(amount < limit){
+        throw `Please enter an amount bigger or equal than ${limit}.`
       }
 
       const result = matchesUTXO(resp, amount)