William O'Beirne 371e6e327c Wallet Decrypt Redesign (#677)
* Reorganize files to better match other components.

* Initial UI for wallet buttons.

* Fix leftover rebase conflict.

* Wallet selection, styling, mobile handling.

* Initial work on animations.

* Adjusted animations.

* Adjust wallet unlock forms to be more uniform. Fix view address saying 'unlock'

* Adjust tooltips.

* Fix embedded decrypt components.

* Cover whole sign msg form with decrypt.

* Give deploy contract a better unlock treatment like sign msg.

* Reset decrypt component on hide / show

* Unused var

* Fix tooltip hover.

* Fix hover lift.

* Make spacing better on mobile.

* Back button mobile handling.

* Redesign mobile button icons. Prevent clicking through when clicking on icons.

* TSCheck fixes.

* Attempt to unlock MetaMask onClick, and provide existing flow with notification when unlock fails.

* Get rid of outline.

* Remove decrypt min height. Make view only textarea.

* Add change wallet buttons to deploy contract and sign msg.

* Standardize
2018-01-01 13:46:28 -06:00

64 lines
2.0 KiB
TypeScript

import React, { Component } from 'react';
import InteractForm from './components/InteractForm';
import { InteractExplorer } from './components//InteractExplorer';
import Contract from 'libs/contracts';
import { setToField, TSetToField } from 'actions/transaction';
import { Address } from 'libs/units';
import { showNotification, TShowNotification } from 'actions/notifications';
import { connect } from 'react-redux';
interface State {
currentContract: Contract | null;
showExplorer: boolean;
}
interface DispatchProps {
setToField: TSetToField;
showNotification: TShowNotification;
}
class InteractClass extends Component<DispatchProps, State> {
public initialState: State = {
currentContract: null,
showExplorer: false
};
public state: State = this.initialState;
public accessContract = (contractAbi: string, address: string) => () => {
try {
const parsedAbi = JSON.parse(contractAbi);
const contractInstance = new Contract(parsedAbi);
this.props.setToField({ raw: address, value: Address(address) });
// dispatch address to to field
this.setState({
currentContract: contractInstance,
showExplorer: true
});
} catch (e) {
this.props.showNotification(
'danger',
`Contract Access Error: ${(e as Error).message || 'Can not parse contract'}`
);
this.resetState();
}
};
public render() {
const { showExplorer, currentContract } = this.state;
return (
<main className="Interact Tab-content-pane" role="main">
<InteractForm accessContract={this.accessContract} resetState={this.resetState} />
<hr />
{showExplorer &&
currentContract && (
<InteractExplorer contractFunctions={Contract.getFunctions(currentContract)} />
)}
</main>
);
}
private resetState = () => this.setState(this.initialState);
}
export const Interact = connect(null, { showNotification, setToField })(InteractClass);