mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
change blockchain/web3 "estimateGasLimit" to return string
This commit is contained in:
parent
b36b9667e4
commit
51253665be
@ -83,9 +83,12 @@ export const getGasPrice = (network: string, defaultGasPrice: number): PromiseAc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const estimateGasLimit = (network: string, data: string, value: string, gasPrice: string): PromiseAction<number> => async (dispatch: Dispatch, getState: GetState): Promise<number> => {
|
export const estimateGasLimit = (network: string, data: string, value: string, gasPrice: string): PromiseAction<string> => async (dispatch: Dispatch): Promise<string> => dispatch(Web3Actions.estimateGasLimit(network, {
|
||||||
return await dispatch( Web3Actions.estimateGasLimit(network, { to: '', data, value, gasPrice }) );
|
to: '',
|
||||||
}
|
data,
|
||||||
|
value,
|
||||||
|
gasPrice,
|
||||||
|
}));
|
||||||
|
|
||||||
export const onBlockMined = (coinInfo: any): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
export const onBlockMined = (coinInfo: any): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
// incoming "coinInfo" from TrezorConnect is CoinInfo | EthereumNetwork type
|
// incoming "coinInfo" from TrezorConnect is CoinInfo | EthereumNetwork type
|
||||||
|
@ -279,16 +279,20 @@ export const updateGasPrice = (network: string): PromiseAction<void> => async (d
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const estimateGasLimit = (network: string, options: EstimateGasOptions): PromiseAction<number> => async (dispatch: Dispatch, getState: GetState): Promise<number> => {
|
export const estimateGasLimit = (network: string, $options: EstimateGasOptions): PromiseAction<string> => async (dispatch: Dispatch): Promise<string> => {
|
||||||
const instance = await dispatch(initWeb3(network));
|
const instance = await dispatch(initWeb3(network));
|
||||||
// TODO: allow data starting with 0x ...
|
// TODO: allow data starting with 0x ...
|
||||||
options.to = '0x0000000000000000000000000000000000000000';
|
const data = `0x${$options.data.length % 2 === 0 ? $options.data : `0${$options.data}`}`;
|
||||||
options.data = `0x${options.data.length % 2 === 0 ? options.data : `0${options.data}`}`;
|
const options = {
|
||||||
options.value = instance.web3.utils.toHex( EthereumjsUnits.convert(options.value || '0', 'ether', 'wei') );
|
...$options,
|
||||||
options.gasPrice = instance.web3.utils.toHex( EthereumjsUnits.convert(options.gasPrice, 'gwei', 'wei') );
|
to: '0x0000000000000000000000000000000000000000',
|
||||||
|
data,
|
||||||
|
value: instance.web3.utils.toHex(EthereumjsUnits.convert($options.value || '0', 'ether', 'wei')),
|
||||||
|
gasPrice: instance.web3.utils.toHex(EthereumjsUnits.convert($options.gasPrice, 'gwei', 'wei')),
|
||||||
|
};
|
||||||
|
|
||||||
const limit = await instance.web3.eth.estimateGas(options);
|
const limit = await instance.web3.eth.estimateGas(options);
|
||||||
return limit;
|
return limit.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const disconnect = (coinInfo: any): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
export const disconnect = (coinInfo: any): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
||||||
|
Loading…
Reference in New Issue
Block a user