Skip to content

Commit e88a9bf

Browse files
authored
Merge pull request #46 from lightninglabs/misc-tweaks
Misc improvements throughout the app
2 parents 5043c0b + 8721e27 commit e88a9bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+894
-396
lines changed

app/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
"@emotion/core": "10.0.28",
2222
"@emotion/styled": "10.0.27",
2323
"@improbable-eng/grpc-web": "0.12.0",
24+
"@types/big.js": "4.0.5",
2425
"@types/file-saver": "2.0.1",
2526
"@types/react-virtualized": "^9.21.9",
27+
"big.js": "5.2.2",
2628
"debug": "4.1.1",
2729
"emotion-theming": "10.0.27",
2830
"file-saver": "2.0.2",

app/src/__stories__/AlertContainer.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { useStore } from 'store';
3+
import { Button } from 'components/base';
34
import AlertContainer from 'components/common/AlertContainer';
4-
import { Button } from 'components/common/base';
55

66
export default {
77
title: 'Components/Alerts',

app/src/__stories__/ChannelBalance.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export default {
1212

1313
const getChannel = (store: Store, ratio: number) => {
1414
const channel = new Channel(store, lndListChannelsOne.channelsList[0]);
15-
channel.localBalance = channel.capacity * ratio;
16-
channel.remoteBalance = channel.capacity * (1 - ratio);
15+
channel.localBalance = channel.capacity.mul(ratio);
16+
channel.remoteBalance = channel.capacity.mul(1 - ratio);
1717
return channel;
1818
};
1919

app/src/__stories__/ChannelRow.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const renderStory = (
2020
},
2121
) => {
2222
if (options && options.ratio) {
23-
channel.localBalance = channel.capacity * options.ratio;
24-
channel.remoteBalance = channel.capacity * (1 - options.ratio);
23+
channel.localBalance = channel.capacity.mul(options.ratio);
24+
channel.remoteBalance = channel.capacity.mul(1 - options.ratio);
2525
}
2626
return useObserver(() => (
2727
<div style={{ paddingTop: 50 }}>

app/src/__stories__/LoopActions.stories.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ export default {
77
title: 'Components/Loop Actions',
88
component: LoopActions,
99
parameters: { contained: true },
10-
decorators: [
11-
(storyFn: any) => <div style={{ width: 600, margin: 'auto' }}>{storyFn()}</div>,
12-
],
1310
};
1411

1512
export const Default = () => {
@@ -19,7 +16,15 @@ export const Default = () => {
1916
export const Opened = () => {
2017
const store = useStore();
2118
store.buildSwapStore.startSwap();
22-
// select 3 channels
19+
lndListChannels.channelsList.slice(0, 1).forEach(c => {
20+
store.buildSwapStore.toggleSelectedChannel(c.chanId);
21+
});
22+
return <LoopActions />;
23+
};
24+
25+
export const LoopInWarn = () => {
26+
const store = useStore();
27+
store.buildSwapStore.startSwap();
2328
lndListChannels.channelsList.slice(0, 3).forEach(c => {
2429
store.buildSwapStore.toggleSelectedChannel(c.chanId);
2530
});

app/src/__stories__/LoopHistory.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from 'react';
2+
import { observable } from 'mobx';
3+
import { useStore } from 'store';
24
import Tile from 'components/common/Tile';
35
import LoopHistory from 'components/loop/LoopHistory';
46

@@ -19,3 +21,13 @@ export const InsideTile = () => {
1921
</Tile>
2022
);
2123
};
24+
25+
export const Empty = () => {
26+
const { swapStore } = useStore();
27+
swapStore.swaps = observable.map();
28+
return (
29+
<Tile title="Loop History" onMaximizeClick={() => null}>
30+
<LoopHistory />
31+
</Tile>
32+
);
33+
};

app/src/__stories__/NodeStatus.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useEffect } from 'react';
2+
import Big from 'big.js';
23
import { useStore } from 'store';
34
import NodeStatus from 'components/NodeStatus';
45

@@ -12,7 +13,7 @@ export const Default = () => {
1213
const store = useStore();
1314
useEffect(() => {
1415
const { channelBalance, walletBalance } = store.nodeStore.wallet;
15-
store.nodeStore.wallet = { channelBalance: 0, walletBalance: 0 };
16+
store.nodeStore.wallet = { channelBalance: Big(0), walletBalance: Big(0) };
1617

1718
// change back to sample data when the component is unmounted
1819
return () => {

app/src/__stories__/Range.stories.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react';
2+
import Big from 'big.js';
23
import Range from 'components/common/Range';
34

45
export default {
@@ -8,16 +9,16 @@ export default {
89
};
910

1011
export const Default = () => {
11-
const [value, setValue] = useState(50);
12+
const [value, setValue] = useState(Big(50));
1213
return <Range value={value} onChange={setValue} />;
1314
};
1415

1516
export const StepByFive = () => {
16-
const [value, setValue] = useState(50);
17+
const [value, setValue] = useState(Big(50));
1718
return <Range value={value} onChange={setValue} step={5} />;
1819
};
1920

2021
export const WithMinMax = () => {
21-
const [value, setValue] = useState(50);
22+
const [value, setValue] = useState(Big(50));
2223
return <Range value={value} onChange={setValue} showRadios />;
2324
};

app/src/__stories__/StoryWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { BalanceMode, Unit } from 'util/constants';
44
import { sampleApiResponses } from 'util/tests/sampleData';
55
import { createStore, StoreProvider } from 'store';
66
import { PersistentSettings } from 'store/stores/settingsStore';
7-
import { Background } from 'components/common/base';
7+
import { Background } from 'components/base';
88
import { ThemeProvider } from 'components/theme';
99

1010
// mock the GRPC client to return sample data instead of making an actual request

app/src/__stories__/SwapWizard.stories.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { observable } from 'mobx';
33
import { SwapDirection } from 'types/state';
4+
import Big from 'big.js';
45
import { lndListChannels } from 'util/tests/sampleData';
56
import { useStore } from 'store';
67
import SwapWizard from 'components/loop/swap/SwapWizard';
@@ -35,7 +36,7 @@ export const Step2Fees = () => {
3536
build.startSwap();
3637
build.selectedChanIds = selectedChannels;
3738
build.setDirection(SwapDirection.OUT);
38-
build.setAmount(500000);
39+
build.setAmount(Big(500000));
3940
build.goToNextStep();
4041
return <SwapWizard />;
4142
};
@@ -45,7 +46,7 @@ export const Step3Processing = () => {
4546
build.startSwap();
4647
build.selectedChanIds = selectedChannels;
4748
build.setDirection(SwapDirection.OUT);
48-
build.setAmount(500000);
49+
build.setAmount(Big(500000));
4950
build.goToNextStep();
5051
build.goToNextStep();
5152
return <SwapWizard />;

0 commit comments

Comments
 (0)