mirror of https://github.com/trezor/trezor-wallet
parent
8aeb10cf2c
commit
c597f482dc
@ -0,0 +1,15 @@
|
|||||||
|
/* @flow */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import * as ADDRESS from './constants/address';
|
||||||
|
|
||||||
|
export type AddressAction = {
|
||||||
|
type: typeof ADDRESS.CREATE,
|
||||||
|
payload: any
|
||||||
|
} | {
|
||||||
|
type: typeof ADDRESS.SET_BALANCE,
|
||||||
|
payload: any
|
||||||
|
} | {
|
||||||
|
type: typeof ADDRESS.SET_NONCE,
|
||||||
|
payload: any
|
||||||
|
}
|
@ -1,10 +1,2 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
export const onGasPriceChange2 = (gasPrice: string): void => {
|
|
||||||
return {
|
|
||||||
type: '',
|
|
||||||
gasPrice
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +1,25 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const toggle = (): any => {
|
import * as LOG from './constants/log';
|
||||||
return (dispatch, getState) => {
|
|
||||||
|
import type { AsyncAction, GetState, Dispatch } from '../flowtype';
|
||||||
|
|
||||||
|
export type LogAction = {
|
||||||
|
type: typeof LOG.OPEN,
|
||||||
|
} | {
|
||||||
|
type: typeof LOG.CLOSE,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const toggle = (): AsyncAction => {
|
||||||
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
|
|
||||||
if (!getState().log.opened) {
|
if (!getState().log.opened) {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: getState().log.opened ? 'log__close' : 'log__open'
|
type: getState().log.opened ? LOG.CLOSE : LOG.OPEN
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,113 @@
|
|||||||
|
/* @flow */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import * as TOKEN from './constants/token';
|
||||||
|
import { getTokenInfoAsync, getTokenBalanceAsync } from './Web3Actions';
|
||||||
|
|
||||||
|
import type { GetState, AsyncAction, Action } from '../flowtype';
|
||||||
|
import type { State, Token } from '../reducers/TokensReducer';
|
||||||
|
import type { Account } from '../reducers/AccountsReducer';
|
||||||
|
import type { NetworkToken } from '../reducers/LocalStorageReducer';
|
||||||
|
|
||||||
|
export type TokenAction = {
|
||||||
|
type: typeof TOKEN.FROM_STORAGE,
|
||||||
|
payload: State
|
||||||
|
} | {
|
||||||
|
type: typeof TOKEN.ADD,
|
||||||
|
payload: Token
|
||||||
|
} | {
|
||||||
|
type: typeof TOKEN.REMOVE,
|
||||||
|
token: Token
|
||||||
|
} | {
|
||||||
|
type: typeof TOKEN.SET_BALANCE,
|
||||||
|
payload: {
|
||||||
|
ethAddress: string,
|
||||||
|
address: string,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setBalance = (web3: any, coinIndex: number = 0): AsyncAction => {
|
||||||
|
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type SelectOptions = {
|
||||||
|
options?: Array<NetworkToken>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// action from component <reactSelect>
|
||||||
|
export const load = (input: string, network: string): AsyncAction => {
|
||||||
|
return async (dispatch: Dispatch, getState: GetState): Promise<any> => {
|
||||||
|
|
||||||
|
if (input.length < 1) return;
|
||||||
|
|
||||||
|
const tokens = getState().localStorage.tokens[ network ];
|
||||||
|
const value = input.toLowerCase();
|
||||||
|
const result = tokens.filter(t =>
|
||||||
|
t.symbol.toLowerCase().indexOf(value) >= 0 ||
|
||||||
|
t.address.toLowerCase().indexOf(value) >= 0 ||
|
||||||
|
t.name.toLowerCase().indexOf(value) >= 0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result.length > 0) {
|
||||||
|
return { options: result };
|
||||||
|
} else {
|
||||||
|
const web3instance = getState().web3.find(w3 => w3.network === network);
|
||||||
|
if (!web3instance) return;
|
||||||
|
|
||||||
|
const info = await getTokenInfoAsync(web3instance.erc20, input);
|
||||||
|
info.address = input;
|
||||||
|
|
||||||
|
if (info) {
|
||||||
|
return {
|
||||||
|
options: [ info ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//await resolveAfter(300000);
|
||||||
|
//await resolveAfter(3000);
|
||||||
|
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const add = (token: NetworkToken, account: Account): AsyncAction => {
|
||||||
|
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
|
|
||||||
|
const web3instance = getState().web3.find(w3 => w3.network === account.network);
|
||||||
|
if (!web3instance) return;
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: TOKEN.ADD,
|
||||||
|
payload: {
|
||||||
|
loaded: false,
|
||||||
|
deviceState: account.deviceState,
|
||||||
|
name: token.name,
|
||||||
|
symbol: token.symbol,
|
||||||
|
address: token.address,
|
||||||
|
ethAddress: account.address,
|
||||||
|
decimals: token.decimals,
|
||||||
|
balance: '0'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const tokenBalance = await getTokenBalanceAsync(web3instance.erc20, token.address, account.address);
|
||||||
|
dispatch({
|
||||||
|
type: TOKEN.SET_BALANCE,
|
||||||
|
payload: {
|
||||||
|
ethAddress: account.address,
|
||||||
|
address: token.address,
|
||||||
|
balance: tokenBalance.toString()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const remove = (token: Token): Action => {
|
||||||
|
return {
|
||||||
|
type: TOKEN.REMOVE,
|
||||||
|
token
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +1,29 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const READY: string = 'trezorconnect__ready';
|
//regExp1 : string = '(.*)'
|
||||||
export const INITIALIZATION_ERROR: string = 'trezorconnect__init_error';
|
//regExp2 : '$1' = '$1'
|
||||||
export const SELECT_DEVICE: string = 'trezorconnect__select_device';
|
|
||||||
|
|
||||||
|
export const READY: 'trezorconnect__ready' = 'trezorconnect__ready';
|
||||||
|
export const INITIALIZATION_ERROR: 'trezorconnect__init_error' = 'trezorconnect__init_error';
|
||||||
|
export const SELECT_DEVICE: 'trezorconnect__select_device' = 'trezorconnect__select_device';
|
||||||
|
|
||||||
export const DEVICE_FROM_STORAGE: string = 'trezorconnect__device_from_storage';
|
|
||||||
export const AUTH_DEVICE: string = 'trezorconnect__auth_device';
|
|
||||||
export const COIN_CHANGED: string = 'trezorconnect__coin_changed';
|
|
||||||
|
|
||||||
export const REMEMBER_REQUEST: string = 'trezorconnect__remember_request';
|
export const DEVICE_FROM_STORAGE: 'trezorconnect__device_from_storage' = 'trezorconnect__device_from_storage';
|
||||||
export const FORGET_REQUEST: string = 'trezorconnect__forget_request';
|
export const AUTH_DEVICE: 'trezorconnect__auth_device' = 'trezorconnect__auth_device';
|
||||||
export const FORGET: string = 'trezorconnect__forget';
|
export const COIN_CHANGED: 'trezorconnect__coin_changed' = 'trezorconnect__coin_changed';
|
||||||
export const FORGET_SINGLE: string = 'trezorconnect__forget_single';
|
|
||||||
export const DISCONNECT_REQUEST: string = 'trezorconnect__disconnect_request';
|
|
||||||
export const REMEMBER: string = 'trezorconnect__remember';
|
|
||||||
|
|
||||||
export const START_ACQUIRING: string = 'trezorconnect__start_acquiring';
|
export const REMEMBER_REQUEST: 'trezorconnect__remember_request' = 'trezorconnect__remember_request';
|
||||||
export const STOP_ACQUIRING: string = 'trezorconnect__stop_acquiring';
|
export const FORGET_REQUEST: 'trezorconnect__forget_request' = 'trezorconnect__forget_request';
|
||||||
|
export const FORGET: 'trezorconnect__forget' = 'trezorconnect__forget';
|
||||||
|
export const FORGET_SINGLE: 'trezorconnect__forget_single' = 'trezorconnect__forget_single';
|
||||||
|
export const DISCONNECT_REQUEST: 'trezorconnect__disconnect_request' = 'trezorconnect__disconnect_request';
|
||||||
|
export const REMEMBER: 'trezorconnect__remember' = 'trezorconnect__remember';
|
||||||
|
|
||||||
export const TRY_TO_DUPLICATE: string = 'trezorconnect__try_to_duplicate';
|
export const START_ACQUIRING: 'trezorconnect__start_acquiring' = 'trezorconnect__start_acquiring';
|
||||||
export const DUPLICATE: string = 'trezorconnect__duplicate';
|
export const STOP_ACQUIRING: 'trezorconnect__stop_acquiring' = 'trezorconnect__stop_acquiring';
|
||||||
|
|
||||||
export const DEVICE_STATE_EXCEPTION: string = 'trezorconnect__device_state_exception';
|
export const TRY_TO_DUPLICATE: 'trezorconnect__try_to_duplicate' = 'trezorconnect__try_to_duplicate';
|
||||||
|
export const DUPLICATE: 'trezorconnect__duplicate' = 'trezorconnect__duplicate';
|
||||||
|
|
||||||
|
export const DEVICE_STATE_EXCEPTION: 'trezorconnect__device_state_exception' = 'trezorconnect__device_state_exception';
|
@ -1,11 +1,11 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const INIT: string = 'account__init';
|
export const INIT: 'account__init' = 'account__init';
|
||||||
export const DISPOSE: string = 'account__dispose';
|
export const DISPOSE: 'account__dispose' = 'account__dispose';
|
||||||
|
|
||||||
export const CREATE: string = 'address__create';
|
// export const CREATE: 'address__create' = 'address__create';
|
||||||
export const REMOVE: string = 'address__remove';
|
// export const REMOVE: 'address__remove' = 'address__remove';
|
||||||
export const SET_BALANCE: string = 'address__set_balance';
|
// export const SET_BALANCE: 'address__set_balance' = 'address__set_balance';
|
||||||
export const SET_NONCE: string = 'address__set_nonce';
|
// export const SET_NONCE: 'address__set_nonce' = 'address__set_nonce';
|
||||||
export const FROM_STORAGE: string = 'address__from_storage';
|
// export const FROM_STORAGE: 'address__from_storage' = 'address__from_storage';
|
@ -1,9 +1,9 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const CREATE: string = 'address__create';
|
export const CREATE: 'address__create' = 'address__create';
|
||||||
export const REMOVE: string = 'address__remove';
|
export const REMOVE: 'address__remove' = 'address__remove';
|
||||||
export const SET_BALANCE: string = 'address__set_balance';
|
export const SET_BALANCE: 'address__set_balance' = 'address__set_balance';
|
||||||
export const SET_NONCE: string = 'address__set_nonce';
|
export const SET_NONCE: 'address__set_nonce' = 'address__set_nonce';
|
||||||
export const FROM_STORAGE: string = 'address__from_storage';
|
export const FROM_STORAGE: 'address__from_storage' = 'address__from_storage';
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const START: string = 'discovery__start';
|
export const START: 'discovery__start' = 'discovery__start';
|
||||||
export const STOP: string = 'discovery__stop';
|
export const STOP: 'discovery__stop' = 'discovery__stop';
|
||||||
export const COMPLETE: string = 'discovery__complete';
|
export const COMPLETE: 'discovery__complete' = 'discovery__complete';
|
||||||
export const WAITING: string = 'discovery__waiting';
|
export const WAITING: 'discovery__waiting' = 'discovery__waiting';
|
||||||
export const FROM_STORAGE: string = 'discovery__from_storage';
|
export const FROM_STORAGE: 'discovery__from_storage' = 'discovery__from_storage';
|
@ -1,6 +1,6 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const SAVE: string = 'storage__save';
|
export const SAVE: 'storage__save' = 'storage__save';
|
||||||
export const READY: string = 'storage__ready';
|
export const READY: 'storage__ready' = 'storage__ready';
|
||||||
export const ERROR: string = 'storage__error';
|
export const ERROR: 'storage__error' = 'storage__error';
|
@ -0,0 +1,5 @@
|
|||||||
|
/* @flow */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
export const OPEN: 'log__open' = 'log__open';
|
||||||
|
export const CLOSE: 'log__close' = 'log__close';
|
@ -1,14 +1,17 @@
|
|||||||
export const ON_PASSPHRASE_CHANGE: string = 'action__on_passphrase_change';
|
/* @flow */
|
||||||
export const ON_PASSPHRASE_SHOW: string = 'action__on_passphrase_show';
|
'use strict';
|
||||||
export const ON_PASSPHRASE_HIDE: string = 'action__on_passphrase_hide';
|
|
||||||
export const ON_PASSPHRASE_SAVE: string = 'action__on_passphrase_save';
|
|
||||||
export const ON_PASSPHRASE_FORGET: string = 'action__on_passphrase_forget';
|
|
||||||
export const ON_PASSPHRASE_FOCUS: string = 'action__on_passphrase_focus';
|
|
||||||
export const ON_PASSPHRASE_BLUR: string = 'action__on_passphrase_blur';
|
|
||||||
export const ON_PASSPHRASE_SUBMIT: string = 'action__on_passphrase_submit';
|
|
||||||
|
|
||||||
export const FORGET: string = 'modal__forget';
|
export const ON_PASSPHRASE_CHANGE: 'action__on_passphrase_change' = 'action__on_passphrase_change';
|
||||||
export const REMEMBER: string = 'modal__remember';
|
export const ON_PASSPHRASE_SHOW: 'action__on_passphrase_show' = 'action__on_passphrase_show';
|
||||||
export const ON_FORGET: string = 'modal__on_forget';
|
export const ON_PASSPHRASE_HIDE: 'action__on_passphrase_hide' = 'action__on_passphrase_hide';
|
||||||
export const ON_REMEMBER: string = 'modal__on_remember';
|
export const ON_PASSPHRASE_SAVE: 'action__on_passphrase_save' = 'action__on_passphrase_save';
|
||||||
export const CLOSE: string = 'modal__close';
|
export const ON_PASSPHRASE_FORGET: 'action__on_passphrase_forget' = 'action__on_passphrase_forget';
|
||||||
|
export const ON_PASSPHRASE_FOCUS: 'action__on_passphrase_focus' = 'action__on_passphrase_focus';
|
||||||
|
export const ON_PASSPHRASE_BLUR: 'action__on_passphrase_blur' = 'action__on_passphrase_blur';
|
||||||
|
export const ON_PASSPHRASE_SUBMIT: 'action__on_passphrase_submit' = 'action__on_passphrase_submit';
|
||||||
|
|
||||||
|
export const FORGET: 'modal__forget' = 'modal__forget';
|
||||||
|
export const REMEMBER: 'modal__remember' = 'modal__remember';
|
||||||
|
export const ON_FORGET: 'modal__on_forget' = 'modal__on_forget';
|
||||||
|
export const ON_REMEMBER: 'modal__on_remember' = 'modal__on_remember';
|
||||||
|
export const CLOSE: 'modal__close' = 'modal__close';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const ADD: string = 'notification__add';
|
export const ADD: 'notification__add' = 'notification__add';
|
||||||
export const CLOSE: string = 'notification__close';
|
export const CLOSE: 'notification__close' = 'notification__close';
|
||||||
export const REMOVE: string = 'account__remove';
|
export const REMOVE: 'account__remove' = 'account__remove';
|
@ -1,8 +1,8 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const INIT: string = 'receive__init';
|
export const INIT: 'receive__init' = 'receive__init';
|
||||||
export const DISPOSE: string = 'receive__dispose';
|
export const DISPOSE: 'receive__dispose' = 'receive__dispose';
|
||||||
export const REQUEST_UNVERIFIED: string = 'receive__request_unverified';
|
export const REQUEST_UNVERIFIED: 'receive__request_unverified' = 'receive__request_unverified';
|
||||||
export const SHOW_ADDRESS: string = 'receive__show_address';
|
export const SHOW_ADDRESS: 'receive__show_address' = 'receive__show_address';
|
||||||
export const SHOW_UNVERIFIED_ADDRESS: string = 'receive__show_unverified';
|
export const SHOW_UNVERIFIED_ADDRESS: 'receive__show_unverified' = 'receive__show_unverified';
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const INIT: string = 'send__init';
|
export const INIT: 'send__init' = 'send__init';
|
||||||
export const DISPOSE: string = 'send__dispose';
|
export const DISPOSE: 'send__dispose' = 'send__dispose';
|
||||||
export const VALIDATION: string = 'send__validation';
|
export const VALIDATION: 'send__validation' = 'send__validation';
|
||||||
export const ADDRESS_CHANGE: string = 'send__address_change';
|
export const ADDRESS_CHANGE: 'send__address_change' = 'send__address_change';
|
||||||
export const AMOUNT_CHANGE: string = 'send__amount_change';
|
export const AMOUNT_CHANGE: 'send__amount_change' = 'send__amount_change';
|
||||||
export const SET_MAX: string = 'send__set_max';
|
export const SET_MAX: 'send__set_max' = 'send__set_max';
|
||||||
export const CURRENCY_CHANGE: string = 'send__currency_change';
|
export const CURRENCY_CHANGE: 'send__currency_change' = 'send__currency_change';
|
||||||
export const FEE_LEVEL_CHANGE: string = 'send__fee_level_change';
|
export const FEE_LEVEL_CHANGE: 'send__fee_level_change' = 'send__fee_level_change';
|
||||||
export const GAS_PRICE_CHANGE: string = 'send__gas_price_change';
|
export const GAS_PRICE_CHANGE: 'send__gas_price_change' = 'send__gas_price_change';
|
||||||
export const GAS_LIMIT_CHANGE: string = 'send__gas_limit_change';
|
export const GAS_LIMIT_CHANGE: 'send__gas_limit_change' = 'send__gas_limit_change';
|
||||||
export const UPDATE_FEE_LEVELS: string = 'send__update_fee_levels';
|
export const UPDATE_FEE_LEVELS: 'send__update_fee_levels' = 'send__update_fee_levels';
|
||||||
export const DATA_CHANGE: string = 'send__data_change';
|
export const DATA_CHANGE: 'send__data_change' = 'send__data_change';
|
||||||
export const SEND: string = 'send__submit';
|
export const SEND: 'send__submit' = 'send__submit';
|
||||||
export const TX_COMPLETE: string = 'send__tx_complete';
|
export const TX_COMPLETE: 'send__tx_complete' = 'send__tx_complete';
|
||||||
export const TX_ERROR: string = 'send__tx_error';
|
export const TX_ERROR: 'send__tx_error' = 'send__tx_error';
|
||||||
export const TOGGLE_ADVANCED: string = 'send__toggle_advanced';
|
export const TOGGLE_ADVANCED: 'send__toggle_advanced' = 'send__toggle_advanced';
|
@ -1,7 +1,7 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const INIT: string = 'summary__init';
|
export const INIT: 'summary__init' = 'summary__init';
|
||||||
export const DISPOSE: string = 'summary__dispose';
|
export const DISPOSE: 'summary__dispose' = 'summary__dispose';
|
||||||
export const ADD_TOKEN: string = 'summary__add_token';
|
export const ADD_TOKEN: 'summary__add_token' = 'summary__add_token';
|
||||||
export const DETAILS_TOGGLE: string = 'summary__details_toggle';
|
export const DETAILS_TOGGLE: 'summary__details_toggle' = 'summary__details_toggle';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const ADD: string = 'token__add';
|
export const ADD: 'token__add' = 'token__add';
|
||||||
export const REMOVE: string = 'token__remove';
|
export const REMOVE: 'token__remove' = 'token__remove';
|
||||||
export const SET_BALANCE: string = 'token__set_balance';
|
export const SET_BALANCE: 'token__set_balance' = 'token__set_balance';
|
||||||
export const FROM_STORAGE: string = 'token__from_storage';
|
export const FROM_STORAGE: 'token__from_storage' = 'token__from_storage';
|
@ -1,6 +1,6 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const ON_BEFORE_UNLOAD: string = 'wallet__on_before_unload';
|
export const ON_BEFORE_UNLOAD: 'wallet__on_before_unload' = 'wallet__on_before_unload';
|
||||||
export const TOGGLE_DEVICE_DROPDOWN: string = 'wallet_toggle_dropdown';
|
export const TOGGLE_DEVICE_DROPDOWN: 'wallet_toggle_dropdown' = 'wallet_toggle_dropdown';
|
||||||
export const SET_INITIAL_URL: string = 'wallet_set_initial_url';
|
export const SET_INITIAL_URL: 'wallet_set_initial_url' = 'wallet_set_initial_url';
|
@ -1,10 +1,10 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export const START: string = 'web3__start';
|
export const START: 'web3__start' = 'web3__start';
|
||||||
export const STOP: string = 'web3__stop';
|
export const STOP: 'web3__stop' = 'web3__stop';
|
||||||
export const CREATE: string = 'web3__create';
|
export const CREATE: 'web3__create' = 'web3__create';
|
||||||
export const READY: string = 'web3__ready';
|
export const READY: 'web3__ready' = 'web3__ready';
|
||||||
export const BLOCK_UPDATED: string = 'web3__block_updated';
|
export const BLOCK_UPDATED: 'web3__block_updated' = 'web3__block_updated';
|
||||||
export const GAS_PRICE_UPDATED: string = 'web3__gas_price_updated';
|
export const GAS_PRICE_UPDATED: 'web3__gas_price_updated' = 'web3__gas_price_updated';
|
||||||
export const PENDING_TX_RESOLVED: string = 'web3__pending_tx_resolved';
|
export const PENDING_TX_RESOLVED: 'web3__pending_tx_resolved' = 'web3__pending_tx_resolved';
|
@ -1,33 +1,30 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export default class Header extends Component {
|
const Header = (): React$Element<string> => {
|
||||||
render() {
|
return (
|
||||||
return (
|
<header>
|
||||||
<header>
|
<div className="layout-wrapper">
|
||||||
<div className="layout-wrapper">
|
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 163.7 41.9" width="100%" height="100%" preserveAspectRatio="xMinYMin meet">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 163.7 41.9" width="100%" height="100%" preserveAspectRatio="xMinYMin meet">
|
<polygon points="101.1,12.8 118.2,12.8 118.2,17.3 108.9,29.9 118.2,29.9 118.2,35.2 101.1,35.2 101.1,30.7 110.4,18.1 101.1,18.1"/>
|
||||||
<polygon points="101.1,12.8 118.2,12.8 118.2,17.3 108.9,29.9 118.2,29.9 118.2,35.2 101.1,35.2 101.1,30.7 110.4,18.1 101.1,18.1"/>
|
<path d="M158.8,26.9c2.1-0.8,4.3-2.9,4.3-6.6c0-4.5-3.1-7.4-7.7-7.4h-10.5v22.3h5.8v-7.5h2.2l4.1,7.5h6.7L158.8,26.9z M154.7,22.5 h-4V18h4c1.5,0,2.5,0.9,2.5,2.2C157.2,21.6,156.2,22.5,154.7,22.5z"/>
|
||||||
<path d="M158.8,26.9c2.1-0.8,4.3-2.9,4.3-6.6c0-4.5-3.1-7.4-7.7-7.4h-10.5v22.3h5.8v-7.5h2.2l4.1,7.5h6.7L158.8,26.9z M154.7,22.5 h-4V18h4c1.5,0,2.5,0.9,2.5,2.2C157.2,21.6,156.2,22.5,154.7,22.5z"/>
|
<path d="M130.8,12.5c-6.8,0-11.6,4.9-11.6,11.5s4.9,11.5,11.6,11.5s11.7-4.9,11.7-11.5S137.6,12.5,130.8,12.5z M130.8,30.3 c-3.4,0-5.7-2.6-5.7-6.3c0-3.8,2.3-6.3,5.7-6.3c3.4,0,5.8,2.6,5.8,6.3C136.6,27.7,134.2,30.3,130.8,30.3z"/>
|
||||||
<path d="M130.8,12.5c-6.8,0-11.6,4.9-11.6,11.5s4.9,11.5,11.6,11.5s11.7-4.9,11.7-11.5S137.6,12.5,130.8,12.5z M130.8,30.3 c-3.4,0-5.7-2.6-5.7-6.3c0-3.8,2.3-6.3,5.7-6.3c3.4,0,5.8,2.6,5.8,6.3C136.6,27.7,134.2,30.3,130.8,30.3z"/>
|
<polygon points="82.1,12.8 98.3,12.8 98.3,18 87.9,18 87.9,21.3 98,21.3 98,26.4 87.9,26.4 87.9,30 98.3,30 98.3,35.2 82.1,35.2 "/>
|
||||||
<polygon points="82.1,12.8 98.3,12.8 98.3,18 87.9,18 87.9,21.3 98,21.3 98,26.4 87.9,26.4 87.9,30 98.3,30 98.3,35.2 82.1,35.2 "/>
|
<path d="M24.6,9.7C24.6,4.4,20,0,14.4,0S4.2,4.4,4.2,9.7v3.1H0v22.3h0l14.4,6.7l14.4-6.7h0V12.9h-4.2V9.7z M9.4,9.7 c0-2.5,2.2-4.5,5-4.5s5,2,5,4.5v3.1H9.4V9.7z M23,31.5l-8.6,4l-8.6-4V18.1H23V31.5z"/>
|
||||||
<path d="M24.6,9.7C24.6,4.4,20,0,14.4,0S4.2,4.4,4.2,9.7v3.1H0v22.3h0l14.4,6.7l14.4-6.7h0V12.9h-4.2V9.7z M9.4,9.7 c0-2.5,2.2-4.5,5-4.5s5,2,5,4.5v3.1H9.4V9.7z M23,31.5l-8.6,4l-8.6-4V18.1H23V31.5z"/>
|
<path d="M79.4,20.3c0-4.5-3.1-7.4-7.7-7.4H61.2v22.3H67v-7.5h2.2l4.1,7.5H80l-4.9-8.3C77.2,26.1,79.4,24,79.4,20.3z M71,22.5h-4V18 h4c1.5,0,2.5,0.9,2.5,2.2C73.5,21.6,72.5,22.5,71,22.5z"/>
|
||||||
<path d="M79.4,20.3c0-4.5-3.1-7.4-7.7-7.4H61.2v22.3H67v-7.5h2.2l4.1,7.5H80l-4.9-8.3C77.2,26.1,79.4,24,79.4,20.3z M71,22.5h-4V18 h4c1.5,0,2.5,0.9,2.5,2.2C73.5,21.6,72.5,22.5,71,22.5z"/>
|
<polygon points="40.5,12.8 58.6,12.8 58.6,18.1 52.4,18.1 52.4,35.2 46.6,35.2 46.6,18.1 40.5,18.1 "/>
|
||||||
<polygon points="40.5,12.8 58.6,12.8 58.6,18.1 52.4,18.1 52.4,35.2 46.6,35.2 46.6,18.1 40.5,18.1 "/>
|
</svg>
|
||||||
</svg>
|
<div>
|
||||||
<div>
|
<a href="https://trezor.io/" target="_blank" rel="noreferrer noopener">TREZOR</a>
|
||||||
<a href="https://trezor.io/" target="_blank" rel="noreferrer noopener">TREZOR</a>
|
<a href="https://doc.satoshilabs.com/trezor-user/" target="_blank" rel="noreferrer noopener">Docs</a>
|
||||||
<a href="https://doc.satoshilabs.com/trezor-user/" target="_blank" rel="noreferrer noopener">Docs</a>
|
<a href="https://blog.trezor.io/" target="_blank" rel="noreferrer noopener">Blog</a>
|
||||||
<a href="https://blog.trezor.io/" target="_blank" rel="noreferrer noopener">Blog</a>
|
<a href="https://trezor.io/support/" target="_blank" rel="noreferrer noopener">Support</a>
|
||||||
<a href="https://trezor.io/support/" target="_blank" rel="noreferrer noopener">Support</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</div>
|
||||||
);
|
</header>
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Header;
|
||||||
|
|
@ -1,77 +0,0 @@
|
|||||||
/* @flow */
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
|
||||||
|
|
||||||
const formatTime = (ts) => {
|
|
||||||
var date = new Date(ts * 1000);
|
|
||||||
// Hours part from the timestamp
|
|
||||||
var hours = date.getHours();
|
|
||||||
// Minutes part from the timestamp
|
|
||||||
var minutes = "0" + date.getMinutes();
|
|
||||||
// Seconds part from the timestamp
|
|
||||||
var seconds = "0" + date.getSeconds();
|
|
||||||
|
|
||||||
// Will display time in 10:30:23 format
|
|
||||||
return hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const History = (props): any => {
|
|
||||||
|
|
||||||
const web3 = props.web3;
|
|
||||||
const { addresses } = props.addresses;
|
|
||||||
const currentAddress = addresses[ parseInt(props.match.params.address) ];
|
|
||||||
|
|
||||||
if (!currentAddress) return null;
|
|
||||||
|
|
||||||
let txs = null;
|
|
||||||
let pendingTransactions = null;
|
|
||||||
|
|
||||||
if (currentAddress.history) {
|
|
||||||
|
|
||||||
const pending = currentAddress.pendingTx;
|
|
||||||
|
|
||||||
if (pending.length > 0) {
|
|
||||||
pendingTransactions = pending.map((tx, i) => {
|
|
||||||
|
|
||||||
const etherscanLink = `https://ropsten.etherscan.io/tx/${ tx.hash }`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div key={i} className="history-pending-transaction">
|
|
||||||
<a href={ etherscanLink } target="_blank" rel="noreferrer noopener">Details</a>
|
|
||||||
<span className="address">{ tx.to }</span>
|
|
||||||
Pending...
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
txs = currentAddress.history.map((tx, i) => {
|
|
||||||
const etherscanLink = `https://ropsten.etherscan.io/tx/${ tx.hash }`;
|
|
||||||
return (
|
|
||||||
<div key={i} className={ `history-transaction ${ tx.type }` }>
|
|
||||||
<a href={ etherscanLink } target="_blank">Details</a>
|
|
||||||
<span className="time">{ formatTime( parseInt(tx.timeStamp) ) }</span>
|
|
||||||
<span className="address">{ tx.address }</span>
|
|
||||||
<span className="amount">{ web3.fromWei(tx.value, 'ether') }</span>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="history">
|
|
||||||
{ pendingTransactions ?
|
|
||||||
<div>
|
|
||||||
<h2>Pending:</h2>
|
|
||||||
{ pendingTransactions }
|
|
||||||
</div>
|
|
||||||
: null}
|
|
||||||
|
|
||||||
<h3>HISTORY OF { currentAddress.address }</h3>
|
|
||||||
{ txs }
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default History;
|
|
@ -1,60 +0,0 @@
|
|||||||
/* @flow */
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
|
|
||||||
// export default (props: any): any => {
|
|
||||||
// console.log("RENDER CUSTOM OPTION", props)
|
|
||||||
// return (
|
|
||||||
// <div>1</div>
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
|
|
||||||
class FeeSelectOption extends Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleMouseDown(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
this.props.onSelect(this.props.option, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleMouseEnter(event) {
|
|
||||||
this.props.onFocus(this.props.option, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleMouseMove(event) {
|
|
||||||
if (this.props.isFocused) return;
|
|
||||||
this.props.onFocus(this.props.option, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div className={ this.props.className }
|
|
||||||
onMouseDown={ this.handleMouseDown.bind(this) }
|
|
||||||
onMouseEnter={ this.handleMouseEnter.bind(this) }
|
|
||||||
onMouseMove={ this.handleMouseMove.bind(this) }>
|
|
||||||
<span className="fee-label">{ this.props.children }</span>
|
|
||||||
|
|
||||||
<span className="fee-value">$10.20 / 8.828392159996002 ETH</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FeeSelectOption.propTypes = {
|
|
||||||
children: PropTypes.node,
|
|
||||||
className: PropTypes.string,
|
|
||||||
isDisabled: PropTypes.bool,
|
|
||||||
isFocused: PropTypes.bool,
|
|
||||||
isSelected: PropTypes.bool,
|
|
||||||
onFocus: PropTypes.func,
|
|
||||||
onSelect: PropTypes.func,
|
|
||||||
option: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FeeSelectOption;
|
|
@ -1,8 +1,126 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
Store as ReduxStore,
|
||||||
|
StoreEnhancer as ReduxStoreEnhancer,
|
||||||
|
Dispatch as ReduxDispatch,
|
||||||
|
Middleware as ReduxMiddleware,
|
||||||
|
MiddlewareAPI as ReduxMiddlewareAPI,
|
||||||
|
ThunkAction as ReduxThunkAction,
|
||||||
|
ThunkDispatch as ReduxThunkDispatch,
|
||||||
|
PlainDispatch as ReduxPlainDispatch
|
||||||
|
} from 'redux';
|
||||||
|
|
||||||
|
import type { Reducers, ReducersState } from '../reducers';
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
import type { AbstractAccountAction } from '../actions/AbstractAccountActions';
|
||||||
|
import type { AddressAction } from '../actions/AddressActions';
|
||||||
|
import type { DiscoveryAction } from '../actions/DiscoveryActions';
|
||||||
|
import type { StorageAction } from '../actions/LocalStorageActions';
|
||||||
|
import type { LogAction } from '../actions/LogActions';
|
||||||
|
import type { ModalAction } from '../actions/ModalActions';
|
||||||
|
import type { NotificationAction } from '../actions/NotificationActions';
|
||||||
|
import type { ReceiveAction } from '../actions/ReceiveActions';
|
||||||
|
import type { SendFormAction } from '../actions/SendFormActions';
|
||||||
|
import type { SummaryAction } from '../actions/SummaryActions';
|
||||||
|
import type { TokenAction } from '../actions/TokenActions';
|
||||||
|
import type { TrezorConnectAction } from '../actions/TrezorConnectActions';
|
||||||
|
import type { WalletAction } from '../actions/WalletActions';
|
||||||
|
import type { Web3Action } from '../actions/Web3Actions';
|
||||||
|
import type { FiatRateAction } from '../services/CoinmarketcapService'; // this service has no action file, all is written inside one file
|
||||||
|
|
||||||
|
import type {
|
||||||
|
Device,
|
||||||
|
Features,
|
||||||
|
DeviceMessageType,
|
||||||
|
TransportMessageType,
|
||||||
|
UiMessageType,
|
||||||
|
} from 'trezor-connect';
|
||||||
|
|
||||||
|
import type { RouterAction, LocationState } from 'react-router-redux';
|
||||||
|
|
||||||
|
export type TrezorDevice = {
|
||||||
|
remember: boolean;
|
||||||
|
connected: boolean;
|
||||||
|
available: boolean; // device cannot be used because of features.passphrase_protection is different then expected (saved)
|
||||||
|
path: string;
|
||||||
|
label: string;
|
||||||
|
state: ?string;
|
||||||
|
instance?: number;
|
||||||
|
instanceLabel: string;
|
||||||
|
features?: Features;
|
||||||
|
unacquired?: boolean;
|
||||||
|
acquiring: boolean;
|
||||||
|
isUsedElsewhere?: boolean;
|
||||||
|
featuresNeedsReload?: boolean;
|
||||||
|
ts: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RouterLocationState = LocationState;
|
||||||
|
|
||||||
|
// Cast event from TrezorConnect event listener to react Action
|
||||||
|
type DeviceEventAction = {
|
||||||
|
type: DeviceMessageType,
|
||||||
|
device: Device,
|
||||||
|
}
|
||||||
|
|
||||||
|
type TransportEventAction = {
|
||||||
|
type: TransportMessageType,
|
||||||
|
payload: any,
|
||||||
|
}
|
||||||
|
|
||||||
|
type UiEventAction = {
|
||||||
|
type: UiMessageType,
|
||||||
|
payload: any,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: join this message with uiMessage
|
||||||
|
type IFrameHandshake = {
|
||||||
|
type: 'iframe_handshake',
|
||||||
|
payload: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Action =
|
||||||
|
RouterAction
|
||||||
|
| IFrameHandshake
|
||||||
|
| TransportEventAction
|
||||||
|
| DeviceEventAction
|
||||||
|
| UiEventAction
|
||||||
|
|
||||||
|
| AbstractAccountAction
|
||||||
|
| AddressAction
|
||||||
|
| DiscoveryAction
|
||||||
|
| StorageAction
|
||||||
|
| LogAction
|
||||||
|
| ModalAction
|
||||||
|
| NotificationAction
|
||||||
|
| ReceiveAction
|
||||||
|
| SendFormAction
|
||||||
|
| SummaryAction
|
||||||
|
| TokenAction
|
||||||
|
| TrezorConnectAction
|
||||||
|
| WalletAction
|
||||||
|
| Web3Action
|
||||||
|
| FiatRateAction;
|
||||||
|
|
||||||
|
export type State = ReducersState;
|
||||||
|
|
||||||
|
export type Accounts = $ElementType<State, 'accounts'>;
|
||||||
|
export type LocalStorage = $ElementType<State, 'localStorage'>;
|
||||||
|
export type Config = $PropertyType<$ElementType<State, 'localStorage'>, 'config'>;
|
||||||
|
|
||||||
|
|
||||||
|
export type Dispatch = ReduxDispatch<State, Action>;
|
||||||
|
export type MiddlewareDispatch = ReduxPlainDispatch<Action>;
|
||||||
|
|
||||||
|
export type MiddlewareAPI = ReduxMiddlewareAPI<State, Action>;
|
||||||
|
export type Middleware = ReduxMiddleware<State, Action>;
|
||||||
|
|
||||||
|
export type Store = ReduxStore<State, Action>;
|
||||||
|
export type StoreEnhancer = ReduxStoreEnhancer<State, Action>;
|
||||||
|
|
||||||
export type Dispatch = (action: Action | ThunkAction | PromiseAction) => any;
|
|
||||||
export type GetState = () => State;
|
export type GetState = () => State;
|
||||||
export type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;
|
|
||||||
export type PromiseAction = Promise<Action>;
|
export type AsyncAction = ReduxThunkAction<State, Action>;
|
||||||
|
@ -0,0 +1,132 @@
|
|||||||
|
// flow-typed signature: 59b0c4be0e1408f21e2446be96c79804
|
||||||
|
// flow-typed version: 9092387fd2/react-redux_v5.x.x/flow_>=v0.54.x
|
||||||
|
|
||||||
|
import type { Dispatch, Store } from "redux";
|
||||||
|
|
||||||
|
declare module "react-redux" {
|
||||||
|
/*
|
||||||
|
|
||||||
|
S = State
|
||||||
|
A = Action
|
||||||
|
OP = OwnProps
|
||||||
|
SP = StateProps
|
||||||
|
DP = DispatchProps
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare type MapStateToProps<S, OP: Object, SP: Object> = (
|
||||||
|
state: S,
|
||||||
|
ownProps: OP
|
||||||
|
) => ((state: S, ownProps: OP) => SP) | SP;
|
||||||
|
|
||||||
|
declare type MapDispatchToProps<A, OP: Object, DP: Object> =
|
||||||
|
| ((dispatch: Dispatch<A>, ownProps: OP) => DP)
|
||||||
|
| DP;
|
||||||
|
|
||||||
|
declare type MergeProps<SP, DP: Object, OP: Object, P: Object> = (
|
||||||
|
stateProps: SP,
|
||||||
|
dispatchProps: DP,
|
||||||
|
ownProps: OP
|
||||||
|
) => P;
|
||||||
|
|
||||||
|
declare type Context = { store: Store<*, *> };
|
||||||
|
|
||||||
|
declare type ComponentWithDefaultProps<DP: {}, P: {}, CP: P> = Class<
|
||||||
|
React$Component<CP>
|
||||||
|
> & { defaultProps: DP };
|
||||||
|
|
||||||
|
declare class ConnectedComponentWithDefaultProps<
|
||||||
|
OP,
|
||||||
|
DP,
|
||||||
|
CP
|
||||||
|
> extends React$Component<OP> {
|
||||||
|
static defaultProps: DP, // <= workaround for https://github.com/facebook/flow/issues/4644
|
||||||
|
static WrappedComponent: Class<React$Component<CP>>,
|
||||||
|
getWrappedInstance(): React$Component<CP>,
|
||||||
|
props: OP,
|
||||||
|
state: void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class ConnectedComponent<OP, P> extends React$Component<OP> {
|
||||||
|
static WrappedComponent: Class<React$Component<P>>,
|
||||||
|
getWrappedInstance(): React$Component<P>,
|
||||||
|
props: OP,
|
||||||
|
state: void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare type ConnectedComponentWithDefaultPropsClass<OP, DP, CP> = Class<
|
||||||
|
ConnectedComponentWithDefaultProps<OP, DP, CP>
|
||||||
|
>;
|
||||||
|
|
||||||
|
declare type ConnectedComponentClass<OP, P> = Class<
|
||||||
|
ConnectedComponent<OP, P>
|
||||||
|
>;
|
||||||
|
|
||||||
|
declare type Connector<OP, P> = (<DP: {}, CP: {}>(
|
||||||
|
component: ComponentWithDefaultProps<DP, P, CP>
|
||||||
|
) => ConnectedComponentWithDefaultPropsClass<OP, DP, CP>) &
|
||||||
|
((component: React$ComponentType<P>) => ConnectedComponentClass<OP, P>);
|
||||||
|
|
||||||
|
declare class Provider<S, A> extends React$Component<{
|
||||||
|
store: Store<S, A>,
|
||||||
|
children?: any
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare function createProvider(
|
||||||
|
storeKey?: string,
|
||||||
|
subKey?: string
|
||||||
|
): Provider<*, *>;
|
||||||
|
|
||||||
|
declare type ConnectOptions = {
|
||||||
|
pure?: boolean,
|
||||||
|
withRef?: boolean
|
||||||
|
};
|
||||||
|
|
||||||
|
declare type Null = null | void;
|
||||||
|
|
||||||
|
declare function connect<A, OP>(
|
||||||
|
...rest: Array<void> // <= workaround for https://github.com/facebook/flow/issues/2360
|
||||||
|
): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;
|
||||||
|
|
||||||
|
declare function connect<A, OP>(
|
||||||
|
mapStateToProps: Null,
|
||||||
|
mapDispatchToProps: Null,
|
||||||
|
mergeProps: Null,
|
||||||
|
options: ConnectOptions
|
||||||
|
): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;
|
||||||
|
|
||||||
|
declare function connect<S, A, OP, SP>(
|
||||||
|
mapStateToProps: MapStateToProps<S, OP, SP>,
|
||||||
|
mapDispatchToProps: Null,
|
||||||
|
mergeProps: Null,
|
||||||
|
options?: ConnectOptions
|
||||||
|
): Connector<OP, $Supertype<SP & { dispatch: Dispatch<A> } & OP>>;
|
||||||
|
|
||||||
|
declare function connect<A, OP, DP>(
|
||||||
|
mapStateToProps: Null,
|
||||||
|
mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
|
||||||
|
mergeProps: Null,
|
||||||
|
options?: ConnectOptions
|
||||||
|
): Connector<OP, $Supertype<DP & OP>>;
|
||||||
|
|
||||||
|
declare function connect<S, A, OP, SP, DP>(
|
||||||
|
mapStateToProps: MapStateToProps<S, OP, SP>,
|
||||||
|
mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
|
||||||
|
mergeProps: Null,
|
||||||
|
options?: ConnectOptions
|
||||||
|
): Connector<OP, $Supertype<SP & DP & OP>>;
|
||||||
|
|
||||||
|
declare function connect<S, A, OP, SP, DP, P>(
|
||||||
|
mapStateToProps: MapStateToProps<S, OP, SP>,
|
||||||
|
mapDispatchToProps: Null,
|
||||||
|
mergeProps: MergeProps<SP, DP, OP, P>,
|
||||||
|
options?: ConnectOptions
|
||||||
|
): Connector<OP, P>;
|
||||||
|
|
||||||
|
declare function connect<S, A, OP, SP, DP, P>(
|
||||||
|
mapStateToProps: MapStateToProps<S, OP, SP>,
|
||||||
|
mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
|
||||||
|
mergeProps: MergeProps<SP, DP, OP, P>,
|
||||||
|
options?: ConnectOptions
|
||||||
|
): Connector<OP, P>;
|
||||||
|
}
|
@ -0,0 +1,157 @@
|
|||||||
|
declare module "react-router-dom" {
|
||||||
|
declare export class BrowserRouter extends React$Component<{
|
||||||
|
basename?: string,
|
||||||
|
forceRefresh?: boolean,
|
||||||
|
getUserConfirmation?: GetUserConfirmation,
|
||||||
|
keyLength?: number,
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class HashRouter extends React$Component<{
|
||||||
|
basename?: string,
|
||||||
|
getUserConfirmation?: GetUserConfirmation,
|
||||||
|
hashType?: "slash" | "noslash" | "hashbang",
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Link extends React$Component<{
|
||||||
|
className?: string,
|
||||||
|
to: string | LocationShape,
|
||||||
|
replace?: boolean,
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class NavLink extends React$Component<{
|
||||||
|
to: string | LocationShape,
|
||||||
|
activeClassName?: string,
|
||||||
|
className?: string,
|
||||||
|
activeStyle?: Object,
|
||||||
|
style?: Object,
|
||||||
|
isActive?: (match: Match, location: Location) => boolean,
|
||||||
|
children?: React$Node,
|
||||||
|
exact?: boolean,
|
||||||
|
strict?: boolean
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
// NOTE: Below are duplicated from react-router. If updating these, please
|
||||||
|
// update the react-router and react-router-native types as well.
|
||||||
|
declare export type Location = {
|
||||||
|
pathname: string,
|
||||||
|
search: string,
|
||||||
|
hash: string,
|
||||||
|
state?: any,
|
||||||
|
key?: string
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type LocationShape = {
|
||||||
|
pathname?: string,
|
||||||
|
search?: string,
|
||||||
|
hash?: string,
|
||||||
|
state?: any
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type HistoryAction = "PUSH" | "REPLACE" | "POP";
|
||||||
|
|
||||||
|
declare export type RouterHistory = {
|
||||||
|
length: number,
|
||||||
|
location: Location,
|
||||||
|
action: HistoryAction,
|
||||||
|
listen(
|
||||||
|
callback: (location: Location, action: HistoryAction) => void
|
||||||
|
): () => void,
|
||||||
|
push(path: string | LocationShape, state?: any): void,
|
||||||
|
replace(path: string | LocationShape, state?: any): void,
|
||||||
|
go(n: number): void,
|
||||||
|
goBack(): void,
|
||||||
|
goForward(): void,
|
||||||
|
canGo?: (n: number) => boolean,
|
||||||
|
block(
|
||||||
|
callback: (location: Location, action: HistoryAction) => boolean
|
||||||
|
): void,
|
||||||
|
// createMemoryHistory
|
||||||
|
index?: number,
|
||||||
|
entries?: Array<Location>
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type Match = {
|
||||||
|
params: { [key: string]: ?string },
|
||||||
|
isExact: boolean,
|
||||||
|
path: string,
|
||||||
|
url: string
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type ContextRouter = {|
|
||||||
|
history: RouterHistory,
|
||||||
|
location: Location,
|
||||||
|
match: Match,
|
||||||
|
staticContext?: StaticRouterContext,
|
||||||
|
|};
|
||||||
|
|
||||||
|
declare export type GetUserConfirmation = (
|
||||||
|
message: string,
|
||||||
|
callback: (confirmed: boolean) => void
|
||||||
|
) => void;
|
||||||
|
|
||||||
|
declare type StaticRouterContext = {
|
||||||
|
url?: string
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export class StaticRouter extends React$Component<{
|
||||||
|
basename?: string,
|
||||||
|
location?: string | Location,
|
||||||
|
context: StaticRouterContext,
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class MemoryRouter extends React$Component<{
|
||||||
|
initialEntries?: Array<LocationShape | string>,
|
||||||
|
initialIndex?: number,
|
||||||
|
getUserConfirmation?: GetUserConfirmation,
|
||||||
|
keyLength?: number,
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Router extends React$Component<{
|
||||||
|
history: RouterHistory,
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Prompt extends React$Component<{
|
||||||
|
message: string | ((location: Location) => string | boolean),
|
||||||
|
when?: boolean
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Redirect extends React$Component<{
|
||||||
|
to: string | LocationShape,
|
||||||
|
push?: boolean
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Route extends React$Component<{
|
||||||
|
component?: React$ComponentType<*>,
|
||||||
|
render?: (router: ContextRouter) => React$Node,
|
||||||
|
children?: React$ComponentType<ContextRouter> | React$Node,
|
||||||
|
path?: string,
|
||||||
|
exact?: boolean,
|
||||||
|
strict?: boolean
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Switch extends React$Component<{
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export function withRouter<P>(
|
||||||
|
Component: React$ComponentType<{| ...ContextRouter, ...P |}>
|
||||||
|
): React$ComponentType<P>;
|
||||||
|
|
||||||
|
declare type MatchPathOptions = {
|
||||||
|
path?: string,
|
||||||
|
exact?: boolean,
|
||||||
|
sensitive?: boolean,
|
||||||
|
strict?: boolean
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export function matchPath(
|
||||||
|
pathname: string,
|
||||||
|
options?: MatchPathOptions | string
|
||||||
|
): null | Match;
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
import type {
|
||||||
|
RouterHistory,
|
||||||
|
Location as RouterLocation
|
||||||
|
} from 'react-router';
|
||||||
|
|
||||||
|
declare module "react-router-redux" {
|
||||||
|
|
||||||
|
// custom state for location
|
||||||
|
declare export type LocationState = {[key: string] : string};
|
||||||
|
|
||||||
|
declare export type Location = {
|
||||||
|
pathname: string,
|
||||||
|
search: string,
|
||||||
|
hash: string,
|
||||||
|
key?: string,
|
||||||
|
state: LocationState
|
||||||
|
}
|
||||||
|
|
||||||
|
declare export var LOCATION_CHANGE: "@@router/LOCATION_CHANGE";
|
||||||
|
|
||||||
|
declare export type RouterAction = {
|
||||||
|
type: typeof LOCATION_CHANGE,
|
||||||
|
// type: "@@router/LOCATION_CHANGE",
|
||||||
|
payload: Location;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare export type State = {
|
||||||
|
location: Location; // should be ?Location
|
||||||
|
}
|
||||||
|
|
||||||
|
declare export function push(a: string): void;
|
||||||
|
declare export function replace(a: string): void;
|
||||||
|
declare export function go(a: string): void;
|
||||||
|
declare export function goBack(): void;
|
||||||
|
declare export function goForward(): void;
|
||||||
|
|
||||||
|
//declare export function routerReducer<S, A>(state?: S, action: A): S;
|
||||||
|
declare export function routerReducer(state?: State, action: any): State;
|
||||||
|
declare export function routerMiddleware(history: any): any;
|
||||||
|
|
||||||
|
declare export class ConnectedRouter extends React$Component<{
|
||||||
|
history: any
|
||||||
|
}> {}
|
||||||
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
declare module "react-router" {
|
||||||
|
// NOTE: many of these are re-exported by react-router-dom and
|
||||||
|
// react-router-native, so when making changes, please be sure to update those
|
||||||
|
// as well.
|
||||||
|
declare export type Location = {
|
||||||
|
pathname: string,
|
||||||
|
search: string,
|
||||||
|
hash: string,
|
||||||
|
state?: any,
|
||||||
|
key?: string
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type LocationShape = {
|
||||||
|
pathname?: string,
|
||||||
|
search?: string,
|
||||||
|
hash?: string,
|
||||||
|
state?: any
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type HistoryAction = "PUSH" | "REPLACE" | "POP";
|
||||||
|
|
||||||
|
declare export type RouterHistory = {
|
||||||
|
length: number,
|
||||||
|
location: Location,
|
||||||
|
action: HistoryAction,
|
||||||
|
listen(
|
||||||
|
callback: (location: Location, action: HistoryAction) => void
|
||||||
|
): () => void,
|
||||||
|
push(path: string | LocationShape, state?: any): void,
|
||||||
|
replace(path: string | LocationShape, state?: any): void,
|
||||||
|
go(n: number): void,
|
||||||
|
goBack(): void,
|
||||||
|
goForward(): void,
|
||||||
|
canGo?: (n: number) => boolean,
|
||||||
|
block(
|
||||||
|
callback: (location: Location, action: HistoryAction) => boolean
|
||||||
|
): void,
|
||||||
|
// createMemoryHistory
|
||||||
|
index?: number,
|
||||||
|
entries?: Array<Location>
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type Match = {
|
||||||
|
params: { [key: string]: ?string },
|
||||||
|
isExact: boolean,
|
||||||
|
path: string,
|
||||||
|
url: string
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type ContextRouter = {|
|
||||||
|
history: RouterHistory,
|
||||||
|
location: Location,
|
||||||
|
match: Match,
|
||||||
|
staticContext?: StaticRouterContext
|
||||||
|
|};
|
||||||
|
|
||||||
|
declare export type GetUserConfirmation = (
|
||||||
|
message: string,
|
||||||
|
callback: (confirmed: boolean) => void
|
||||||
|
) => void;
|
||||||
|
|
||||||
|
declare type StaticRouterContext = {
|
||||||
|
url?: string
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export class StaticRouter extends React$Component<{
|
||||||
|
basename?: string,
|
||||||
|
location?: string | Location,
|
||||||
|
context: StaticRouterContext,
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class MemoryRouter extends React$Component<{
|
||||||
|
initialEntries?: Array<LocationShape | string>,
|
||||||
|
initialIndex?: number,
|
||||||
|
getUserConfirmation?: GetUserConfirmation,
|
||||||
|
keyLength?: number,
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Router extends React$Component<{
|
||||||
|
history: RouterHistory,
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Prompt extends React$Component<{
|
||||||
|
message: string | ((location: Location) => string | true),
|
||||||
|
when?: boolean
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Redirect extends React$Component<{
|
||||||
|
to: string | LocationShape,
|
||||||
|
push?: boolean
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Route extends React$Component<{
|
||||||
|
component?: React$ComponentType<*>,
|
||||||
|
render?: (router: ContextRouter) => React$Node,
|
||||||
|
children?: React$ComponentType<ContextRouter> | React$Node,
|
||||||
|
path?: string,
|
||||||
|
exact?: boolean,
|
||||||
|
strict?: boolean
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export class Switch extends React$Component<{
|
||||||
|
children?: React$Node
|
||||||
|
}> {}
|
||||||
|
|
||||||
|
declare export function withRouter<P>(
|
||||||
|
Component: React$ComponentType<{| ...ContextRouter, ...P |}>
|
||||||
|
): React$ComponentType<P>;
|
||||||
|
|
||||||
|
declare type MatchPathOptions = {
|
||||||
|
path?: string,
|
||||||
|
exact?: boolean,
|
||||||
|
strict?: boolean,
|
||||||
|
sensitive?: boolean
|
||||||
|
};
|
||||||
|
declare export function matchPath(
|
||||||
|
pathname: string,
|
||||||
|
options?: MatchPathOptions | string
|
||||||
|
): null | Match;
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
// flow-typed signature: cca4916b0213065533df8335c3285a4a
|
||||||
|
// flow-typed version: cab04034e7/redux_v3.x.x/flow_>=v0.55.x
|
||||||
|
|
||||||
|
declare module 'redux' {
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
S = State
|
||||||
|
A = Action
|
||||||
|
D = Dispatch
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare export type DispatchAPI<A> = (action: A) => A;
|
||||||
|
// declare export type Dispatch<A: { type: $Subtype<string> }> = DispatchAPI<A>;
|
||||||
|
|
||||||
|
declare export type ThunkAction<S, A> = (dispatch: Dispatch<S, A>, getState: () => S) => Promise<void> | void;
|
||||||
|
declare export type ThunkDispatch<S, A> = (action: ThunkAction<S, A>) => void;
|
||||||
|
|
||||||
|
declare export type PlainDispatch<A: {type: $Subtype<string>}> = DispatchAPI<A>;
|
||||||
|
/* NEW: Dispatch is now a combination of these different dispatch types */
|
||||||
|
declare export type Dispatch<S, A> = PlainDispatch<A> & ThunkDispatch<S, A>;
|
||||||
|
|
||||||
|
// declare export type ThunkAction<S, D> = (dispatch: D, getState: () => S) => Promise<void> | void;
|
||||||
|
// declare type ThunkDispatch<S, D> = (action: ThunkAction<S, D & ThunkDispatch<S, D>>) => void;
|
||||||
|
|
||||||
|
declare export type MiddlewareAPI<S, A> = {
|
||||||
|
dispatch: Dispatch<S, A>;
|
||||||
|
getState(): S;
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type Store<S, A, D = Dispatch<S, A>> = {
|
||||||
|
// rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)
|
||||||
|
dispatch: D;
|
||||||
|
getState(): S;
|
||||||
|
subscribe(listener: () => void): () => void;
|
||||||
|
replaceReducer(nextReducer: Reducer<S, A>): void
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type Reducer<S, A> = (state: S | void, action: A) => S;
|
||||||
|
|
||||||
|
declare export type CombinedReducer<S, A> = (state: $Shape<S> & {} | void, action: A) => S;
|
||||||
|
|
||||||
|
declare export type Middleware<S, A> =
|
||||||
|
(api: MiddlewareAPI<S, A>) =>
|
||||||
|
(next: PlainDispatch<A>) => PlainDispatch<A>;
|
||||||
|
|
||||||
|
declare export type StoreCreator<S, A, D = Dispatch<S, A>> = {
|
||||||
|
(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
|
||||||
|
(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
|
||||||
|
};
|
||||||
|
|
||||||
|
declare export type StoreEnhancer<S, A, D = Dispatch<S, A>> = (next: StoreCreator<S, A, D>) => StoreCreator<S, A, D>;
|
||||||
|
|
||||||
|
declare export function createStore<S, A, D>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
|
||||||
|
declare export function createStore<S, A, D>(reducer: Reducer<S, A>, preloadedState?: S, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
|
||||||
|
|
||||||
|
declare export function applyMiddleware<S, A, D>(...middlewares: Array<Middleware<S, A>>): StoreEnhancer<S, A, D>;
|
||||||
|
|
||||||
|
declare export type ActionCreator<A, B> = (...args: Array<B>) => A;
|
||||||
|
declare export type ActionCreators<K, A> = { [key: K]: ActionCreator<A, any> };
|
||||||
|
|
||||||
|
declare export function bindActionCreators<A, C: ActionCreator<A, any>, D: DispatchAPI<A>>(actionCreator: C, dispatch: D): C;
|
||||||
|
declare export function bindActionCreators<A, K, C: ActionCreators<K, A>, D: DispatchAPI<A>>(actionCreators: C, dispatch: D): C;
|
||||||
|
// declare export function bindActionCreators<A, C: ActionCreator<A, any>, D: Dispatch>(actionCreator: C, dispatch: D): C;
|
||||||
|
// declare export function bindActionCreators<A, K, C: ActionCreators<K, A>, D: Dispatch>(actionCreators: C, dispatch: D): C;
|
||||||
|
|
||||||
|
declare export function combineReducers<O: Object, A>(reducers: O): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
|
||||||
|
|
||||||
|
declare export var compose: $Compose;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,195 @@
|
|||||||
|
declare module 'trezor-connect' {
|
||||||
|
|
||||||
|
// CONSTANTS (from trezor-connect/src/js/constants)
|
||||||
|
|
||||||
|
declare type T_DEVICE_EVENT = 'DEVICE_EVENT';
|
||||||
|
declare type T_DEVICE = {
|
||||||
|
CONNECT: 'device__connect',
|
||||||
|
CONNECT_UNACQUIRED: 'device__connect_unacquired',
|
||||||
|
DISCONNECT: 'device__disconnect',
|
||||||
|
DISCONNECT_UNACQUIRED: 'device__disconnect_unacquired',
|
||||||
|
|
||||||
|
ACQUIRE: 'device__acquire', // remove? internal
|
||||||
|
RELEASE: 'device__release', // internal
|
||||||
|
ACQUIRED: 'device__acquired',
|
||||||
|
RELEASED: 'device__released', // internal
|
||||||
|
USED_ELSEWHERE: 'device__used_elsewhere', // internal
|
||||||
|
CHANGED: 'device__changed',
|
||||||
|
|
||||||
|
LOADING: 'device__loading', // internal
|
||||||
|
|
||||||
|
// trezor-link events
|
||||||
|
BUTTON: 'button',
|
||||||
|
PIN: 'pin',
|
||||||
|
PASSPHRASE: 'passphrase',
|
||||||
|
PASSPHRASE_ON_DEVICE: 'passphrase_on_device',
|
||||||
|
WORD: 'word',
|
||||||
|
|
||||||
|
// custom (not emitted)
|
||||||
|
// AUTHENTICATED: 'device__authenticated',
|
||||||
|
// WAIT_FOR_SELECTION: 'device__wait_for_selection',
|
||||||
|
};
|
||||||
|
|
||||||
|
declare type T_UI_EVENT = 'UI_EVENT';
|
||||||
|
declare type T_UI = {
|
||||||
|
TRANSPORT: 'ui-no_transport',
|
||||||
|
BOOTLOADER: 'ui-device_bootloader_mode',
|
||||||
|
INITIALIZE: 'ui-device_not_initialized',
|
||||||
|
FIRMWARE: 'ui-device_firmware_old',
|
||||||
|
BROWSER_NOT_SUPPORTED: 'ui-browser_not_supported',
|
||||||
|
BROWSER_OUTDATED: 'ui-browser_outdated',
|
||||||
|
RECEIVE_BROWSER: 'ui-receive_browser',
|
||||||
|
REQUEST_UI_WINDOW: 'ui-request_window',
|
||||||
|
CLOSE_UI_WINDOW: 'ui-close_window',
|
||||||
|
REQUEST_PERMISSION: 'ui-request_permission',
|
||||||
|
REQUEST_CONFIRMATION: 'ui-request_confirmation',
|
||||||
|
REQUEST_PIN: 'ui-request_pin',
|
||||||
|
INVALID_PIN: 'ui-invalid_pin',
|
||||||
|
REQUEST_PASSPHRASE: 'ui-request_passphrase',
|
||||||
|
REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request_passphrase_on_device',
|
||||||
|
CONNECT: 'ui-connect',
|
||||||
|
LOADING: 'ui-loading',
|
||||||
|
SET_OPERATION: 'ui-set_operation',
|
||||||
|
SELECT_DEVICE: 'ui-select_device',
|
||||||
|
SELECT_ACCOUNT: 'ui-select_account',
|
||||||
|
SELECT_FEE: 'ui-select_fee',
|
||||||
|
UPDATE_CUSTOM_FEE: 'ui-update_custom_fee',
|
||||||
|
INSUFFICIENT_FUNDS: 'ui-insufficient_funds',
|
||||||
|
REQUEST_BUTTON: 'ui-button',
|
||||||
|
RECEIVE_PERMISSION: 'ui-receive_permission',
|
||||||
|
RECEIVE_CONFIRMATION: 'ui-receive_confirmation',
|
||||||
|
RECEIVE_PIN: 'ui-receive_pin',
|
||||||
|
RECEIVE_PASSPHRASE: 'ui-receive_passphrase',
|
||||||
|
RECEIVE_DEVICE: 'ui-receive_device',
|
||||||
|
CHANGE_ACCOUNT: 'ui-change_account',
|
||||||
|
RECEIVE_ACCOUNT: 'ui-receive_account',
|
||||||
|
RECEIVE_FEE: 'ui-receive_fee',
|
||||||
|
CHANGE_SETTINGS: 'ui-change_settings',
|
||||||
|
};
|
||||||
|
|
||||||
|
declare type T_TRANSPORT_EVENT = 'TRANSPORT_EVENT';
|
||||||
|
declare type T_TRANSPORT = {
|
||||||
|
START: 'transport__start',
|
||||||
|
ERROR: 'transport__error',
|
||||||
|
UPDATE: 'transport__update',
|
||||||
|
STREAM: 'transport__stream',
|
||||||
|
REQUEST: 'transport__request_device',
|
||||||
|
UNREADABLE: 'transport__unreadable_hid_device',
|
||||||
|
RECONNECT: 'transport__reconnect'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
declare export type ResponseMessage = {
|
||||||
|
event: string;
|
||||||
|
type: string;
|
||||||
|
id: number;
|
||||||
|
success: boolean;
|
||||||
|
payload: Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare export type UiMessageType = $Values<T_UI>;
|
||||||
|
declare export type UiMessage = {
|
||||||
|
event: string;
|
||||||
|
type: UiMessageType;
|
||||||
|
payload: Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare export type DeviceMessageType = $Values<T_DEVICE>;
|
||||||
|
declare export type DeviceMessage = {
|
||||||
|
event: string;
|
||||||
|
type: DeviceMessageType;
|
||||||
|
payload: Device;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare export type TransportMessageType = $Values<T_TRANSPORT>;
|
||||||
|
declare export type TransportMessage = {
|
||||||
|
event: string;
|
||||||
|
type: TransportMessageType;
|
||||||
|
payload: Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare export type Device = {
|
||||||
|
path: string,
|
||||||
|
label: string,
|
||||||
|
isUsedElsewhere: boolean,
|
||||||
|
featuresNeedsReload: boolean,
|
||||||
|
unacquired?: boolean,
|
||||||
|
features: Features,
|
||||||
|
}
|
||||||
|
|
||||||
|
declare export type Features = {
|
||||||
|
vendor: string,
|
||||||
|
major_version: number,
|
||||||
|
minor_version: number,
|
||||||
|
patch_version: number,
|
||||||
|
bootloader_mode: boolean,
|
||||||
|
device_id: string,
|
||||||
|
pin_protection: boolean,
|
||||||
|
passphrase_protection: boolean,
|
||||||
|
language: string,
|
||||||
|
label: string,
|
||||||
|
// coins: CoinType[],
|
||||||
|
coins: Array<any>,
|
||||||
|
initialized: boolean,
|
||||||
|
revision: string,
|
||||||
|
bootloader_hash: string,
|
||||||
|
imported: boolean,
|
||||||
|
pin_cached: boolean,
|
||||||
|
passphrase_cached: boolean,
|
||||||
|
state?: string;
|
||||||
|
needs_backup?: boolean,
|
||||||
|
firmware_present?: boolean,
|
||||||
|
}
|
||||||
|
|
||||||
|
// declare export interface TrezorConnect = {
|
||||||
|
// on: (type: string, handler: (event: any) => void) => void;
|
||||||
|
// }
|
||||||
|
|
||||||
|
declare type OnEvents = "device__event";
|
||||||
|
|
||||||
|
// declare type TRANSPORT = {
|
||||||
|
// ERROR: 'transport__error';
|
||||||
|
// READY: 'transport__ready';
|
||||||
|
// }
|
||||||
|
|
||||||
|
declare type DeviceEventListener = (type: T_DEVICE_EVENT, handler: (event: DeviceMessage) => void) => void;
|
||||||
|
declare type DeviceEventListenerByType = (type: DeviceMessageType, handler: (device: Device) => void) => void;
|
||||||
|
declare type UiEventListener = (type: T_UI_EVENT, handler: (event: UiMessage) => void) => void;
|
||||||
|
declare type TransportEventListener = (type: T_TRANSPORT_EVENT, handler: (event: TransportMessage) => void) => void;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
declare module.exports: {
|
||||||
|
init: (options: Object) => Promise<Object>;
|
||||||
|
// on: (type: string, handler: (event: any) => void) => void;
|
||||||
|
on: DeviceEventListener & DeviceEventListenerByType & UiEventListener & TransportEventListener;
|
||||||
|
off: (type: string, handler: (event: any) => void) => void;
|
||||||
|
getVersion: () => any;
|
||||||
|
renderWebUSBButton: (className?: string) => void;
|
||||||
|
|
||||||
|
getDeviceState: (options: Object) => Promise<Object>;
|
||||||
|
getFeatures: (options: Object) => Promise<Object>;
|
||||||
|
getPublicKey: (options: Object) => Promise<Object>;
|
||||||
|
ethereumGetAddress: (options: Object) => Promise<Object>;
|
||||||
|
uiResponse: (options: Object) => Promise<Object>;
|
||||||
|
|
||||||
|
ethereumSignTransaction: (options: Object) => Promise<Object>;
|
||||||
|
|
||||||
|
|
||||||
|
// export const RESPONSE_EVENT: string = 'RESPONSE_EVENT';
|
||||||
|
// export const ERROR_EVENT: string = 'ERROR_EVENT';
|
||||||
|
|
||||||
|
DEVICE_EVENT: T_DEVICE_EVENT;
|
||||||
|
DEVICE: T_DEVICE;
|
||||||
|
|
||||||
|
|
||||||
|
UI_EVENT: T_UI_EVENT;
|
||||||
|
UI: T_UI;
|
||||||
|
|
||||||
|
TRANSPORT_EVENT: T_TRANSPORT_EVENT;
|
||||||
|
TRANSPORT: T_TRANSPORT;
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
declare module 'web3' {
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
eth: {
|
||||||
|
_requestManager: any;
|
||||||
|
iban: {
|
||||||
|
(iban: string): void;
|
||||||
|
fromAddress: (address: string) => any;
|
||||||
|
fromBban: (bban: string) => any;
|
||||||
|
createIndirect: (options: any) => any;
|
||||||
|
isValid: (iban: string) => boolean;
|
||||||
|
};
|
||||||
|
sendIBANTransaction: any;
|
||||||
|
contract: (abi: any) => {
|
||||||
|
eth: any;
|
||||||
|
abi: any[];
|
||||||
|
new: (...args: any[]) => {
|
||||||
|
_eth: any;
|
||||||
|
transactionHash: any;
|
||||||
|
address: any;
|
||||||
|
abi: any[];
|
||||||
|
};
|
||||||
|
at: (address: any, callback: Function) => any;
|
||||||
|
getData: (...args: any[]) => any;
|
||||||
|
};
|
||||||
|
filter: (fil: any, callback: any, filterCreationErrorCallback: any) => {
|
||||||
|
requestManager: any;
|
||||||
|
options: any;
|
||||||
|
implementation: {
|
||||||
|
[x: string]: any;
|
||||||
|
};
|
||||||
|
filterId: any;
|
||||||
|
callbacks: any[];
|
||||||
|
getLogsCallbacks: any[];
|
||||||
|
pollFilters: any[];
|
||||||
|
formatter: any;
|
||||||
|
watch: (callback: any) => any;
|
||||||
|
stopWatching: (callback: any) => any;
|
||||||
|
get: (callback: any) => any;
|
||||||
|
};
|
||||||
|
namereg: () => {
|
||||||
|
eth: any;
|
||||||
|
abi: any[];
|
||||||
|
new: (...args: any[]) => {
|
||||||
|
_eth: any;
|
||||||
|
transactionHash: any;
|
||||||
|
address: any;
|
||||||
|
abi: any[];
|
||||||
|
};
|
||||||
|
at: (address: any, callback: Function) => any;
|
||||||
|
getData: (...args: any[]) => any;
|
||||||
|
};
|
||||||
|
icapNamereg: () => {
|
||||||
|
eth: any;
|
||||||
|
abi: any[];
|
||||||
|
new: (...args: any[]) => {
|
||||||
|
_eth: any;
|
||||||
|
transactionHash: any;
|
||||||
|
address: any;
|
||||||
|
abi: any[];
|
||||||
|
};
|
||||||
|
at: (address: any, callback: Function) => any;
|
||||||
|
getData: (...args: any[]) => any;
|
||||||
|
};
|
||||||
|
isSyncing: (callback: any) => {
|
||||||
|
requestManager: any;
|
||||||
|
pollId: string;
|
||||||
|
callbacks: any[];
|
||||||
|
lastSyncState: boolean;
|
||||||
|
addCallback: (callback: any) => any;
|
||||||
|
stopWatching: () => void;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue