mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
added (commented) NONCE in Sendform
This commit is contained in:
parent
b8b8ed6a34
commit
9125fbcd61
@ -83,6 +83,9 @@ export type SendFormAction = SendTxAction | {
|
|||||||
} | {
|
} | {
|
||||||
type: typeof SEND.GAS_LIMIT_CHANGE,
|
type: typeof SEND.GAS_LIMIT_CHANGE,
|
||||||
state: State
|
state: State
|
||||||
|
} | {
|
||||||
|
type: typeof SEND.NONCE_CHANGE,
|
||||||
|
state: State
|
||||||
} | {
|
} | {
|
||||||
type: typeof SEND.DATA_CHANGE,
|
type: typeof SEND.DATA_CHANGE,
|
||||||
state: State
|
state: State
|
||||||
@ -182,6 +185,7 @@ export const init = (): ThunkAction => {
|
|||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
|
|
||||||
const accountState: ?AccountState = getState().abstractAccount;
|
const accountState: ?AccountState = getState().abstractAccount;
|
||||||
|
if (!accountState) return;
|
||||||
|
|
||||||
const { location } = getState().router;
|
const { location } = getState().router;
|
||||||
const urlParams: RouterLocationState = location.state;
|
const urlParams: RouterLocationState = location.state;
|
||||||
@ -196,11 +200,8 @@ export const init = (): ThunkAction => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check if there are some unfinished tx in localStorage
|
// TODO: check if there are some unfinished tx in localStorage
|
||||||
const { config } = getState().localStorage;
|
|
||||||
if (!config) return;
|
|
||||||
|
|
||||||
const coin: ?Coin = config.coins.find(c => c.network === urlParams.network);
|
const coin: Coin = accountState.coin;
|
||||||
if (!coin) return;
|
|
||||||
|
|
||||||
const gasPrice: BigNumber = new BigNumber( EthereumjsUnits.convert(web3instance.gasPrice, 'wei', 'gwei') ) || new BigNumber(coin.defaultGasPrice);
|
const gasPrice: BigNumber = new BigNumber( EthereumjsUnits.convert(web3instance.gasPrice, 'wei', 'gwei') ) || new BigNumber(coin.defaultGasPrice);
|
||||||
const gasLimit: string = coin.defaultGasLimit.toString();
|
const gasLimit: string = coin.defaultGasLimit.toString();
|
||||||
@ -252,7 +253,7 @@ export const validation = (): ThunkAction => {
|
|||||||
const warnings: {[k: string]: string} = {};
|
const warnings: {[k: string]: string} = {};
|
||||||
const infos: {[k: string]: string} = {};
|
const infos: {[k: string]: string} = {};
|
||||||
|
|
||||||
if (!state.untouched) {
|
if (state.untouched) return;
|
||||||
// valid address
|
// valid address
|
||||||
if (state.touched.address) {
|
if (state.touched.address) {
|
||||||
|
|
||||||
@ -334,7 +335,7 @@ export const validation = (): ThunkAction => {
|
|||||||
const gl: BigNumber = new BigNumber(state.gasLimit);
|
const gl: BigNumber = new BigNumber(state.gasLimit);
|
||||||
if (gl.lessThan(1)) {
|
if (gl.lessThan(1)) {
|
||||||
errors.gasLimit = 'Gas limit is too low';
|
errors.gasLimit = 'Gas limit is too low';
|
||||||
} else if (gl.lessThan(1000)) {
|
} else if (gl.lessThan( state.selectedCurrency !== state.coinSymbol ? accountState.coin.defaultGasLimitTokens : accountState.coin.defaultGasLimit )) {
|
||||||
warnings.gasLimit = 'Gas limit is below recommended';
|
warnings.gasLimit = 'Gas limit is below recommended';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -348,14 +349,21 @@ export const validation = (): ThunkAction => {
|
|||||||
errors.gasPrice = 'Gas price is not a number';
|
errors.gasPrice = 'Gas price is not a number';
|
||||||
} else {
|
} else {
|
||||||
const gp: BigNumber = new BigNumber(state.gasPrice);
|
const gp: BigNumber = new BigNumber(state.gasPrice);
|
||||||
if (gp.greaterThan(100)) {
|
if (gp.greaterThan(1000)) {
|
||||||
errors.gasPrice = 'Gas price is too high';
|
warnings.gasPrice = 'Gas price is too high';
|
||||||
} else if (gp.lessThanOrEqualTo('0')) {
|
} else if (gp.lessThanOrEqualTo('0')) {
|
||||||
errors.gasPrice = 'Gas price is too low';
|
errors.gasPrice = 'Gas price is too low';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// valid nonce
|
||||||
|
if (state.touched.nonce) {
|
||||||
|
if (state.nonce.length < 1) {
|
||||||
|
errors.nonce = 'Nonce is not set';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// valid data
|
// valid data
|
||||||
if (state.touched.data && state.data.length > 0) {
|
if (state.touched.data && state.data.length > 0) {
|
||||||
const re = /^[0-9A-Fa-f]+$/g;
|
const re = /^[0-9A-Fa-f]+$/g;
|
||||||
@ -373,8 +381,6 @@ export const validation = (): ThunkAction => {
|
|||||||
warnings,
|
warnings,
|
||||||
infos
|
infos
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,6 +733,27 @@ export const onGasLimitChange = (gasLimit: string): ThunkAction => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const onNonceChange = (nonce: string): AsyncAction => {
|
||||||
|
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
|
const currentState: State = getState().sendForm;
|
||||||
|
const touched = { ...currentState.touched };
|
||||||
|
touched.nonce = true;
|
||||||
|
|
||||||
|
const state: State = {
|
||||||
|
...currentState,
|
||||||
|
untouched: false,
|
||||||
|
touched,
|
||||||
|
nonce,
|
||||||
|
};
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: SEND.NONCE_CHANGE,
|
||||||
|
state
|
||||||
|
});
|
||||||
|
dispatch( validation() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const onDataChange = (data: string): AsyncAction => {
|
export const onDataChange = (data: string): AsyncAction => {
|
||||||
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
const currentState: State = getState().sendForm;
|
const currentState: State = getState().sendForm;
|
||||||
@ -948,6 +975,7 @@ export default {
|
|||||||
updateFeeLevels,
|
updateFeeLevels,
|
||||||
onGasPriceChange,
|
onGasPriceChange,
|
||||||
onGasLimitChange,
|
onGasLimitChange,
|
||||||
|
onNonceChange,
|
||||||
onDataChange,
|
onDataChange,
|
||||||
onSend,
|
onSend,
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ export const CURRENCY_CHANGE: 'send__currency_change' = 'send__currency_change';
|
|||||||
export const FEE_LEVEL_CHANGE: 'send__fee_level_change' = 'send__fee_level_change';
|
export const FEE_LEVEL_CHANGE: 'send__fee_level_change' = 'send__fee_level_change';
|
||||||
export const GAS_PRICE_CHANGE: 'send__gas_price_change' = 'send__gas_price_change';
|
export const GAS_PRICE_CHANGE: 'send__gas_price_change' = 'send__gas_price_change';
|
||||||
export const GAS_LIMIT_CHANGE: 'send__gas_limit_change' = 'send__gas_limit_change';
|
export const GAS_LIMIT_CHANGE: 'send__gas_limit_change' = 'send__gas_limit_change';
|
||||||
|
export const NONCE_CHANGE: 'send__nonce_change' = 'send__nonce_change';
|
||||||
export const UPDATE_FEE_LEVELS: 'send__update_fee_levels' = 'send__update_fee_levels';
|
export const UPDATE_FEE_LEVELS: 'send__update_fee_levels' = 'send__update_fee_levels';
|
||||||
export const DATA_CHANGE: 'send__data_change' = 'send__data_change';
|
export const DATA_CHANGE: 'send__data_change' = 'send__data_change';
|
||||||
export const SEND: 'send__submit' = 'send__submit';
|
export const SEND: 'send__submit' = 'send__submit';
|
||||||
|
@ -17,6 +17,7 @@ const AdvancedForm = (props: Props) => {
|
|||||||
selectedCurrency,
|
selectedCurrency,
|
||||||
gasPrice,
|
gasPrice,
|
||||||
gasLimit,
|
gasLimit,
|
||||||
|
nonce,
|
||||||
data,
|
data,
|
||||||
errors,
|
errors,
|
||||||
warnings,
|
warnings,
|
||||||
@ -28,6 +29,7 @@ const AdvancedForm = (props: Props) => {
|
|||||||
toggleAdvanced,
|
toggleAdvanced,
|
||||||
onGasPriceChange,
|
onGasPriceChange,
|
||||||
onGasLimitChange,
|
onGasLimitChange,
|
||||||
|
onNonceChange,
|
||||||
onDataChange
|
onDataChange
|
||||||
} = props.sendFormActions;
|
} = props.sendFormActions;
|
||||||
|
|
||||||
@ -68,6 +70,27 @@ const AdvancedForm = (props: Props) => {
|
|||||||
<div className="advanced-container opened">
|
<div className="advanced-container opened">
|
||||||
<a className="advanced" onClick={ toggleAdvanced }>Advanced settings</a>
|
<a className="advanced" onClick={ toggleAdvanced }>Advanced settings</a>
|
||||||
<div className="row gas-row">
|
<div className="row gas-row">
|
||||||
|
{/* <div className="column nonce">
|
||||||
|
<label>
|
||||||
|
Nonce
|
||||||
|
<Tooltip
|
||||||
|
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
|
||||||
|
overlay={ gasLimitTooltip }
|
||||||
|
placement="top">
|
||||||
|
<span className="what-is-it"></span>
|
||||||
|
</Tooltip>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
autoComplete="off"
|
||||||
|
autoCorrect="off"
|
||||||
|
autoCapitalize="off"
|
||||||
|
spellCheck="false"
|
||||||
|
value={ nonce }
|
||||||
|
onChange={ event => onNonceChange(event.target.value) } />
|
||||||
|
{ errors.nonce ? (<span className="error">{ errors.nonce }</span>) : null }
|
||||||
|
{ warnings.nonce ? (<span className="warning">{ warnings.nonce }</span>) : null }
|
||||||
|
</div> */}
|
||||||
<div className="column">
|
<div className="column">
|
||||||
<label>
|
<label>
|
||||||
Gas limit
|
Gas limit
|
||||||
|
@ -157,6 +157,7 @@ export default (state: State = initialState, action: Action): State => {
|
|||||||
case SEND.UPDATE_FEE_LEVELS :
|
case SEND.UPDATE_FEE_LEVELS :
|
||||||
case SEND.GAS_PRICE_CHANGE :
|
case SEND.GAS_PRICE_CHANGE :
|
||||||
case SEND.GAS_LIMIT_CHANGE :
|
case SEND.GAS_LIMIT_CHANGE :
|
||||||
|
case SEND.NONCE_CHANGE :
|
||||||
case SEND.DATA_CHANGE :
|
case SEND.DATA_CHANGE :
|
||||||
return action.state;
|
return action.state;
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@
|
|||||||
bottom: 6px;
|
bottom: 6px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: @color_error_primary;
|
color: @color_error_primary;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
@ -255,6 +256,11 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
padding-right: 20px;
|
padding-right: 20px;
|
||||||
|
|
||||||
|
&.nonce {
|
||||||
|
width: 100px;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
padding-right: 0px;
|
padding-right: 0px;
|
||||||
}
|
}
|
||||||
@ -264,6 +270,7 @@
|
|||||||
.info {
|
.info {
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: -17px;
|
bottom: -17px;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user