refactoring Account object to coin specific

pull/284/head
Szymon Lesisz 5 years ago
parent 350d71521e
commit 31e3c7a9a2

@ -4,59 +4,13 @@ import * as ACCOUNT from 'actions/constants/account';
import type { Action } from 'flowtype';
import type { Account, State } from 'reducers/AccountsReducer';
export type AccountFromStorageAction = {
export type AccountAction = {
type: typeof ACCOUNT.FROM_STORAGE,
payload: State
}
export type AccountCreateAction = {
type: typeof ACCOUNT.CREATE,
payload: Account,
}
export type AccountUpdateAction = {
type: typeof ACCOUNT.UPDATE,
} | {
type: typeof ACCOUNT.CREATE | typeof ACCOUNT.UPDATE,
payload: Account,
}
export type AccountSetBalanceAction = {
type: typeof ACCOUNT.SET_BALANCE,
address: string,
network: string,
deviceState: string,
balance: string
}
export type AccountSetNonceAction = {
type: typeof ACCOUNT.SET_NONCE,
address: string,
network: string,
deviceState: string,
nonce: number
}
export type AccountAction =
AccountFromStorageAction
| AccountCreateAction
| AccountUpdateAction
| AccountSetBalanceAction
| AccountSetNonceAction;
export const setBalance = (address: string, network: string, deviceState: string, balance: string): Action => ({
type: ACCOUNT.SET_BALANCE,
address,
network,
deviceState,
balance,
});
export const setNonce = (address: string, network: string, deviceState: string, nonce: number): Action => ({
type: ACCOUNT.SET_NONCE,
address,
network,
deviceState,
nonce,
});
};
export const update = (account: Account): Action => ({
type: ACCOUNT.UPDATE,

@ -63,7 +63,7 @@ const findTokens = (accounts: Array<Account>, tokens: Array<Token>): Array<Token
const findDiscovery = (devices: Array<TrezorDevice>, discovery: Array<Discovery>): Array<Discovery> => devices.reduce((arr, dev) => arr.concat(discovery.filter(d => d.deviceState === dev.state && d.completed)), []);
const findPendingTxs = (accounts: Array<Account>, pending: Array<Transaction>): Array<Transaction> => accounts.reduce((result, account) => result.concat(pending.filter(p => p.address === account.address && p.network === account.network)), []);
const findPendingTxs = (accounts: Array<Account>, pending: Array<Transaction>): Array<Transaction> => accounts.reduce((result, account) => result.concat(pending.filter(p => p.address === account.descriptor && p.network === account.network)), []);
export const save = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
const devices: Array<TrezorDevice> = getState().devices.filter(d => d.features && d.remember === true);

@ -44,7 +44,7 @@ export const loadEthereumDraftTransaction = (): PayloadAction<?EthereumSendFormS
if (state.currency !== state.networkSymbol) {
const { account, tokens } = getState().selectedAccount;
if (!account) return null;
const token = findToken(tokens, account.address, state.currency, account.deviceState);
const token = findToken(tokens, account.descriptor, state.currency, account.deviceState);
if (!token) {
storageUtils.remove(TYPE, key);
return null;

@ -76,7 +76,7 @@ export const add = (token: NetworkToken, account: Account): AsyncAction => async
name: token.name,
symbol: token.symbol,
address: token.address,
ethAddress: account.address,
ethAddress: account.descriptor,
decimals: token.decimals,
balance: '0',
};
@ -87,7 +87,7 @@ export const add = (token: NetworkToken, account: Account): AsyncAction => async
});
const tokenBalance = await dispatch(BlockchainActions.getTokenBalance(tkn));
dispatch(setBalance(token.address, account.address, tokenBalance));
dispatch(setBalance(token.address, account.descriptor, tokenBalance));
};
export const remove = (token: Token): Action => ({

@ -193,9 +193,10 @@ export const getTxInput = (): PromiseAction<void> => async (dispatch: Dispatch):
export const updateAccount = (account: Account, newAccount: EthereumAccount, network: string): PromiseAction<void> => async (dispatch: Dispatch): Promise<void> => {
const instance: Web3Instance = await dispatch(initWeb3(network));
const balance = await instance.web3.eth.getBalance(account.address);
const nonce = await instance.web3.eth.getTransactionCount(account.address);
const balance = await instance.web3.eth.getBalance(account.descriptor);
const nonce = await instance.web3.eth.getTransactionCount(account.descriptor);
dispatch(AccountsActions.update({
networkType: 'ethereum',
...account,
...newAccount,
nonce,
@ -208,7 +209,7 @@ export const updateAccount = (account: Account, newAccount: EthereumAccount, net
};
export const updateAccountTokens = (account: Account): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
const tokens = getState().tokens.filter(t => t.network === account.network && t.ethAddress === account.address);
const tokens = getState().tokens.filter(t => t.network === account.network && t.ethAddress === account.descriptor);
tokens.forEach(async (token) => {
const balance = await dispatch(getTokenBalance(token));
// const newBalance: string = balance.dividedBy(Math.pow(10, token.decimals)).toString(10);

@ -85,7 +85,7 @@ export const estimateGasLimit = (network: string, data: string, value: string, g
};
export const subscribe = (network: string): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
const accounts: Array<string> = getState().accounts.filter(a => a.network === network).map(a => a.address); // eslint-disable-line no-unused-vars
const accounts: Array<string> = getState().accounts.filter(a => a.network === network).map(a => a.descriptor); // eslint-disable-line no-unused-vars
const response = await TrezorConnect.blockchainSubscribe({
accounts,
coin: network,
@ -129,7 +129,7 @@ export const onBlockMined = (network: string): PromiseAction<void> => async (dis
export const onNotification = (payload: $ElementType<BlockchainNotification, 'payload'>): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
const { notification } = payload;
const account = getState().accounts.find(a => a.address === notification.address);
const account = getState().accounts.find(a => a.descriptor === notification.address);
if (!account) return;
if (notification.status === 'pending') {

@ -8,13 +8,13 @@ import * as BlockchainActions from 'actions/ethereum/BlockchainActions';
import type {
PromiseAction,
Dispatch,
GetState,
TrezorDevice,
Network,
Account,
} from 'flowtype';
import type { Discovery } from 'reducers/DiscoveryReducer';
export type DiscoveryStartAction = {
type: typeof DISCOVERY.START,
networkType: 'ethereum',
@ -61,33 +61,38 @@ export const begin = (device: TrezorDevice, network: Network): PromiseAction<Dis
};
};
export const discoverAccount = (device: TrezorDevice, discoveryProcess: Discovery): PromiseAction<Account> => async (dispatch: Dispatch): Promise<Account> => {
export const discoverAccount = (device: TrezorDevice, discoveryProcess: Discovery): PromiseAction<Account> => async (dispatch: Dispatch, getState: GetState): Promise<Account> => {
const { config } = getState().localStorage;
const network = config.networks.find(c => c.shortcut === discoveryProcess.network);
if (!network) throw new Error('Discovery network not found');
const derivedKey = discoveryProcess.hdKey.derive(`m/${discoveryProcess.accountIndex}`);
const path = discoveryProcess.basePath.concat(discoveryProcess.accountIndex);
const publicAddress: string = EthereumjsUtil.publicToAddress(derivedKey.publicKey, true).toString('hex');
const ethAddress: string = EthereumjsUtil.toChecksumAddress(publicAddress);
const { network } = discoveryProcess;
// TODO: check if address was created before
const account = await dispatch(BlockchainActions.discoverAccount(device, ethAddress, network));
const account = await dispatch(BlockchainActions.discoverAccount(device, ethAddress, network.shortcut));
// const accountIsEmpty = account.transactions <= 0 && account.nonce <= 0 && account.balance === '0';
const empty = account.nonce <= 0 && account.balance === '0';
return {
imported: false,
index: discoveryProcess.accountIndex,
loaded: true,
network,
network: network.shortcut,
deviceID: device.features ? device.features.device_id : '0',
deviceState: device.state || '0',
addressPath: path,
address: ethAddress,
accountPath: path,
descriptor: ethAddress,
balance: account.balance,
availableBalance: account.balance,
sequence: account.nonce,
nonce: account.nonce,
block: account.block,
transactions: account.transactions,
empty,
networkType: 'ethereum',
nonce: account.nonce,
};
};

@ -76,7 +76,7 @@ export const observe = (prevState: ReducersState, action: Action): ThunkAction =
// make sure that this token is added into account
const { account, tokens } = getState().selectedAccount;
if (!account) return;
const token = findToken(tokens, account.address, currentState.sendFormEthereum.currency, account.deviceState);
const token = findToken(tokens, account.descriptor, currentState.sendFormEthereum.currency, account.deviceState);
if (!token) {
// token not found, re-init form
dispatch(init());
@ -456,7 +456,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
pending,
} = getState().selectedAccount;
if (!account || !network) return;
if (!account || account.networkType !== 'ethereum' || !network) return;
const currentState: State = getState().sendFormEthereum;
@ -466,8 +466,8 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
const txData = await dispatch(prepareEthereumTx({
network: network.shortcut,
token: isToken ? findToken(getState().tokens, account.address, currentState.currency, account.deviceState) : null,
from: account.address,
token: isToken ? findToken(getState().tokens, account.descriptor, currentState.currency, account.deviceState) : null,
from: account.descriptor,
to: currentState.address,
amount: currentState.amount,
data: currentState.data,
@ -487,7 +487,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
},
// useEmptyPassphrase: !selected.instance,
useEmptyPassphrase: selected.useEmptyPassphrase,
path: account.addressPath,
path: account.accountPath,
transaction: txData,
});
@ -533,10 +533,10 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
type: 'send',
status: 'pending',
confirmations: 0,
address: account.address,
address: account.descriptor,
inputs: [
{
addresses: [account.address],
addresses: [account.descriptor],
amount: currentState.amount,
fee,
total: currentState.total,

@ -114,7 +114,7 @@ export const recalculateTotalAmount = ($state: State): PayloadAction<State> => (
if (state.setMax) {
const pendingAmount = getPendingAmount(pending, state.currency, isToken);
if (isToken) {
const token = findToken(tokens, account.address, state.currency, account.deviceState);
const token = findToken(tokens, account.descriptor, state.currency, account.deviceState);
if (token) {
state.amount = new BigNumber(token.balance).minus(pendingAmount).toString(10);
}
@ -173,7 +173,7 @@ export const addressLabel = ($state: State): PayloadAction<State> => (dispatch:
if (!account || !network) return state;
const { address } = state;
const savedAccounts = getState().accounts.filter(a => a.address.toLowerCase() === address.toLowerCase());
const savedAccounts = getState().accounts.filter(a => a.descriptor.toLowerCase() === address.toLowerCase());
if (savedAccounts.length > 0) {
// check if found account belongs to this network
const currentNetworkAccount = savedAccounts.find(a => a.network === network.shortcut);
@ -221,7 +221,7 @@ export const amountValidation = ($state: State): PayloadAction<State> => (dispat
const pendingAmount: BigNumber = getPendingAmount(pending, state.currency, isToken);
if (isToken) {
const token = findToken(tokens, account.address, state.currency, account.deviceState);
const token = findToken(tokens, account.descriptor, state.currency, account.deviceState);
if (!token) return state;
const decimalRegExp = dynamicRegexp(parseInt(token.decimals, 0));
@ -304,7 +304,7 @@ export const nonceValidation = ($state: State): PayloadAction<State> => (dispatc
const {
account,
} = getState().selectedAccount;
if (!account) return state;
if (!account || account.networkType !== 'ethereum') return state;
const { nonce } = state;
if (nonce.length < 1) {

@ -16,7 +16,7 @@ import type {
const DECIMALS: number = 6;
export const subscribe = (network: string): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
const accounts: Array<string> = getState().accounts.filter(a => a.network === network).map(a => a.address);
const accounts: Array<string> = getState().accounts.filter(a => a.network === network).map(a => a.descriptor);
await TrezorConnect.blockchainSubscribe({
accounts,
coin: network,
@ -68,7 +68,7 @@ export const onBlockMined = (network: string): PromiseAction<void> => async (dis
export const onNotification = (payload: $ElementType<BlockchainNotification, 'payload'>): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
const { notification } = payload;
const account = getState().accounts.find(a => a.address === notification.address);
const account = getState().accounts.find(a => a.descriptor === notification.address);
if (!account) return;
if (notification.status === 'pending') {
@ -95,7 +95,7 @@ export const onNotification = (payload: $ElementType<BlockchainNotification, 'pa
const updatedAccount = await TrezorConnect.rippleGetAccountInfo({
account: {
address: account.address,
address: account.descriptor,
from: account.block,
history: false,
},
@ -104,10 +104,12 @@ export const onNotification = (payload: $ElementType<BlockchainNotification, 'pa
if (!updatedAccount.success) return;
dispatch(AccountsActions.update({
networkType: 'ripple',
...account,
balance: toDecimalAmount(updatedAccount.payload.balance, DECIMALS),
availableBalance: toDecimalAmount(updatedAccount.payload.availableBalance, DECIMALS),
block: updatedAccount.payload.block,
sequence: updatedAccount.payload.sequence,
reserve: '0',
}));
};

@ -60,19 +60,22 @@ export const discoverAccount = (device: TrezorDevice, discoveryProcess: Discover
const empty = account.sequence <= 0 && account.balance === '0';
return {
imported: false,
index: discoveryProcess.accountIndex,
loaded: true,
network: network.shortcut,
deviceID: device.features ? device.features.device_id : '0',
deviceState: device.state || '0',
addressPath: account.path || [],
address: account.address,
balance: toDecimalAmount(account.balance, 6),
availableBalance: toDecimalAmount(account.availableBalance, 6),
sequence: account.sequence,
nonce: account.sequence,
accountPath: account.path || [],
descriptor: account.address,
balance: toDecimalAmount(account.balance, network.decimals),
availableBalance: toDecimalAmount(account.availableBalance, network.decimals),
block: account.block,
transactions: account.transactions,
empty,
networkType: 'ripple',
sequence: account.sequence,
reserve: '0',
};
};

@ -173,7 +173,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
const selected: ?TrezorDevice = getState().wallet.selectedDevice;
if (!selected) return;
if (!account || !network) return;
if (!account || account.networkType !== 'ripple' || !network) return;
const blockchain = getState().blockchain.find(b => b.shortcut === account.network);
if (!blockchain) return;
@ -188,7 +188,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
state: selected.state,
},
useEmptyPassphrase: selected.useEmptyPassphrase,
path: account.addressPath,
path: account.accountPath,
transaction: {
fee: blockchain.fee, // Fee must be in the range of 10 to 10,000 drops
flags: 0x80000000,

@ -115,7 +115,7 @@ const addressValidation = ($state: State): PayloadAction<State> => (dispatch: Di
state.errors.address = 'Address is not set';
} else if (!AddressValidator.validate(address, 'XRP')) {
state.errors.address = 'Address is not valid';
} else if (address.toLowerCase() === account.address.toLowerCase()) {
} else if (address.toLowerCase() === account.descriptor.toLowerCase()) {
state.errors.address = 'Cannot send to myself';
}
return state;
@ -135,7 +135,7 @@ const addressLabel = ($state: State): PayloadAction<State> => (dispatch: Dispatc
if (!account || !network) return state;
const { address } = state;
const savedAccounts = getState().accounts.filter(a => a.address.toLowerCase() === address.toLowerCase());
const savedAccounts = getState().accounts.filter(a => a.descriptor.toLowerCase() === address.toLowerCase());
if (savedAccounts.length > 0) {
// check if found account belongs to this network
const currentNetworkAccount = savedAccounts.find(a => a.network === network.shortcut);

@ -45,7 +45,7 @@ const ConfirmAddress = (props: Props) => {
<P>Please compare your address on device with address shown bellow.</P>
</Header>
<Content>
<P>{ account.address }</P>
<P>{ account.descriptor }</P>
<Label>{ network.symbol } account #{ (account.index + 1) }</Label>
</Content>
</Wrapper>

@ -71,7 +71,7 @@ class ConfirmUnverifiedAddress extends PureComponent<Props> {
const { account, onCancel, showAddress } = this.props;
if (!account) return;
onCancel();
showAddress(account.addressPath);
showAddress(account.accountPath);
}
showUnverifiedAddress() {

@ -6,27 +6,35 @@ import * as WALLET from 'actions/constants/wallet';
import * as ACCOUNT from 'actions/constants/account';
import type { Action, TrezorDevice } from 'flowtype';
import type {
AccountSetBalanceAction,
AccountSetNonceAction,
} from 'actions/AccountsActions';
export type Account = {
loaded: boolean;
+network: string;
+deviceID: string;
+deviceState: string;
+index: number;
+addressPath: Array<number>;
+address: string;
balance: string;
availableBalance: string;
sequence: number;
nonce: number;
block: number;
transactions: number;
empty: boolean;
}
type AccountCommon = {
+imported: boolean,
+index: number,
+network: string, // network id (shortcut)
+deviceID: string, // empty for imported accounts
+deviceState: string, // empty for imported accounts
+accountPath: Array<number>, // empty for imported accounts
+descriptor: string, // address or xpub
balance: string,
availableBalance: string, // balance - pending
block: number, // last known (synchronized) block
empty: boolean, // account without transactions
transactions: number, // deprecated
};
export type Account = AccountCommon & {
networkType: 'ethereum',
nonce: number,
} | AccountCommon & {
networkType: 'ripple',
sequence: number,
reserve: string,
} | AccountCommon & {
networkType: 'bitcoin',
addressIndex: number,
};
export type State = Array<Account>;
@ -44,7 +52,7 @@ export const findDeviceAccounts = (state: State, device: TrezorDevice, network:
const createAccount = (state: State, account: Account): State => {
// TODO check with device_id
// check if account was created before
const exist: ?Account = state.find(a => a.address === account.address && a.network === account.network && a.deviceState === account.deviceState);
const exist: ?Account = state.find(a => a.descriptor === account.descriptor && a.network === account.network && a.deviceState === account.deviceState);
if (exist) {
return state;
}
@ -55,7 +63,6 @@ const createAccount = (state: State, account: Account): State => {
const removeAccounts = (state: State, device: TrezorDevice): State => state.filter(account => account.deviceState !== device.state);
const clear = (state: State, devices: Array<TrezorDevice>): State => {
let newState: State = [...state];
devices.forEach((d) => {
@ -65,29 +72,12 @@ const clear = (state: State, devices: Array<TrezorDevice>): State => {
};
const updateAccount = (state: State, account: Account): State => {
const index: number = state.findIndex(a => a.address === account.address && a.network === account.network && a.deviceState === account.deviceState);
const index: number = state.findIndex(a => a.descriptor === account.descriptor && a.network === account.network && a.deviceState === account.deviceState);
const newState: State = [...state];
newState[index] = account;
return newState;
};
const setBalance = (state: State, action: AccountSetBalanceAction): State => {
// const index: number = state.findIndex(account => account.address === action.address && account.network === action.network && account.deviceState === action.deviceState);
const index: number = state.findIndex(account => account.address === action.address && account.network === action.network);
const newState: State = [...state];
newState[index].loaded = true;
newState[index].balance = action.balance;
return newState;
};
const setNonce = (state: State, action: AccountSetNonceAction): State => {
const index: number = state.findIndex(account => account.address === action.address && account.network === action.network && account.deviceState === action.deviceState);
const newState: State = [...state];
newState[index].loaded = true;
newState[index].nonce = action.nonce;
return newState;
};
export default (state: State = initialState, action: Action): State => {
switch (action.type) {
case ACCOUNT.CREATE:
@ -108,11 +98,6 @@ export default (state: State = initialState, action: Action): State => {
case ACCOUNT.UPDATE:
return updateAccount(state, action.payload);
case ACCOUNT.SET_BALANCE:
return setBalance(state, action);
case ACCOUNT.SET_NONCE:
return setNonce(state, action);
case ACCOUNT.FROM_STORAGE:
return action.payload;

@ -27,17 +27,7 @@ const initialState: State = [];
// Helper for actions
export const findToken = (state: Array<Token>, address: string, symbol: string, deviceState: string): ?Token => state.find(t => t.ethAddress === address && t.symbol === symbol && t.deviceState === deviceState);
export const findAccountTokens = (state: Array<Token>, account: Account): Array<Token> => state.filter(t => t.ethAddress === account.address && t.network === account.network && t.deviceState === account.deviceState);
// const setBalance = (state: State, payload: any): State => {
// const newState: Array<Token> = [ ...state ];
// let index: number = state.findIndex(t => t.address === payload.address && t.ethAddress === payload.ethAddress);
// if (index >= 0) {
// newState[index].loaded = true;
// newState[index].balance = payload.balance;
// }
// return newState;
// }
export const findAccountTokens = (state: Array<Token>, account: Account): Array<Token> => state.filter(t => t.ethAddress === account.descriptor && t.network === account.network && t.deviceState === account.deviceState);
const create = (state: State, token: Token): State => {
const newState: State = [...state];

@ -86,7 +86,7 @@ export const getDiscoveryProcess = (state: State): ?Discovery => {
export const getAccountPendingTx = (pending: Array<Transaction>, account: ?Account): Array<Transaction> => {
const a = account;
if (!a) return [];
return pending.filter(p => p.network === a.network && p.address === a.address);
return pending.filter(p => p.network === a.network && p.address === a.descriptor);
};
export const getPendingSequence = (pending: Array<Transaction>): number => pending.reduce((value: number, tx: Transaction) => {
@ -104,7 +104,7 @@ export const getPendingAmount = (pending: Array<Transaction>, currency: string,
export const getAccountTokens = (state: State, account: ?Account): Array<Token> => {
const a = account;
if (!a) return [];
return state.tokens.filter(t => t.ethAddress === a.address && t.network === a.network && t.deviceState === a.deviceState);
return state.tokens.filter(t => t.ethAddress === a.descriptor && t.network === a.network && t.deviceState === a.deviceState);
};
export const getWeb3 = (state: State): ?Web3Instance => {

@ -37,8 +37,7 @@ const LocalStorageService: Middleware = (api: MiddlewareAPI) => (next: Middlewar
break;
case ACCOUNT.CREATE:
case ACCOUNT.SET_BALANCE:
case ACCOUNT.SET_NONCE:
case ACCOUNT.UPDATE:
api.dispatch(LocalStorageActions.save());
break;

@ -161,10 +161,8 @@ const AccountMenu = (props: Props) => {
const discovery = props.discovery.find(d => d.deviceState === selected.state && d.network === location.state.network);
if (discovery && discovery.completed) {
// TODO: add only if last one is not empty
//if (selectedAccounts.length > 0 && selectedAccounts[selectedAccounts.length - 1])
const lastAccount = deviceAccounts[deviceAccounts.length - 1];
if (lastAccount && (new BigNumber(lastAccount.balance).greaterThan(0) || lastAccount.nonce > 0)) {
if (lastAccount && !lastAccount.empty) {
discoveryStatus = (
<Row onClick={props.addAccount}>
<RowAddAccountWrapper>

@ -111,9 +111,9 @@ const AccountReceive = (props: Props) => {
const isAddressVerifying = props.modal.context === CONTEXT_DEVICE && props.modal.windowType === 'ButtonRequest_Address';
const isAddressHidden = !isAddressVerifying && !addressVerified && !addressUnverified;
let address = `${account.address.substring(0, 20)}...`;
let address = `${account.descriptor.substring(0, 20)}...`;
if (addressVerified || addressUnverified || isAddressVerifying) {
({ address } = account);
address = account.descriptor;
}
return (
@ -149,7 +149,7 @@ const AccountReceive = (props: Props) => {
/>
)}
>
<EyeButton onClick={() => props.showAddress(account.addressPath)}>
<EyeButton onClick={() => props.showAddress(account.accountPath)}>
<Icon
icon={addressUnverified ? ICONS.EYE_CROSSED : ICONS.EYE}
color={addressUnverified ? colors.ERROR_PRIMARY : colors.TEXT_PRIMARY}
@ -159,7 +159,7 @@ const AccountReceive = (props: Props) => {
)}
/>
{!(addressVerified || addressUnverified) && (
<ShowAddressButton onClick={() => props.showAddress(account.addressPath)} isDisabled={device.connected && !discovery.completed}>
<ShowAddressButton onClick={() => props.showAddress(account.accountPath)} isDisabled={device.connected && !discovery.completed}>
<ShowAddressIcon icon={ICONS.EYE} color={colors.WHITE} />Show full address
</ShowAddressButton>
)}
@ -172,7 +172,7 @@ const AccountReceive = (props: Props) => {
fgColor="#000000"
level="Q"
style={{ width: 150 }}
value={account.address}
value={account.descriptor}
/>
</QrWrapper>
)}

@ -111,9 +111,9 @@ const AccountReceive = (props: Props) => {
const isAddressVerifying = props.modal.context === CONTEXT_DEVICE && props.modal.windowType === 'ButtonRequest_Address';
const isAddressHidden = !isAddressVerifying && !addressVerified && !addressUnverified;
let address = `${account.address.substring(0, 20)}...`;
let address = `${account.descriptor.substring(0, 20)}...`;
if (addressVerified || addressUnverified || isAddressVerifying) {
({ address } = account);
address = account.descriptor;
}
return (
@ -149,7 +149,7 @@ const AccountReceive = (props: Props) => {
/>
)}
>
<EyeButton onClick={() => props.showAddress(account.addressPath)}>
<EyeButton onClick={() => props.showAddress(account.accountPath)}>
<Icon
icon={addressUnverified ? ICONS.EYE_CROSSED : ICONS.EYE}
color={addressUnverified ? colors.ERROR_PRIMARY : colors.TEXT_PRIMARY}
@ -159,7 +159,7 @@ const AccountReceive = (props: Props) => {
)}
/>
{!(addressVerified || addressUnverified) && (
<ShowAddressButton onClick={() => props.showAddress(account.addressPath)} isDisabled={device.connected && !discovery.completed}>
<ShowAddressButton onClick={() => props.showAddress(account.accountPath)} isDisabled={device.connected && !discovery.completed}>
<ShowAddressIcon icon={ICONS.EYE} color={colors.WHITE} />Show full address
</ShowAddressButton>
)}
@ -172,7 +172,7 @@ const AccountReceive = (props: Props) => {
fgColor="#000000"
level="Q"
style={{ width: 150 }}
value={account.address}
value={account.descriptor}
/>
</QrWrapper>
)}

@ -86,7 +86,7 @@ class SignVerify extends Component <Props> {
<Input
topLabel="Address"
name="signAddress"
value={account.address}
value={account.descriptor}
type="text"
autoSelect
readOnly
@ -122,7 +122,7 @@ class SignVerify extends Component <Props> {
>Clear
</Button>
<StyledButton
onClick={() => signVerifyActions.sign(account.addressPath, signMessage)}
onClick={() => signVerifyActions.sign(account.accountPath, signMessage)}
>Sign
</StyledButton>
</RowButtons>

@ -84,7 +84,7 @@ const AccountSummary = (props: Props) => {
return <Content loader={loader} exceptionPage={exceptionPage} isLoading />;
}
const explorerLink: string = `${network.explorer.address}${account.address}`;
const explorerLink: string = `${network.explorer.address}${account.descriptor}`;
const pendingAmount: BigNumber = stateUtils.getPendingAmount(pending, network.symbol);
const balance: string = new BigNumber(account.balance).minus(pendingAmount).toString(10);

@ -74,7 +74,7 @@ const AccountSummary = (props: Props) => {
return <Content loader={loader} exceptionPage={exceptionPage} isLoading />;
}
const explorerLink: string = `${network.explorer.address}${account.address}`;
const explorerLink: string = `${network.explorer.address}${account.descriptor}`;
const pendingAmount: BigNumber = stateUtils.getPendingAmount(pending, network.symbol);
const balance: string = new BigNumber(account.balance).minus(pendingAmount).toString(10);

Loading…
Cancel
Save