mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-28 03:08:30 +00:00
add Web3Service
This commit is contained in:
parent
414d0b0d01
commit
b5a885907b
@ -39,6 +39,8 @@ export type Web3UpdateGasPriceAction = {
|
||||
|
||||
export type Web3Action = {
|
||||
type: typeof WEB3.READY,
|
||||
} | {
|
||||
type: typeof WEB3.START,
|
||||
} | {
|
||||
type: typeof WEB3.CREATE,
|
||||
instance: Web3Instance
|
||||
|
28
src/services/Web3Service.js
Normal file
28
src/services/Web3Service.js
Normal file
@ -0,0 +1,28 @@
|
||||
/* @flow */
|
||||
|
||||
|
||||
import TrezorConnect, { TRANSPORT } from 'trezor-connect';
|
||||
import * as WEB3 from 'actions/constants/web3';
|
||||
|
||||
import type {
|
||||
Middleware,
|
||||
MiddlewareAPI,
|
||||
MiddlewareDispatch,
|
||||
Action,
|
||||
} from 'flowtype';
|
||||
|
||||
/**
|
||||
* Middleware
|
||||
*/
|
||||
const Web3Service: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispatch) => (action: Action): Action => {
|
||||
// pass action
|
||||
next(action);
|
||||
|
||||
if (action.type === WEB3.START) {
|
||||
api.dispatch(WalletActions.clearUnavailableDevicesData(prevState, action.device));
|
||||
}
|
||||
|
||||
return action;
|
||||
};
|
||||
|
||||
export default Web3Service;
|
@ -4,6 +4,7 @@ import RouterService from './RouterService';
|
||||
import LocalStorageService from './LocalStorageService';
|
||||
import CoinmarketcapService from './CoinmarketcapService';
|
||||
import TrezorConnectService from './TrezorConnectService';
|
||||
import Web3Service from './Web3Service';
|
||||
|
||||
export default [
|
||||
WalletService,
|
||||
|
Loading…
Reference in New Issue
Block a user