A simple deposit and profit bytom dapp demo
修订版 | d3ec98132bb8fcdf59ce353a551adce71280d44f (tree) |
---|---|
时间 | 2019-03-05 15:22:30 |
作者 | Zhiting Lin <zlin035@uott...> |
Commiter | Zhiting Lin |
update the radio limits.
@@ -1,4 +1,5 @@ | ||
1 | 1 | import config from 'config'; |
2 | +import BigNumber from "bignumber.js/bignumber"; | |
2 | 3 | |
3 | 4 | let depositProgram |
4 | 5 | let profitProgram |
@@ -10,6 +11,7 @@ let dueBlockHeight | ||
10 | 11 | let expireBlockHeight |
11 | 12 | let banker |
12 | 13 | let gas |
14 | +let radio | |
13 | 15 | |
14 | 16 | const GetContractArgs = function() { |
15 | 17 | if(window.bytom && window.bytom.defaultAccount && window.bytom.defaultAccount.net){ |
@@ -27,6 +29,7 @@ const GetContractArgs = function() { | ||
27 | 29 | expireBlockHeight = object.expireBlockHeight |
28 | 30 | banker = object.banker |
29 | 31 | gas = object.gas |
32 | + radio =BigNumber(object.totalAmountCapital).div(object.totalAmountBill).toNumber() | |
30 | 33 | } |
31 | 34 | } |
32 | 35 |
@@ -40,7 +43,8 @@ const GetContractArgs = function() { | ||
40 | 43 | dueBlockHeight, |
41 | 44 | expireBlockHeight, |
42 | 45 | banker, |
43 | - gas | |
46 | + gas, | |
47 | + radio | |
44 | 48 | }; |
45 | 49 | } |
46 | 50 |
@@ -18,9 +18,11 @@ export function FixedLimitProfit(account, amountBill, saver) { | ||
18 | 18 | }).then(resp => { |
19 | 19 | if(resp.length === 0) { |
20 | 20 | throw 'Empty UTXO info, it might be that the utxo is locked. Please retry after 60s.' |
21 | + }else if(amountBill < 100000000){ | |
22 | + throw 'Please enter an amount bigger or equal than 100000000.' | |
21 | 23 | } |
22 | 24 | |
23 | - const radio = BigNumber( GetContractArgs().totalAmountCapital).div(GetContractArgs().totalAmountBill) | |
25 | + const radio = BigNumber( GetContractArgs().radio ) | |
24 | 26 | const matchesAmount = radio.multipliedBy(amountBill).toNumber() |
25 | 27 | |
26 | 28 | const result = matchesUTXO(resp, matchesAmount) |
@@ -17,8 +17,11 @@ export function FixedLimitDeposit(account, amount, address) { | ||
17 | 17 | "order":"desc" |
18 | 18 | } |
19 | 19 | }).then(resp => { |
20 | + const limit = GetContractArgs().radio * 100000000 | |
20 | 21 | if(resp.length === 0) { |
21 | 22 | throw 'Empty UTXO info, it might be that the utxo is locked. Please retry after 60s.' |
23 | + }else if(amount < limit){ | |
24 | + throw `Please enter an amount bigger or equal than ${limit}.` | |
22 | 25 | } |
23 | 26 | |
24 | 27 | const result = matchesUTXO(resp, amount) |