mirror of https://github.com/trezor/trezor-wallet
parent
0bc4dd3cf9
commit
1c89f3e975
@ -0,0 +1,55 @@
|
||||
declare module 'bignumber.js' {
|
||||
declare type $npm$big$number$object = number | string | BigNumber
|
||||
declare type $npm$cmp$result = -1 | 0 | 1
|
||||
declare type DIGIT = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
||||
declare type ROUND_DOWN = 0
|
||||
declare type ROUND_HALF_UP = 1
|
||||
declare type ROUND_HALF_EVEN = 2
|
||||
declare type ROUND_UP = 3
|
||||
declare type RM = ROUND_DOWN | ROUND_HALF_UP | ROUND_HALF_EVEN | ROUND_UP
|
||||
|
||||
declare class BigNumber {
|
||||
// Properties
|
||||
static DP: number;
|
||||
static RM: RM;
|
||||
static E_NEG: number;
|
||||
static E_POS: number;
|
||||
|
||||
c: Array<DIGIT>;
|
||||
e: number;
|
||||
s: -1 | 1;
|
||||
|
||||
// Constructors
|
||||
static (value: $npm$big$number$object): BigNumber;
|
||||
constructor(value: $npm$big$number$object): BigNumber;
|
||||
|
||||
// Methods
|
||||
abs(): BigNumber;
|
||||
cmp(n: $npm$big$number$object): $npm$cmp$result;
|
||||
div(n: $npm$big$number$object): BigNumber;
|
||||
dividedBy(n: $npm$big$number$object): BigNumber;
|
||||
eq(n: $npm$big$number$object): boolean;
|
||||
gt(n: $npm$big$number$object): boolean;
|
||||
greaterThan(n: $npm$big$number$object): boolean;
|
||||
gte(n: $npm$big$number$object): boolean;
|
||||
lt(n: $npm$big$number$object): boolean;
|
||||
lessThan(n: $npm$big$number$object): boolean;
|
||||
lte(n: $npm$big$number$object): boolean;
|
||||
lessThanOrEqualTo(n: $npm$big$number$object): boolean;
|
||||
minus(n: $npm$big$number$object): BigNumber;
|
||||
mod(n: $npm$big$number$object): BigNumber;
|
||||
plus(n: $npm$big$number$object): BigNumber;
|
||||
pow(exp: number): BigNumber;
|
||||
round(dp: ?number, rm: ?RM): BigNumber;
|
||||
sqrt(): BigNumber;
|
||||
times(n: $npm$big$number$object): BigNumber;
|
||||
toExponential(dp: ?number): string;
|
||||
toFixed(dp: ?number): string;
|
||||
toPrecision(sd: ?number): string;
|
||||
toString(): string;
|
||||
valueOf(): string;
|
||||
toJSON(): string;
|
||||
}
|
||||
|
||||
declare module.exports: typeof BigNumber
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
declare module 'ethereum-types' {
|
||||
// start data types
|
||||
declare export type EthereumUnitT =
|
||||
| 'kwei'
|
||||
| 'ada'
|
||||
| 'mwei'
|
||||
| 'babbage'
|
||||
| 'gwei'
|
||||
| 'shannon'
|
||||
| 'szabo'
|
||||
| 'finney'
|
||||
| 'ether'
|
||||
| 'kether'
|
||||
| 'grand'
|
||||
| 'einstein'
|
||||
| 'mether'
|
||||
| 'gether'
|
||||
| 'tether'
|
||||
|
||||
declare export type EthereumAddressT = string
|
||||
declare export type EthereumBlockNumberT = number
|
||||
declare export type EthereumBlockHashT = string
|
||||
declare export type EthereumTransactionHashT = string
|
||||
// end data types
|
||||
|
||||
// start contract types
|
||||
declare export type EthereumWatchErrorT = ?Object
|
||||
|
||||
declare export type EthereumEventT<A> = {
|
||||
address: EthereumAddressT,
|
||||
args: A,
|
||||
blockHash: EthereumBlockHashT,
|
||||
blockNumber: number,
|
||||
event: string,
|
||||
logIndex: number,
|
||||
transactionHash: EthereumTransactionHashT,
|
||||
transactionIndex: number,
|
||||
transactionLogIndex: string,
|
||||
type: 'mined' // TODO: what other types are there?
|
||||
}
|
||||
|
||||
// this represents the setup object returned from truffle-contract
|
||||
// we use it to get a known contact `at(address)` (ie. for POATokenContract addresses)
|
||||
declare export type EthereumContractSetupT<A> = {
|
||||
at: EthereumAddressT => Promise<A>
|
||||
}
|
||||
|
||||
declare export type EthereumSendTransactionOptionsT = {
|
||||
from: EthereumAddressT,
|
||||
gas: number,
|
||||
value?: number
|
||||
}
|
||||
|
||||
declare export type EthereumSendTransactionT = EthereumSendTransactionOptionsT => Promise<
|
||||
EthereumTransactionHashT
|
||||
>
|
||||
|
||||
// TODO(mattgstevens): it would be nice to have an Generic type for a Contract instance
|
||||
// similar to the EthererumWatchEventT
|
||||
//
|
||||
// declare export type SendTransactionContractT = interface .sendTransaction(EthereumAddressT)
|
||||
// declare export type WatchableContractT = <A>(error: Object, response: A)
|
||||
|
||||
// declare export type EthereumContractWatcherT = (options: {
|
||||
// fromBlock?: EthereumBlockNumberT,
|
||||
// toBlock?: EthereumBlockNumberT,
|
||||
// address?: EthereumAddressT
|
||||
// }) => *
|
||||
|
||||
// end contract data
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
/* @flow */
|
||||
'use strict';
|
||||
|
||||
import * as LogActions from '../actions/LogActions';
|
||||
import * as STORAGE from '../actions/constants/localStorage';
|
||||
import { OPEN, CLOSE, ADD } from '../actions/constants/log';
|
||||
|
||||
import type {
|
||||
Middleware,
|
||||
MiddlewareAPI,
|
||||
MiddlewareDispatch,
|
||||
State,
|
||||
Dispatch,
|
||||
Action,
|
||||
AsyncAction,
|
||||
GetState
|
||||
} from '../flowtype';
|
||||
|
||||
const exclude: Array<string> = [
|
||||
ADD, OPEN, CLOSE,
|
||||
STORAGE.READY,
|
||||
"web3__create"
|
||||
];
|
||||
|
||||
/**
|
||||
* Middleware
|
||||
*/
|
||||
const LogService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispatch) => (action: Action): Action => {
|
||||
|
||||
next(action);
|
||||
|
||||
if (exclude.indexOf(action.type) < 0) {
|
||||
// api.dispatch(LogActions.add(action.type, JSON.stringify( action )));
|
||||
api.dispatch(LogActions.add(action.type, action));
|
||||
}
|
||||
|
||||
return action;
|
||||
};
|
||||
|
||||
export default LogService;
|
Loading…
Reference in new issue