Skip to content

Commit

Permalink
Update Butler's packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
kraikov committed Aug 3, 2020
1 parent 4cfff06 commit 41b71f2
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 53 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"test": "rescripts test",
"eject": "react-scripts eject",
"electron-start": "concurrently \"yarn build && cross-env BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\"",
"electron-start-dev": "concurrently \"cross-env BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\"",
"postinstall": "electron-builder install-app-deps",
"preelectron-pack": "yarn build",
"electron-pack": "electron-builder build -w",
Expand Down Expand Up @@ -41,8 +42,8 @@
"@jelly-swap/bitcoin": "0.1.42",
"@jelly-swap/btc-provider": "0.1.40",
"@jelly-swap/btc-utils": "0.1.40",
"@jelly-swap/btc-web-wallet": "0.1.42",
"@jelly-swap/erc20": "0.1.42",
"@jelly-swap/btc-web-wallet": "0.1.45",
"@jelly-swap/erc20": "0.1.44",
"@jelly-swap/ethereum": "0.1.42",
"@jelly-swap/utils": "0.1.41",
"axios": "^0.19.2",
Expand Down
45 changes: 43 additions & 2 deletions src/components/pages/serverONPages/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
import React from 'react';
import React, { useState, useEffect } from 'react';

import { Route } from 'react-router-dom';

import moment from 'moment';
import { v4 as uuidv4 } from 'uuid';

import Terminal from './terminal';
import BalanceOf from './balanceOf';

import { useChannel } from '../../../hooks/useChannel';

const ALLOWED_MESSAGES = ['DATA', 'ERROR'];
const MAX_LOGS = 9999;
const LOGS_TO_REMOVE = 1000;

const getCurrentDate = () => moment().format('MMM Do YYYY h:mm:s A');
const getMessageType = message => message?.indexOf(':') !== -1 && message?.split(':')[0];

const ServerONPages = () => {
const [terminalData, setTerminalData] = useState([
{ now: getCurrentDate(), info: ': Loading...', id: uuidv4(), msgType: 'DATA' },
]);

const { data } = useChannel('data');

useEffect(() => {
const messageType = getMessageType(data);

if (ALLOWED_MESSAGES.includes(messageType)) {
const now = getCurrentDate();

const log = { now, info: data, msgType: messageType, id: uuidv4() };

setTerminalData(terminalData => [...terminalData, log]);
}
}, [data]);

useEffect(() => {
if (terminalData.length === MAX_LOGS) {
const dataRef = [...terminalData];

dataRef.splice(0, LOGS_TO_REMOVE);

setTerminalData(dataRef);
}
}, [terminalData]);

return (
<>
<Route exact path='/terminal' component={() => <Terminal />} />
<Route exact path='/terminal' component={() => <Terminal terminalData={terminalData} />} />
<Route exact path='/balanceOf' component={() => <BalanceOf />} />
</>
);
Expand Down
43 changes: 2 additions & 41 deletions src/components/pages/serverONPages/terminal/index.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,10 @@
import React, { useState, useEffect } from 'react';

import moment from 'moment';
import { v4 as uuidv4 } from 'uuid';
import React from 'react';

import LogData from './logData';

import { useChannel } from '../../../../hooks/useChannel';
import './style.scss';

const ALLOWED_MESSAGES = ['DATA', 'ERROR'];
const MAX_LOGS = 9999;
const LOGS_TO_REMOVE = 1000;

const getCurrentDate = () => moment().format('MMM Do YYYY h:mm:s A');
const getMessageType = message => message?.indexOf(':') !== -1 && message?.split(':')[0];

const JellyTerminal = () => {
const [terminalData, setTerminalData] = useState([
{ now: getCurrentDate(), info: ': Loading...', id: uuidv4(), msgType: 'DATA' },
]);

const { data } = useChannel('data');

useEffect(() => {
const messageType = getMessageType(data);

if (ALLOWED_MESSAGES.includes(messageType)) {
const now = getCurrentDate();

const log = { now, info: data, msgType: messageType, id: uuidv4() };

setTerminalData(terminalData => [...terminalData, log]);
}
}, [data]);

useEffect(() => {
if (terminalData.length === MAX_LOGS) {
const dataRef = [...terminalData];

dataRef.splice(0, LOGS_TO_REMOVE);

setTerminalData(dataRef);
}
}, [terminalData]);

const JellyTerminal = ({ terminalData }) => {
return <LogData terminalData={terminalData} />;
};

Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1315,10 +1315,10 @@
resolved "https://registry.yarnpkg.com/@jelly-swap/btc-utils/-/btc-utils-0.1.40.tgz#ba8bfa438920d751a6f1873e787434a824741ee2"
integrity sha512-kG82iBjIslSYezWTE3XyywqlcySpPvJCQgV38O/b2xYzqSYSbJnVe4y/evWSfKdMDBexzFJ6MdrspMKVmTspXw==

"@jelly-swap/btc-web-wallet@0.1.42":
version "0.1.42"
resolved "https://registry.yarnpkg.com/@jelly-swap/btc-web-wallet/-/btc-web-wallet-0.1.42.tgz#9ae7e15af28690aff8e320e961645aa83ff8465e"
integrity sha512-glug+H6TWEB3BOe6gP/B9wH4jiFAIGlHE23u07H7c3B+DHnNunBBIU6mkMO4J0veh+1xImT7vrjaPvnSCw9A2w==
"@jelly-swap/btc-web-wallet@0.1.45":
version "0.1.45"
resolved "https://registry.yarnpkg.com/@jelly-swap/btc-web-wallet/-/btc-web-wallet-0.1.45.tgz#1cc9fa54f46337371832e5271e104339e03524f6"
integrity sha512-yvB8Kp1zb9nux50aGVvfjL2H8+ZKj4AzrLDCVABUnj9IZYs+5FKNM0jreE1Kkvv6MiASFm8ojo5/xc+O4lQoWg==
dependencies:
"@jelly-swap/btc-utils" "^0.1.40"
"@jelly-swap/types" "^0.1.42"
Expand All @@ -1328,10 +1328,10 @@
bitcoinjs-message "^2.1.0"
coinselect "3.1.11"

"@jelly-swap/erc20@0.1.42":
version "0.1.42"
resolved "https://registry.yarnpkg.com/@jelly-swap/erc20/-/erc20-0.1.42.tgz#87795fede43ef1ebb05efdb1f75a81d516f1b15a"
integrity sha512-7ch72Oa+IyC0QXicYvwJ04u0EREBSxTXxR9TjedO/K235iu7ErcLx/TksrgbeR+PLjgQYREsGcowAwO51VWEOg==
"@jelly-swap/erc20@0.1.44":
version "0.1.44"
resolved "https://registry.yarnpkg.com/@jelly-swap/erc20/-/erc20-0.1.44.tgz#8c9ff9335d85fe21683f834bbd2f27443d0924fb"
integrity sha512-twbl5yWp15Djblq0mGpcucXh1SspKZCPa5flyGwqzSQls3vBBeKNJW8GcoTqVm0xmtfJhuA3dzebX0Snpc5lgA==
dependencies:
"@jelly-swap/ethereum" "^0.1.42"
"@jelly-swap/types" "^0.1.42"
Expand Down

0 comments on commit 41b71f2

Please sign in to comment.