Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lightning Loop functionality #226

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6456078
added loop out terms
Jul 1, 2019
e7eb770
removed unused ui files
Jul 1, 2019
455c28b
fixed loop out actions
Jul 1, 2019
f47647a
made changes to temporarily resolve broken travis ci build
Jul 1, 2019
8d0b945
ran yarn tsc locally to resolve build issues
Jul 1, 2019
34e0e89
refactored loop url initialization/add loop out quote
Jul 7, 2019
7068c69
added success message
Jul 7, 2019
573883c
removed unused imports
Jul 7, 2019
7e1fd54
removed package-lock.json
Jul 7, 2019
39a97f8
started working on default swap out
Jul 9, 2019
514a748
initiated loop out from joule - buggy
Jul 10, 2019
78b32c2
updated ComponentDidUpdate to debug Loop Out
Jul 15, 2019
3128df5
started on advanced loop form
Jul 15, 2019
6140fc4
added advanced fields
Jul 16, 2019
adc06b7
add password before loop out
Jul 16, 2019
4c02904
fixed incorrect password bug
Jul 17, 2019
40aa55b
modified loop quote form
Jul 18, 2019
1ef07df
fixed loop url bug
Jul 19, 2019
af93605
fixed interface typo
Jul 21, 2019
b26b4bc
updated conf_target for loop 2.2
Aug 3, 2019
78d927c
updated sweep confirmation handling
Aug 3, 2019
f579667
added loop in support
Aug 5, 2019
1865979
fixed build
Aug 5, 2019
c47a1e8
added deep equality check
Aug 5, 2019
20bcadc
fixed loop terms bug
Aug 6, 2019
5b945fc
added channel selection logic
Aug 7, 2019
6600113
fixed variable shadowing lint error
Aug 7, 2019
8d35edf
Merge remote-tracking branch 'upstream/develop' into loop
Aug 7, 2019
4bb3957
updated channel selector for Loop In
Aug 7, 2019
7bca5e3
removed unncessary fields from loop in
Aug 8, 2019
e7af691
refactored for review
Aug 18, 2019
5528097
set loop with terms asynchronously
Aug 18, 2019
40c830c
fixed typo and minor clean up
Aug 18, 2019
4fa2d81
updated constant
Aug 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"rimraf": "2.6.2",
"string-hash": "1.1.3",
"webextension-polyfill-ts": "0.8.9",
"webpack-bundle-analyzer": "3.0.3",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-dev-server": "3.2.1",
"write-file-webpack-plugin": "^4.5.0"
}
Expand Down
12 changes: 12 additions & 0 deletions src/app/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import HomePage from 'pages/home';
import OnboardingPage from 'pages/onboarding';
import SettingsPage from 'pages/settings';
import BalancesPage from 'pages/balances';
import LoopPage from 'pages/loop';
import FourOhFourPage from 'pages/fourohfour';
import Template, { Props as TemplateProps } from 'components/Template';

Expand Down Expand Up @@ -74,6 +75,17 @@ const routeConfigs: RouteConfig[] = [
showBack: true,
},
},
{
// Loop
route: {
path: '/loop',
component: LoopPage,
},
template: {
title: 'Loop',
showBack: true,
},
},
{
// 404
route: {
Expand Down
14 changes: 14 additions & 0 deletions src/app/components/Loop/InputLoopAddress.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.InputLoopAddress {
width: 100%;
max-width: 440px;
margin: 0 auto;

.ant-form-item,
.ant-alert {
margin-bottom: 1rem;
}

.ant-alert a {
text-decoration: underline;
}
}
94 changes: 94 additions & 0 deletions src/app/components/Loop/InputLoopAddress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import React from 'react';
import { browser } from 'webextension-polyfill-ts';
import { Button, Form, Input, message } from 'antd';
import { urlWithoutPort } from 'utils/formatters';
import './InputLoopAddress.less';
import { setLoop, setLoopIn } from 'modules/loop/actions';

interface Props {
initialUrl?: string | null;
error: Error | null;
setLoop: typeof setLoop;
setLoopIn: typeof setLoopIn;
type: string;
}

interface State {
url: string;
submittedUrl: string;
validation: string;
}

export default class InputLoopAddress extends React.Component<Props, State> {
state: State = {
url: this.props.initialUrl || '',
submittedUrl: this.props.initialUrl || '',
validation: '',
};

componentDidUpdate(nextProps: Props) {
// Handle errors for incorrect URL
const { error, initialUrl } = this.props;
if (error !== null && nextProps.error === null) {
message.error(`Error setting URL!`, 2);
}
if (initialUrl !== null && nextProps.initialUrl === null) {
message.success(`Loop URL set successfully!`, 2);
}
}

render() {
const { validation, url } = this.state;
const { type } = this.props;
const validateStatus = url ? (validation ? 'error' : 'success') : undefined;
return (
<Form className="InputLoopAddress" onSubmit={this.handleSubmit} layout="vertical">
<Form.Item label={`${type} URL`} validateStatus={validateStatus}>
<Input
type="url"
size="small"
value={url}
onChange={this.handleChange}
placeholder="http://localhost:8081"
autoFocus
/>
</Form.Item>

<Button type="primary" size="large" htmlType="submit" disabled={!url} block>
{`Set ${type} URL`}
</Button>
reemuru marked this conversation as resolved.
Show resolved Hide resolved
</Form>
);
}

private handleChange = (ev: React.ChangeEvent<HTMLInputElement>) => {
const url = ev.currentTarget.value;
let validation = '';
try {
// tslint:disable-next-line
new URL(url);
} catch (err) {
validation = 'That doesn’t look like a valid url';
}
this.setState({ url, validation });
};

private handleSubmit = (ev: React.FormEvent<HTMLFormElement>) => {
const url = this.state.url.replace(/\/$/, '');
const loop = this.props;
ev.preventDefault();
browser.permissions
.request({
origins: [urlWithoutPort(url)],
})
.then(accepted => {
if (!accepted) {
message.warn('Permission denied, connection may fail');
}
this.setState({ submittedUrl: url });
loop.type === 'Loop Out'
? loop.setLoop(this.state.url)
: loop.setLoopIn(this.state.url);
reemuru marked this conversation as resolved.
Show resolved Hide resolved
});
};
}
Loading