Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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,355 changes: 1,216 additions & 1,139 deletions web/package-lock.json

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import React from 'react';
import React, {useState} from 'react';
import { MainFrame } from './components/MainFrame';
import './App.css';
import {useDispatch, useSelector} from "react-redux";
import {RootStore} from "./Store";
import { GetWalletAddress } from '../src/api/Wallet'

function App() {

return (
<div>
<MainFrame currentPage="home"/>
</div>
<div>
<MainFrame currentPage="home" />
</div>


);
}

export default App;
export default App;
10 changes: 10 additions & 0 deletions web/src/Store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createStore, applyMiddleware } from 'redux';
import RootReducer from './reducers/RootReducer';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';

const Store = createStore(RootReducer, composeWithDevTools(applyMiddleware(thunk)));

export type RootStore = ReturnType<typeof RootReducer>

export default Store;
4 changes: 3 additions & 1 deletion web/src/api/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const RequestConfig: AxiosRequestConfig = {
'Access-Control-Allow-Origin': '*',
'Cache-Control': 'no-cache',
'Content-Type': 'text/plain',
'Accept': 'application/json'
'Accept': 'application/json',
"Access-Control-Allow-Headers": "X-Requested-With, content-type",
"Access-Control-Allow-Methods": "PUT, POST, GET, DELETE, PATCH, OPTIONS",
},
responseType: 'json'
};
Expand Down
85 changes: 84 additions & 1 deletion web/src/api/Wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,87 @@
import axios from 'axios';
import { Dispatch } from 'redux';
import { RequestConfig }from "./Config";
import {
AddressRes,
MnemonicRes,
ImportMnemonicReq,
ImportMnemonicRes,
UnlockWalletReq,
UnlockWalletRes,
EncryptWalletReq,
EncryptWalletRes,
} from '../types/Wallet';
import {
WALLET_ADDRESS_RESPONSE,
MNEMONIC_RESPONSE,
IMPORT_MNEMONIC_REQUEST,
IMPORT_MNEMONIC_RESPONSE,
UNLOCK_WALLET_REQUEST,
UNLOCK_WALLET_RESPONSE,
ENCRYPT_WALLET_REQUEST,
ENCRYPT_WALLET_RESPONSE,
WalletActionTypes,
AppActions
} from '../types/actions';
import { AppState } from '../store/configureStore';

export const getMnemonicResponse = (mnemonic_response: MnemonicRes[]): AppActions => ({
type: MNEMONIC_RESPONSE,
mnemonic_response
})

export const getWalletAdress = (address_response: AddressRes ): AppActions => ({
type: WALLET_ADDRESS_RESPONSE,
address_response
})

export const MnemonicRequest = (mnemonic_request: ImportMnemonicReq[]): AppActions => ({
type: IMPORT_MNEMONIC_REQUEST,
mnemonic_request
})

export const RestoreMnemonicResponse = (restore_mnemonic_response: ImportMnemonicRes ): AppActions => ({
type: IMPORT_MNEMONIC_RESPONSE,
restore_mnemonic_response
})

export const UnlockRequest = (wallet_request: UnlockWalletReq[]): AppActions => ({
type: UNLOCK_WALLET_REQUEST,
wallet_request
})

export const UnlockResponse = (wallet_response: UnlockWalletRes): AppActions => ({
type: UNLOCK_WALLET_RESPONSE,
wallet_response
})

export const EncryptRequest = (encrypt_request: EncryptWalletReq): AppActions => ({
type: ENCRYPT_WALLET_REQUEST,
encrypt_request
})

export const EncryptResponse = (encrypt_response: EncryptWalletRes): AppActions => ({
type: ENCRYPT_WALLET_RESPONSE,
encrypt_response
})

export const GetWalletAddress = () => async (dispatch: Dispatch<WalletActionTypes>) => {
try {
const response = await axios.get("/wallet/defaultaddress", RequestConfig);
console.log(response, "response inside Wallet Address Action. ts")
dispatch({
type: WALLET_ADDRESS_RESPONSE,
address_response: response.data
})
} catch(error) {
var errMessage = "GetWalletAddresses execute [Get] /wallet/defaultaddress error: " + error;
var errResponse: WalletAddressResponse = {
address: errMessage
}
return errResponse;
}

}

export interface WalletAddressResponse {
address: string;
Expand Down Expand Up @@ -38,12 +120,13 @@ export interface EncryptWalletResponse {
result: string;
};


export const GetMnemonic = async (): Promise<MnemonicResponse> => {
return await axios.get<MnemonicResponse>("/wallet/mnemonic", RequestConfig).then(function (response) {

return response.data;
}).catch(function (error) {
var errMessage = "GetMnemonics execute [Get] /wallet/mnemonic error: " + error;
console.log(errMessage);
var errResponse: MnemonicResponse = {
hdseed: "",
mnemonic: "",
Expand Down
10 changes: 8 additions & 2 deletions web/src/components/MainFrame.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { Component } from "react";
import { Settings } from "./Settings";
import ReactDOM from "react-dom";
import { TerminalPage } from "./TerminalPage";
import { SetupWizard } from "./SetupWizard";
import { WalletView } from "./wallet/View";
import {useDispatch, useSelector} from "react-redux";
import {
Button,
Dropdown,
Expand Down Expand Up @@ -33,7 +35,7 @@ export class MainFrame extends Component<MainFrameProps, MainFrameState> {
this.currentPage = props.currentPage ? props.currentPage : "home";
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.changePage = this.changePage.bind(this);
}

Expand All @@ -46,7 +48,7 @@ export class MainFrame extends Component<MainFrameProps, MainFrameState> {
});
}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

private changePage(pageName: string): void {
this.currentPage = pageName;
Expand Down Expand Up @@ -106,6 +108,10 @@ export class MainFrame extends Component<MainFrameProps, MainFrameState> {
/>
</Dropdown.Menu>
</Dropdown>
<Menu.Item onClick={() => this.changePage("bridges")} as="a">
<Icon name="connectdevelop" />
Test Button
</Menu.Item>
</Menu>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from "react";
import ReactDOM from "react-dom";
import { Button, Form, Header } from "semantic-ui-react";
import { RestartWebServer, UpdateWebServerConfig, WebServerConfig, WebServerRestartRequest } from "../api/WebServerConfig";
import { UpdateIceConfig, IceServerConfig } from "../api/IceServerConfig";
Expand Down Expand Up @@ -28,7 +29,7 @@ export class Settings extends Component<SettingsProps, SettingsState> {
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.getConfigSettings = this.getConfigSettings.bind(this);
this.updateIceConfig = this.updateIceConfig.bind(this);
this.updateWebServerConfig = this.updateWebServerConfig.bind(this);
Expand All @@ -39,7 +40,7 @@ export class Settings extends Component<SettingsProps, SettingsState> {
this.getConfigSettings();
}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

private getConfigSettings = () => {
GetConfigSettings().then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/SetupWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export class SetupWizard extends Component<SetupWizardProps, SetupWizardState> {
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
}

componentDidMount(): void {
this.setState({ currentStep: this.props.currentStep });
}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

render() {
return (
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/TerminalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export class TerminalPage extends Component<TerminalProps, TerminalState> {

// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
}

componentDidMount(): void {
this.setState({ mode: this.props.mode });
}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

render() {
return (
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/wallet/FileRestore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class WalletFileRestore extends Component<
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.filesSelectedHandler = this.filesSelectedHandler.bind(this);
this.loadSecureFileData = this.loadSecureFileData.bind(this);
this.onMnemonic = this.onMnemonic.bind(this);
Expand All @@ -47,7 +47,7 @@ export class WalletFileRestore extends Component<
this.setState({ fileContents: undefined });
}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

private loadSecureFileData = (file: FilePathInfo, reader?: FileReader) => {
if (reader) {
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/wallet/MnemonicBackup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class MnemonicBackup extends Component<
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.backupSecureFile = this.backupSecureFile.bind(this);
this.getMnemonic = this.getMnemonic.bind(this);
}
Expand All @@ -36,7 +36,7 @@ export class MnemonicBackup extends Component<
this.getMnemonic();
}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

backupSecureFile = async () => {
if (this.state && this.state.mnemonic) {
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/wallet/MnemonicRestore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export class WalletMnemonicRestore extends Component<
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.setMnemonic = this.setMnemonic.bind(this);
}

componentDidMount(): void {}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

private setMnemonic(words: string): void {
this.setState({ mnemonic: words });
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/wallet/MnemonicWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ export class MnemonicWarning extends Component<
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}

componentDidMount(): void {}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

handleSubmit = (e: FormEvent) => {
//if we don't prevent form submission, causes a browser reload
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/wallet/Restore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export class WalletRestore extends Component<
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
}

componentDidMount(): void {
this.setState({ useMnemonic: undefined });
}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

render() {
return (
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/wallet/RestoreFilePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ export class WalletRestoreFilePassword extends Component<
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.decryptSecureMnemonicFile = this.decryptSecureMnemonicFile.bind(this);
}

componentDidMount(): void {}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

private decryptSecureMnemonicFile(): void {
let mnemonicFilePassphrase = this.state.passwordText;
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/wallet/SecureFilePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export class WalletSecureFilePassword extends Component<
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.encryptSecureMnemonicFile = this.encryptSecureMnemonicFile.bind(this);
// init state
this.state = { password: "", confirmPassword: "" };
}

componentDidMount(): void {}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

private encryptSecureMnemonicFile = async () => {
if (this.state.password !== this.state.confirmPassword) {
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/wallet/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class WalletSetup extends Component<WalletSetupProps, WalletSetupState> {
super(props);
// bind events
this.componentDidMount = this.componentDidMount.bind(this);
this.componentDidUnmount = this.componentDidUnmount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.onNewWallet = this.onNewWallet.bind(this);
this.onMnemonicBackup = this.onMnemonicBackup.bind(this);
// set initial state
Expand All @@ -57,7 +57,7 @@ export class WalletSetup extends Component<WalletSetupProps, WalletSetupState> {

componentDidMount(): void {}

componentDidUnmount(): void {}
componentWillUnmount(): void {}

private onNewWallet(): void {
this.props.onComplete();
Expand Down
Loading