• R/O
  • HTTP
  • SSH
  • HTTPS

Bytom-Dapp-Demo: 提交

A simple deposit and profit bytom dapp demo


Commit MetaInfo

修订版d3ec98132bb8fcdf59ce353a551adce71280d44f (tree)
时间2019-03-05 15:22:30
作者Zhiting Lin <zlin035@uott...>
CommiterZhiting Lin

Log Message

update the radio limits.

更改概述

差异

--- a/src/components/constants.js
+++ b/src/components/constants.js
@@ -1,4 +1,5 @@
11 import config from 'config';
2+import BigNumber from "bignumber.js/bignumber";
23
34 let depositProgram
45 let profitProgram
@@ -10,6 +11,7 @@ let dueBlockHeight
1011 let expireBlockHeight
1112 let banker
1213 let gas
14+let radio
1315
1416 const GetContractArgs = function() {
1517 if(window.bytom && window.bytom.defaultAccount && window.bytom.defaultAccount.net){
@@ -27,6 +29,7 @@ const GetContractArgs = function() {
2729 expireBlockHeight = object.expireBlockHeight
2830 banker = object.banker
2931 gas = object.gas
32+ radio =BigNumber(object.totalAmountCapital).div(object.totalAmountBill).toNumber()
3033 }
3134 }
3235
@@ -40,7 +43,8 @@ const GetContractArgs = function() {
4043 dueBlockHeight,
4144 expireBlockHeight,
4245 banker,
43- gas
46+ gas,
47+ radio
4448 };
4549 }
4650
--- a/src/components/layout/profit/action.js
+++ b/src/components/layout/profit/action.js
@@ -18,9 +18,11 @@ export function FixedLimitProfit(account, amountBill, saver) {
1818 }).then(resp => {
1919 if(resp.length === 0) {
2020 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.'
2123 }
2224
23- const radio = BigNumber( GetContractArgs().totalAmountCapital).div(GetContractArgs().totalAmountBill)
25+ const radio = BigNumber( GetContractArgs().radio )
2426 const matchesAmount = radio.multipliedBy(amountBill).toNumber()
2527
2628 const result = matchesUTXO(resp, matchesAmount)
--- a/src/components/layout/save/action.js
+++ b/src/components/layout/save/action.js
@@ -17,8 +17,11 @@ export function FixedLimitDeposit(account, amount, address) {
1717 "order":"desc"
1818 }
1919 }).then(resp => {
20+ const limit = GetContractArgs().radio * 100000000
2021 if(resp.length === 0) {
2122 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}.`
2225 }
2326
2427 const result = matchesUTXO(resp, amount)
Show on old repository browser