1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-13 20:08:56 +00:00

update "rippleGetAccountInfo" and "ethereumGetAccountInfo" params

This commit is contained in:
Szymon Lesisz 2019-01-04 14:32:14 +01:00
parent acd2c0f4c6
commit 4f1ba157e1
4 changed files with 13 additions and 9 deletions

View File

@ -120,15 +120,16 @@ export const initWeb3 = (network: string, urlIndex: number = 0): PromiseAction<W
web3.currentProvider.on('error', onEnd);
});
export const discoverAccount = (address: string, network: string): PromiseAction<EthereumAccount> => async (dispatch: Dispatch): Promise<EthereumAccount> => {
export const discoverAccount = (descriptor: string, network: string): PromiseAction<EthereumAccount> => async (dispatch: Dispatch): Promise<EthereumAccount> => {
const instance: Web3Instance = await dispatch(initWeb3(network));
const balance = await instance.web3.eth.getBalance(address);
const nonce = await instance.web3.eth.getTransactionCount(address);
const balance = await instance.web3.eth.getBalance(descriptor);
const nonce = await instance.web3.eth.getTransactionCount(descriptor);
return {
address,
descriptor,
transactions: 0,
block: 0,
balance: EthereumjsUnits.convert(balance, 'wei', 'ether'),
availableBalance: EthereumjsUnits.convert(balance, 'wei', 'ether'),
nonce,
};
};

View File

@ -16,14 +16,15 @@ import type { NetworkToken } from 'reducers/LocalStorageReducer';
import * as Web3Actions from 'actions/Web3Actions';
import * as AccountsActions from 'actions/AccountsActions';
export const discoverAccount = (device: TrezorDevice, address: string, network: string): PromiseAction<EthereumAccount> => async (dispatch: Dispatch): Promise<EthereumAccount> => {
export const discoverAccount = (device: TrezorDevice, descriptor: string, network: string): PromiseAction<EthereumAccount> => async (dispatch: Dispatch): Promise<EthereumAccount> => {
// get data from connect
const txs = await TrezorConnect.ethereumGetAccountInfo({
account: {
address,
descriptor,
block: 0,
transactions: 0,
balance: '0',
availableBalance: '0',
nonce: 0,
},
coin: network,
@ -34,12 +35,13 @@ export const discoverAccount = (device: TrezorDevice, address: string, network:
}
// blockbook web3 fallback
const web3account = await dispatch(Web3Actions.discoverAccount(address, network));
const web3account = await dispatch(Web3Actions.discoverAccount(descriptor, network));
return {
address,
descriptor,
transactions: txs.payload.transactions,
block: txs.payload.block,
balance: web3account.balance,
availableBalance: web3account.balance,
nonce: web3account.nonce,
};
};

View File

@ -559,6 +559,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
blockHeight: 0,
blockHash: undefined,
timestamp: undefined,
};
dispatch(BlockchainActions.onNotification({

View File

@ -66,7 +66,7 @@ export const discoverAccount = (device: TrezorDevice, discoveryProcess: Discover
deviceID: device.features ? device.features.device_id : '0',
deviceState: device.state || '0',
accountPath: account.path || [],
descriptor: account.address,
descriptor: account.descriptor,
balance: toDecimalAmount(account.balance, network.decimals),
availableBalance: toDecimalAmount(account.availableBalance, network.decimals),