WIP for sending ether from portal (works)

This commit is contained in:
fragosti
2018-07-19 04:11:44 -07:00
parent 3a18c249f5
commit dead04dce8
7 changed files with 82 additions and 38 deletions

View File

@@ -12,7 +12,7 @@ import { utils } from 'ts/utils/utils';
interface SendButtonProps {
userAddress: string;
networkId: number;
token: Token;
asset: Token | 'ETH';
dispatcher: Dispatcher;
blockchain: Blockchain;
onError: () => void;
@@ -51,7 +51,7 @@ export class SendButton extends React.Component<SendButtonProps, SendButtonState
isOpen={this.state.isSendDialogVisible}
onComplete={this._onSendAmountSelectedAsync.bind(this)}
onCancelled={this._toggleSendDialog.bind(this)}
token={this.props.token}
asset={this.props.asset}
lastForceTokenStateRefetch={this.props.lastForceTokenStateRefetch}
/>
</div>
@@ -67,10 +67,14 @@ export class SendButton extends React.Component<SendButtonProps, SendButtonState
isSending: true,
});
this._toggleSendDialog();
const token = this.props.token;
try {
await this.props.blockchain.transferAsync(token, recipient, value);
await this.props.refetchTokenStateAsync(token.address);
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)) {