Commit 08ec32a7 authored by allan juma's avatar allan juma

update

parent 86d3a150
......@@ -187,7 +187,8 @@ var poolStats = await grpc.initPyface(['/data/lightning-bits/src/chains/algo/poo
console.log(poolStats);
store.settings.chains.algo.account.balance = JSON.parse(poolStats).amount/1000000+' ALGOS'
store.settings.chains.algo.account.balance = JSON.parse(poolStats).amount/1000000+' ALGOS';
......
......@@ -22,9 +22,13 @@ class PoolAction {
* the app's transaction state by calling all necessary grpc apis.
* @return {undefined}
*/
init() {
this._nav.goPools();
this.update();
async init() {
var nav = this._nav;
this.update().then(function(){
console.log('INFO! loaded pools');
nav.goPools();
});
nav.goWait();
}
/**
......@@ -39,7 +43,7 @@ class PoolAction {
item.memo = await this.decodeMemo({ payReq: item.paymentRequest });
}
this._nav.goPoolDetail();
this.update();
//this.update();
}
/**
......@@ -49,7 +53,7 @@ class PoolAction {
*/
async update() {
await Promise.all([
this.getPools(),
await this.getPools(),
//this.getInvoices(),
//this.getPayments(),
]);
......@@ -60,8 +64,11 @@ class PoolAction {
var grpc = hii._grpc;
var store = hii._store;
console.log(pool);
try{
var pDat = await addAsaQuote(grpc,store,pool.poolID.id, 0);
}catch(er){
throw pDat;
}
var ret = {
id: pool.id,
cat: 'micro',
......@@ -74,7 +81,7 @@ var ret = {
url: 'https://demo1.bitsoko.org',
title: pool.name,
desc: pool.description,
amount: pDat.b,
amount: pDat.b/Math.pow(10,6),
fee: 0,
confirmations: 5,
status: pool.active ? 'open' : 'closed',
......@@ -106,6 +113,7 @@ var ret = {
pooled = pooled.filter(function(pl){
return pl.status == 'fulfilled' && pl.value.quote != undefined;
});
console.log(pooled);
this._store.pools = pooled.map(function(pl){
if(pl.status == 'fulfilled'){
var ret = pl.value;
......@@ -116,6 +124,7 @@ var ret = {
} catch (err) {
log.error('Listing transactions failed', err);
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="64 64 896 896" focusable="false" data-icon="shop" width="256px" height="256px" fill="#FFFFFF" aria-hidden="true"><path d="M882 272.1V144c0-17.7-14.3-32-32-32H174c-17.7 0-32 14.3-32 32v128.1c-16.7 1-30 14.9-30 31.9v131.7a177 177 0 0014.4 70.4c4.3 10.2 9.6 19.8 15.6 28.9v345c0 17.6 14.3 32 32 32h676c17.7 0 32-14.3 32-32V535a175 175 0 0015.6-28.9c9.5-22.3 14.4-46 14.4-70.4V304c0-17-13.3-30.9-30-31.9zM214 184h596v88H214v-88zm362 656.1H448V736h128v104.1zm234 0H640V704c0-17.7-14.3-32-32-32H416c-17.7 0-32 14.3-32 32v136.1H214V597.9c2.9 1.4 5.9 2.8 9 4 22.3 9.4 46 14.1 70.4 14.1s48-4.7 70.4-14.1c13.8-5.8 26.8-13.2 38.7-22.1.2-.1.4-.1.6 0a180.4 180.4 0 0038.7 22.1c22.3 9.4 46 14.1 70.4 14.1 24.4 0 48-4.7 70.4-14.1 13.8-5.8 26.8-13.2 38.7-22.1.2-.1.4-.1.6 0a180.4 180.4 0 0038.7 22.1c22.3 9.4 46 14.1 70.4 14.1 24.4 0 48-4.7 70.4-14.1 3-1.3 6-2.6 9-4v242.2zm30-404.4c0 59.8-49 108.3-109.3 108.3-40.8 0-76.4-22.1-95.2-54.9-2.9-5-8.1-8.1-13.9-8.1h-.6c-5.7 0-11 3.1-13.9 8.1A109.24 109.24 0 01512 544c-40.7 0-76.2-22-95-54.7-3-5.1-8.4-8.3-14.3-8.3s-11.4 3.2-14.3 8.3a109.63 109.63 0 01-95.1 54.7C233 544 184 495.5 184 435.7v-91.2c0-.3.2-.5.5-.5h655c.3 0 .5.2.5.5v91.2z"></path></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="64 64 896 896" focusable="false" data-icon="user" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M858.5 763.6a374 374 0 00-80.6-119.5 375.63 375.63 0 00-119.5-80.6c-.4-.2-.8-.3-1.2-.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-.4.2-.8.3-1.2.5-44.8 18.9-85 46-119.5 80.6a375.63 375.63 0 00-80.6 119.5A371.7 371.7 0 00136 901.8a8 8 0 008 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c.1 4.4 3.6 7.8 8 7.8h60a8 8 0 008-8.2c-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z"></path></svg>
<svg viewBox="64 64 896 896" focusable="false" data-icon="user" width="256px" height="256px" fill="#FFFFFF" aria-hidden="true"><path d="M858.5 763.6a374 374 0 00-80.6-119.5 375.63 375.63 0 00-119.5-80.6c-.4-.2-.8-.3-1.2-.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-.4.2-.8.3-1.2.5-44.8 18.9-85 46-119.5 80.6a375.63 375.63 0 00-80.6 119.5A371.7 371.7 0 00136 901.8a8 8 0 008 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c.1 4.4 3.6 7.8 8 7.8h60a8 8 0 008-8.2c-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z"></path></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="64 64 896 896" focusable="false" data-icon="team" width="256px" height="256px" fill="#FFFFFF" aria-hidden="true"><path d="M824.2 699.9a301.55 301.55 0 00-86.4-60.4C783.1 602.8 812 546.8 812 484c0-110.8-92.4-201.7-203.2-200-109.1 1.7-197 90.6-197 200 0 62.8 29 118.8 74.2 155.5a300.95 300.95 0 00-86.4 60.4C345 754.6 314 826.8 312 903.8a8 8 0 008 8.2h56c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5A226.62 226.62 0 01612 684c60.9 0 118.2 23.7 161.3 66.8C814.5 792 838 846.3 840 904.3c.1 4.3 3.7 7.7 8 7.7h56a8 8 0 008-8.2c-2-77-33-149.2-87.8-203.9zM612 612c-34.2 0-66.4-13.3-90.5-37.5a126.86 126.86 0 01-37.5-91.8c.3-32.8 13.4-64.5 36.3-88 24-24.6 56.1-38.3 90.4-38.7 33.9-.3 66.8 12.9 91 36.6 24.8 24.3 38.4 56.8 38.4 91.4 0 34.2-13.3 66.3-37.5 90.5A127.3 127.3 0 01612 612zM361.5 510.4c-.9-8.7-1.4-17.5-1.4-26.4 0-15.9 1.5-31.4 4.3-46.5.7-3.6-1.2-7.3-4.5-8.8-13.6-6.1-26.1-14.5-36.9-25.1a127.54 127.54 0 01-38.7-95.4c.9-32.1 13.8-62.6 36.3-85.6 24.7-25.3 57.9-39.1 93.2-38.7 31.9.3 62.7 12.6 86 34.4 7.9 7.4 14.7 15.6 20.4 24.4 2 3.1 5.9 4.4 9.3 3.2 17.6-6.1 36.2-10.4 55.3-12.4 5.6-.6 8.8-6.6 6.3-11.6-32.5-64.3-98.9-108.7-175.7-109.9-110.9-1.7-203.3 89.2-203.3 199.9 0 62.8 28.9 118.8 74.2 155.5-31.8 14.7-61.1 35-86.5 60.4-54.8 54.7-85.8 126.9-87.8 204a8 8 0 008 8.2h56.1c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5 29.4-29.4 65.4-49.8 104.7-59.7 3.9-1 6.5-4.7 6-8.7z"></path></svg>
......@@ -3,7 +3,7 @@
*/
import { extendObservable } from 'mobx';
import { toAmountLabel, toCaps, parseDate } from '../helper';
import { toAmountLabel, toAmount, toCaps, parseDate } from '../helper';
const ComputedPool = store => {
......@@ -13,24 +13,23 @@ const ComputedPool = store => {
const t = pools ? pools.slice() : [];
//const p = payments ? payments.slice() : [];
//const i = invoices ? invoices.slice() : [];
store.poolBalance = 0;
const all = [].concat(t);
//all.sort((a, b) => b.date.getTime() - a.date.getTime());
all.sort((a, b) => b.amount - a.amount);
all.forEach((t, i) => {
store.poolBalance = store.poolBalance + (parseInt(t.quote*t.amount));
store.poolBalance = store.poolBalance + (parseInt(t.quoteFiat*t.amount));
t.key = String(i);
//t.idName = t.type === 'algorand' ? '209:BITS:dooca-net' : 'Ethereum';
t.idName = t.id+':BITS:MSM-1:POOL | '+t.title;
t.idName = t.id+':BITS:MSM1 | '+t.title;
t.icon = t.icon;
t.typeLabel = toCaps(t.type);
t.statusLabel = toCaps(t.status);
t.merchantLabel = t.title;
//t.quote = addQuote(t.aID, 0);
t.quoteFiat = parseFloat(toAmount(parseInt(parseFloat(t.quote)*Math.pow(10,6)), settings));
t.dateLabel = t.date.toLocaleDateString();
t.dateTimeLabel = t.date.toLocaleString();
t.amountLabel = toAmountLabel(parseInt(parseFloat(t.quote)*Math.pow(10,6)), settings);
t.share = t.amount/Math.pow(10,6);
t.quoteLabel = toAmountLabel(parseInt(parseFloat(t.quote)*Math.pow(10,6)), settings);
t.raised = toAmountLabel(0, settings);
if (Number.isInteger(t.confirmations)) {
t.confirmationsLabel = t.confirmations.toString();
......@@ -59,7 +58,9 @@ const ComputedPool = store => {
.reduce((a, b) => a + b, 0);
},
get poolBalanceLabel() {
const { poolBalance, settings } = store;
var { poolBalance, settings } = store;
if (isNaN(poolBalance) || poolBalance == undefined) poolBalance = 0;
console.log(poolBalance);
return toAmountLabel(poolBalance, settings);
},
get poolBalanceOpenLabel() {
......
......@@ -154,8 +154,8 @@ export const addAsaQuote = async (grpc, store, aID1, aID2) => {
// var quote = await grpc.initPyface(['/data/lightning-bits/src/chains/algo/pools.py', 'swap', aID1, aID2, 10, store.settings.chains.algo.account.address, store.settings.chains.algo.account.mnemonic, 'remove' ]);
var quote = await grpc.initPyface(['/data/lightning-bits/src/chains/algo/pools.py', 'quote', aID1, aID2, store.settings.chains.algo.account.address ]);
console.log(quote);
try{
if(quote == '{}')throw 'quote:'+quote+' is not a number';
var q = parseFloat(quote.split("'")[1].split("'")[0]);
var b = parseInt(quote.split("'")[2].replace(/\D/g,''));
if(b >= 0){
......@@ -176,6 +176,7 @@ export const addAsaQuote = async (grpc, store, aID1, aID2) => {
}
}catch(er){
console.error(er);
throw er;
}
}
......
......@@ -120,7 +120,7 @@ class MainView extends Component {
<NewAddress store={store} invoice={invoice} info={info} />
)}
{route === 'LoaderSyncing' && <LoaderSyncing store={store} />}
{route === 'Wait' && <Wait />}
{route === 'Wait' && <Wait nav={nav} />}
{route === 'Home' && (
<Home
store={store}
......
......@@ -237,7 +237,7 @@ const PoolDetailView = ({ store, grpc, nav, pooladdliq, poolremoveliq}) => (
{store.selectedPool.desc}
</DetailField>
<DetailField name="Performance">
VALUATION: {parseInt(store.selectedPool.quote*1000*Math.pow(10,6))+store.settings.fiat} | PRICE: {parseInt(store.selectedPool.quote*Math.pow(10,6))+store.settings.fiat} | SHARE: {parseInt(store.selectedPool.amount*store.selectedPool.quote)+store.settings.fiat}
VALUATION: {parseInt(store.selectedPool.quoteFiat*1000)+store.settings.fiat} | PRICE: {parseInt(store.selectedPool.quoteFiat)+store.settings.fiat} | SHARE: {parseInt(store.selectedPool.amount*store.selectedPool.quoteFiat)+store.settings.fiat}
</DetailField>
{store.selectedPool.memo ? (
<DetailField name="Note">
......@@ -245,10 +245,10 @@ const PoolDetailView = ({ store, grpc, nav, pooladdliq, poolremoveliq}) => (
</DetailField>
) : null}
<DetailField name="Pool">
CAP: 0{store.unitLabel} | FUNDED: 0% | INVESTORS: 1 | ID: {store.selectedPool.id}:BITS:dooca.net
CAP: 0{store.unitLabel} | FUNDED: 12% | INVESTORS: 11 | ID: {store.selectedPool.id}:BITS
</DetailField>
<DetailField name="Asset Supply">
TOTAL: 1,000 | OWNED: {store.selectedPool.amount/Math.pow(10,6)} | CIRCULATING: 30% | ID: {store.selectedPool.assetID}
TOTAL: 1,000 | OWNED: {store.selectedPool.amount} | CIRCULATING: 30% | ID: {store.selectedPool.assetID}
</DetailField>
{store.selectedPool.confirmationsLabel ? (
<DetailField name="Contract">
......
......@@ -101,6 +101,7 @@ const PoolBalances = ({
balanceLabel,
unitLabel,
}) => (
<View style={summaryStyles.wrapper}>
<View style={summaryStyles.box}>
<View style={summaryStyles.alert}>
......@@ -206,7 +207,7 @@ const PoolView = ({ store, nav, pool, grpc, goPoolAdd }) => {
<View style={poolStyles.btnWrapper}>
</View>
<Title style={poolStyles.poolInfo} title="Select upto three merchants to manage liquidity pool funds" />
<Title style={poolStyles.poolInfo} title="Select merchants to manage liquidity pool funds" />
<ListContent>
<List
data={pools}
......@@ -267,7 +268,10 @@ const setState = tx => {
};
const capType = tx => {
return require('../asset/icon/'+tx.cat+'.svg');
//tx.cat
var cap = ['micro','small','medium'].sort(() => Math.random() - Math.random()).slice(0, 1)[0];
return require('../asset/icon/'+cap+'.png');
//return require('../asset/icon/soko.png');
};
const statusType = tx => {
......@@ -286,36 +290,30 @@ const iconType = tx => {
tx.status === 'confirmed' ? 'success' : 'info';
}
*/
return require('../asset/icon/'+tx.type+'.png');
return require('../asset/icon/'+tx.cat+'.png');
};
const PoolListItem = ({ tx, onSelect }) => (
<ListItem style={iStyles.item} onSelect={onSelect}>
<Icon
image={iconType(tx)}
image={capType(tx)}
style={poolStyles.listIcon}
/>
<View style={iStyles.i}>
</View>
<Icon
image={capType(tx)}
style={poolStyles.listIcon}
/>
<View style={[iStyles.m, iStyles.group]}>
<Alert type={setState(tx)} style={iStyles.alert} />
<Text style={iStyles.txt}>{tx.statusLabel}</Text>
</View>
<Text style={[iStyles.m, iStyles.txt]}>{tx.Label}</Text>
<View style={iStyles.l}>
<Text style={[iStyles.txt, iStyles.wrap]} numberOfLines={1}>
{tx.merchantLabel}
</Text>
</View>
<Text style={[iStyles.m, iStyles.txt]}>{tx.share}</Text>
<Text style={[iStyles.m, iStyles.txt]}>{tx.amountLabel}</Text>
<Text style={[iStyles.m, iStyles.txt]}>{tx.amount}</Text>
<Text style={[iStyles.m, iStyles.txt]}>{tx.quoteLabel}</Text>
<Text style={[iStyles.s, iStyles.txt]}>{tx.raised}</Text>
</ListItem>
);
......@@ -342,8 +340,8 @@ const hStyles = StyleSheet.create({
const PoolListHeader = () => (
<ListHeader style={[iStyles.item, hStyles.header]}>
<View style={iStyles.i} />
<Text style={[iStyles.m, hStyles.txt]}>CONTRACT</Text>
<Text style={[iStyles.m, hStyles.txt]}>STATUS</Text>
<Text style={[iStyles.m, hStyles.txt]}></Text>
<Text style={[iStyles.l, hStyles.txt]}>MERCHANT</Text>
<Text style={[iStyles.l, hStyles.txt]}>SHARE</Text>
<Text style={[iStyles.m, hStyles.txt]}>PRICE</Text>
......
......@@ -3,20 +3,36 @@ import { StyleSheet } from 'react-native';
import Background from '../component/background';
import MainContent from '../component/main-content';
import { color } from '../component/style';
import PropTypes from 'prop-types';
import { Button, ButtonText } from '../component/button';
import { ContinuousLoadNetworkSpinner } from '../component/spinner';
const styles = StyleSheet.create({
content: {
justifyContent: 'center',
},
btn: {
position: 'fixed',
bottom: '0px',
},
});
const WaitView = () => (
const WaitView = ({ nav }) => (
<Background color={color.blackDark}>
<MainContent style={styles.content}>
<ContinuousLoadNetworkSpinner msg="Loading network..." />
<ContinuousLoadNetworkSpinner msg="Loading..." />
<Button onPress={() => nav.goHome()} style={styles.btn}>
<ButtonText>HOME</ButtonText>
</Button>
</MainContent>
</Background>
);
WaitView.propTypes = {
nav: PropTypes.object.isRequired,
};
export default WaitView;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment