mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-03 21:00:55 +00:00
update "rippleGetAccountInfo" and "ethereumGetAccountInfo" params
This commit is contained in:
parent
acd2c0f4c6
commit
4f1ba157e1
@ -120,15 +120,16 @@ export const initWeb3 = (network: string, urlIndex: number = 0): PromiseAction<W
|
|||||||
web3.currentProvider.on('error', onEnd);
|
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 instance: Web3Instance = await dispatch(initWeb3(network));
|
||||||
const balance = await instance.web3.eth.getBalance(address);
|
const balance = await instance.web3.eth.getBalance(descriptor);
|
||||||
const nonce = await instance.web3.eth.getTransactionCount(address);
|
const nonce = await instance.web3.eth.getTransactionCount(descriptor);
|
||||||
return {
|
return {
|
||||||
address,
|
descriptor,
|
||||||
transactions: 0,
|
transactions: 0,
|
||||||
block: 0,
|
block: 0,
|
||||||
balance: EthereumjsUnits.convert(balance, 'wei', 'ether'),
|
balance: EthereumjsUnits.convert(balance, 'wei', 'ether'),
|
||||||
|
availableBalance: EthereumjsUnits.convert(balance, 'wei', 'ether'),
|
||||||
nonce,
|
nonce,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -16,14 +16,15 @@ import type { NetworkToken } from 'reducers/LocalStorageReducer';
|
|||||||
import * as Web3Actions from 'actions/Web3Actions';
|
import * as Web3Actions from 'actions/Web3Actions';
|
||||||
import * as AccountsActions from 'actions/AccountsActions';
|
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
|
// get data from connect
|
||||||
const txs = await TrezorConnect.ethereumGetAccountInfo({
|
const txs = await TrezorConnect.ethereumGetAccountInfo({
|
||||||
account: {
|
account: {
|
||||||
address,
|
descriptor,
|
||||||
block: 0,
|
block: 0,
|
||||||
transactions: 0,
|
transactions: 0,
|
||||||
balance: '0',
|
balance: '0',
|
||||||
|
availableBalance: '0',
|
||||||
nonce: 0,
|
nonce: 0,
|
||||||
},
|
},
|
||||||
coin: network,
|
coin: network,
|
||||||
@ -34,12 +35,13 @@ export const discoverAccount = (device: TrezorDevice, address: string, network:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// blockbook web3 fallback
|
// blockbook web3 fallback
|
||||||
const web3account = await dispatch(Web3Actions.discoverAccount(address, network));
|
const web3account = await dispatch(Web3Actions.discoverAccount(descriptor, network));
|
||||||
return {
|
return {
|
||||||
address,
|
descriptor,
|
||||||
transactions: txs.payload.transactions,
|
transactions: txs.payload.transactions,
|
||||||
block: txs.payload.block,
|
block: txs.payload.block,
|
||||||
balance: web3account.balance,
|
balance: web3account.balance,
|
||||||
|
availableBalance: web3account.balance,
|
||||||
nonce: web3account.nonce,
|
nonce: web3account.nonce,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -559,6 +559,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
|
|||||||
|
|
||||||
blockHeight: 0,
|
blockHeight: 0,
|
||||||
blockHash: undefined,
|
blockHash: undefined,
|
||||||
|
timestamp: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatch(BlockchainActions.onNotification({
|
dispatch(BlockchainActions.onNotification({
|
||||||
|
@ -66,7 +66,7 @@ export const discoverAccount = (device: TrezorDevice, discoveryProcess: Discover
|
|||||||
deviceID: device.features ? device.features.device_id : '0',
|
deviceID: device.features ? device.features.device_id : '0',
|
||||||
deviceState: device.state || '0',
|
deviceState: device.state || '0',
|
||||||
accountPath: account.path || [],
|
accountPath: account.path || [],
|
||||||
descriptor: account.address,
|
descriptor: account.descriptor,
|
||||||
|
|
||||||
balance: toDecimalAmount(account.balance, network.decimals),
|
balance: toDecimalAmount(account.balance, network.decimals),
|
||||||
availableBalance: toDecimalAmount(account.availableBalance, network.decimals),
|
availableBalance: toDecimalAmount(account.availableBalance, network.decimals),
|
||||||
|
Loading…
Reference in New Issue
Block a user