mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-08 09:13:41 +00:00
816ce3180f
* Update account view routing * Temporarily add unicode character to translated strings for testing * Temporarily select add unicode to all untranslated strings * Format changes * Add all english translations for /account & /generate * Add the rest of the english translations * Add a few more missing translations * Update en translations * Get selectedLanguage from localstorage instead of redux sttate * Update snapshots * Add missing translation keys & Update translate functs & change variable prefix * translate all markdown strings & remove old translation strings * Update snapshot * Add a few more translation strs * Move raw strings being translated into json * All translation keys are now Uppercase * Fix up the last few translations * Update snapshot * Uppercase de translation strings * Bring back shapeshift logo on swap * Fix contracts tab translations * Fix a few more translations * Fix translations * remove debugging stuff * Update snapshots * Use react.fragment as markdown root renderer * Seperate markdown translations into their own function * Clean up translation functions * Clean up translation functions * Update snapshot * Fix some broken translation strings * Add prettier ignore file
103 lines
3.3 KiB
TypeScript
103 lines
3.3 KiB
TypeScript
import translate from 'translations';
|
|
import { getTransactionFields, makeTransaction } from 'libs/transaction';
|
|
import { OfflineBroadcast } from './OfflineBroadcast';
|
|
import { OnlineSend } from './OnlineSend';
|
|
import { addHexPrefix } from 'ethereumjs-util';
|
|
import { getWalletType, IWalletType } from 'selectors/wallet';
|
|
import React, { Component } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { AppState } from 'reducers';
|
|
import { ConfirmationModal } from 'components/ConfirmationModal';
|
|
import { TextArea } from 'components/ui';
|
|
import { getSerializedTransaction } from 'selectors/transaction';
|
|
|
|
export interface CallbackProps {
|
|
disabled: boolean;
|
|
onClick(): void;
|
|
}
|
|
|
|
interface StateProps {
|
|
walletType: IWalletType;
|
|
serializedTransaction: AppState['transaction']['sign']['local']['signedTransaction'];
|
|
}
|
|
|
|
interface OwnProps {
|
|
onlyTransactionParameters?: boolean;
|
|
toggleDisabled?: boolean;
|
|
Modal: typeof ConfirmationModal;
|
|
withProps(props: CallbackProps): React.ReactElement<any> | null;
|
|
}
|
|
|
|
const getStringifiedTx = (serializedTransaction: Buffer) =>
|
|
JSON.stringify(getTransactionFields(makeTransaction(serializedTransaction)), null, 2);
|
|
|
|
type Props = StateProps & OwnProps;
|
|
|
|
class SendButtonFactoryClass extends Component<Props> {
|
|
public render() {
|
|
const {
|
|
onlyTransactionParameters,
|
|
serializedTransaction,
|
|
toggleDisabled,
|
|
walletType
|
|
} = this.props;
|
|
const columnSize = onlyTransactionParameters ? 12 : 6;
|
|
|
|
/* Left and right transaction comparision boxes, only displayed when a serialized transaction
|
|
exists in state */
|
|
|
|
// shows the json representation of the transaction
|
|
const leftTxCompare = serializedTransaction && (
|
|
<div className={`col-sm-${columnSize}`}>
|
|
<label>{walletType.isWeb3Wallet ? 'Transaction Parameters' : translate('SEND_RAW')}</label>
|
|
<TextArea value={getStringifiedTx(serializedTransaction)} rows={4} readOnly={true} />
|
|
</div>
|
|
);
|
|
|
|
// shows the serialized representation of the transaction
|
|
// "onlyTransactionParameters" used in broadcast tx so the same serialized tx isnt redundantly
|
|
// displayed
|
|
const rightTxCompare = serializedTransaction &&
|
|
!onlyTransactionParameters && (
|
|
<div className="col-sm-6">
|
|
<label>
|
|
{walletType.isWeb3Wallet
|
|
? 'Serialized Transaction Parameters'
|
|
: translate('SEND_SIGNED')}
|
|
</label>
|
|
<TextArea
|
|
value={addHexPrefix(serializedTransaction.toString('hex'))}
|
|
rows={4}
|
|
readOnly={true}
|
|
/>
|
|
</div>
|
|
);
|
|
|
|
const shouldDisplayOnlineSend = toggleDisabled || serializedTransaction;
|
|
|
|
return (
|
|
<>
|
|
{leftTxCompare}
|
|
{rightTxCompare}
|
|
<OfflineBroadcast />
|
|
{shouldDisplayOnlineSend && (
|
|
<OnlineSend
|
|
withOnClick={({ onClick }) =>
|
|
this.props.withProps({
|
|
disabled: !!(toggleDisabled && !serializedTransaction),
|
|
onClick
|
|
})
|
|
}
|
|
Modal={this.props.Modal}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
}
|
|
|
|
export const SendButtonFactory = connect((state: AppState) => ({
|
|
walletType: getWalletType(state),
|
|
serializedTransaction: getSerializedTransaction(state)
|
|
}))(SendButtonFactoryClass);
|