diff options
author | Hsuan Lee <hsuan@cobinhood.com> | 2019-01-19 18:42:04 +0800 |
---|---|---|
committer | Hsuan Lee <hsuan@cobinhood.com> | 2019-01-19 18:42:04 +0800 |
commit | 7ae38906926dc09bc10670c361af0d2bf0050426 (patch) | |
tree | 5fb10ae366b987db09e4ddb4bc3ba0f75404ad08 /packages/website/ts/components/send_button.tsx | |
parent | b5fd3c72a08aaa6957917d74c333387a16edf66b (diff) | |
download | dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.gz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.bz2 dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.lz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.xz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.zst dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.zip |
Update dependency packages
Diffstat (limited to 'packages/website/ts/components/send_button.tsx')
-rw-r--r-- | packages/website/ts/components/send_button.tsx | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/packages/website/ts/components/send_button.tsx b/packages/website/ts/components/send_button.tsx deleted file mode 100644 index 27438e5d5..000000000 --- a/packages/website/ts/components/send_button.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { BigNumber, logUtils } from '@0x/utils'; -import * as _ from 'lodash'; -import RaisedButton from 'material-ui/RaisedButton'; -import * as React from 'react'; -import { Blockchain } from 'ts/blockchain'; -import { SendDialog } from 'ts/components/dialogs/send_dialog'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { BlockchainCallErrs, Token } from 'ts/types'; -import { errorReporter } from 'ts/utils/error_reporter'; -import { utils } from 'ts/utils/utils'; - -interface SendButtonProps { - userAddress: string; - networkId: number; - asset: Token | 'ETH'; - dispatcher: Dispatcher; - blockchain: Blockchain; - onError: () => void; - lastForceTokenStateRefetch: number; - refetchTokenStateAsync: (tokenAddress: string) => Promise<void>; -} - -interface SendButtonState { - isSendDialogVisible: boolean; - isSending: boolean; -} - -export class SendButton extends React.Component<SendButtonProps, SendButtonState> { - public constructor(props: SendButtonProps) { - super(props); - this.state = { - isSendDialogVisible: false, - isSending: false, - }; - } - public render(): React.ReactNode { - const labelStyle = this.state.isSending ? { fontSize: 10 } : {}; - return ( - <div> - <RaisedButton - style={{ width: '100%' }} - labelStyle={labelStyle} - disabled={this.state.isSending} - label={this.state.isSending ? 'Sending...' : 'Send'} - onClick={this._toggleSendDialog.bind(this)} - /> - <SendDialog - blockchain={this.props.blockchain} - userAddress={this.props.userAddress} - networkId={this.props.networkId} - isOpen={this.state.isSendDialogVisible} - onComplete={this._onSendAmountSelectedAsync.bind(this)} - onCancelled={this._toggleSendDialog.bind(this)} - asset={this.props.asset} - lastForceTokenStateRefetch={this.props.lastForceTokenStateRefetch} - /> - </div> - ); - } - private _toggleSendDialog(): void { - this.setState({ - isSendDialogVisible: !this.state.isSendDialogVisible, - }); - } - private async _onSendAmountSelectedAsync(recipient: string, value: BigNumber): Promise<void> { - this.setState({ - isSending: true, - }); - this._toggleSendDialog(); - try { - if (this.props.asset === 'ETH') { - await this.props.blockchain.sendAsync(recipient, value); - } else { - const token = this.props.asset; - await this.props.blockchain.transferAsync(token, recipient, value); - await this.props.refetchTokenStateAsync(token.address); - } - } catch (err) { - const errMsg = `${err}`; - if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) { - this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true); - return; - } else if (!utils.didUserDenyWeb3Request(errMsg)) { - logUtils.log(`Unexpected error encountered: ${err}`); - logUtils.log(err.stack); - this.props.onError(); - errorReporter.report(err); - } - } - this.setState({ - isSending: false, - }); - } -} |