1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-28 03:08:30 +00:00

ripple/BlockbookAction temporary commented

This commit is contained in:
Szymon Lesisz 2018-12-20 14:14:25 +01:00
parent 39c4198fcc
commit c53dfcfaeb
2 changed files with 46 additions and 16 deletions

View File

@ -24,20 +24,47 @@ export const subscribe = (network: string): PromiseAction<void> => async (dispat
}; };
export const onBlockMined = (network: string): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => { export const onBlockMined = (network: string): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
const fee = await TrezorConnect.blockchainGetFee({
coin: network,
});
if (!fee.success) return;
const blockchain = getState().blockchain.find(b => b.shortcut === network); const blockchain = getState().blockchain.find(b => b.shortcut === network);
if (!blockchain) return; if (!blockchain) return;
if (fee.payload !== blockchain.fee) { // const fee = await TrezorConnect.blockchainGetFee({
dispatch({ // coin: network,
type: BLOCKCHAIN.UPDATE_FEE, // });
shortcut: network, // if (!fee.success) return;
fee: fee.payload,
});
// if (fee.payload !== blockchain.fee) {
// dispatch({
// type: BLOCKCHAIN.UPDATE_FEE,
// shortcut: network,
// fee: fee.payload,
// });
// }
const accounts: Array<any> = getState().accounts.filter(a => a.network === network);
// console.warn('ACCOUNTS', accounts);
if (accounts.length > 0) {
// const response = await TrezorConnect.rippleGetAccountInfo({
// bundle: accounts,
// level: 'transactions',
// coin: network,
// });
// console.warn('APDEJT RESP', response);
// if (!response.success) return;
// response.payload.forEach((a, i) => {
// if (a.transactions.length > 0) {
// console.warn('APDEJTED!', a, i);
// dispatch(AccountsActions.update({
// ...accounts[i],
// balance: toDecimalAmount(a.balance, DECIMALS),
// availableBalance: toDecimalAmount(a.availableBalance, DECIMALS),
// block: a.block,
// sequence: a.sequence,
// }));
// }
// });
} }
}; };
@ -71,7 +98,7 @@ export const onNotification = (payload: $ElementType<BlockchainNotification, 'pa
const updatedAccount = await TrezorConnect.rippleGetAccountInfo({ const updatedAccount = await TrezorConnect.rippleGetAccountInfo({
account: { account: {
address: account.address, address: account.address,
block: account.block, from: account.block,
history: false, history: false,
}, },
coin: account.network, coin: account.network,
@ -81,7 +108,7 @@ export const onNotification = (payload: $ElementType<BlockchainNotification, 'pa
dispatch(AccountsActions.update({ dispatch(AccountsActions.update({
...account, ...account,
balance: toDecimalAmount(updatedAccount.payload.balance, DECIMALS), balance: toDecimalAmount(updatedAccount.payload.balance, DECIMALS),
availableDevice: toDecimalAmount(updatedAccount.payload.availableBalance, DECIMALS), availableBalance: toDecimalAmount(updatedAccount.payload.availableBalance, DECIMALS),
block: updatedAccount.payload.block, block: updatedAccount.payload.block,
sequence: updatedAccount.payload.sequence, sequence: updatedAccount.payload.sequence,
})); }));

View File

@ -9,8 +9,9 @@ import type { BlockchainConnect, BlockchainError, BlockchainBlock } from 'trezor
export type BlockchainNetwork = { export type BlockchainNetwork = {
+shortcut: string, +shortcut: string,
connected: boolean, connected: boolean,
fee: string,
block: number, block: number,
reserved: string, // xrp specific
fee: string,
}; };
export type State = Array<BlockchainNetwork>; export type State = Array<BlockchainNetwork>;
@ -34,8 +35,9 @@ const onConnect = (state: State, action: BlockchainConnect): State => {
return state.concat([{ return state.concat([{
shortcut, shortcut,
connected: true, connected: true,
fee: info.fee,
block: info.block, block: info.block,
fee: info.fee,
reserved: info.reserved || '0',
}]); }]);
}; };
@ -53,8 +55,9 @@ const onError = (state: State, action: BlockchainError): State => {
return state.concat([{ return state.concat([{
shortcut, shortcut,
connected: false, connected: false,
fee: '0',
block: 0, block: 0,
fee: '0',
reserved: '0',
}]); }]);
}; };