More typings, declaration files.
This commit is contained in:
parent
3c8e72a3ae
commit
a371d6449a
|
@ -16,7 +16,7 @@ interface Props {
|
|||
}
|
||||
|
||||
interface TrackedTokens {
|
||||
[symbol: string]: any;
|
||||
[symbol: string]: boolean;
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
@ -25,7 +25,7 @@ interface State {
|
|||
}
|
||||
export default class TokenBalances extends React.PureComponent<Props, State> {
|
||||
public state = {
|
||||
trackedTokens: {},
|
||||
trackedTokens: {} as TrackedTokens,
|
||||
showCustomTokenForm: false
|
||||
};
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ class LedgerNanoSDecryptClass extends PureComponent<Props, State> {
|
|||
ledger.comm_u2f.create_async().then((comm: any) => {
|
||||
new ledger.eth(comm)
|
||||
.getAddress_async(dPath, false, true)
|
||||
.then((res: any) => {
|
||||
.then(res => {
|
||||
this.setState({
|
||||
publicKey: res.publicKey,
|
||||
chainCode: res.chainCode,
|
||||
|
|
|
@ -6,7 +6,16 @@ import Ropsten from './ropsten.json';
|
|||
import RSK from './rsk.json';
|
||||
import UBQ from './ubq.json';
|
||||
|
||||
export default {
|
||||
export interface ContractData {
|
||||
name: string;
|
||||
address: string;
|
||||
abi: string;
|
||||
}
|
||||
export interface Networks {
|
||||
[key: string]: ContractData[];
|
||||
}
|
||||
|
||||
const NetworkTypes: Networks = {
|
||||
ETC,
|
||||
ETH,
|
||||
EXP,
|
||||
|
@ -15,3 +24,5 @@ export default {
|
|||
RSK,
|
||||
UBQ
|
||||
};
|
||||
|
||||
export default NetworkTypes;
|
||||
|
|
|
@ -81,6 +81,10 @@ export interface CustomNodeConfig {
|
|||
};
|
||||
}
|
||||
|
||||
export interface Networks {
|
||||
[key: string]: NetworkConfig;
|
||||
}
|
||||
|
||||
// Must be a website that follows the ethplorer convention of /tx/[hash] and
|
||||
// address/[address] to generate the correct functions.
|
||||
function makeExplorer(origin: string): BlockExplorerConfig {
|
||||
|
@ -205,7 +209,7 @@ const EXP: NetworkConfig = {
|
|||
}
|
||||
};
|
||||
|
||||
export const NETWORKS = {
|
||||
export const NETWORKS: Networks = {
|
||||
ETH,
|
||||
Ropsten,
|
||||
Kovan,
|
||||
|
|
|
@ -7,7 +7,17 @@ import Ropsten from './ropsten.json';
|
|||
import RSK from './rsk.json';
|
||||
import UBQ from './ubq.json';
|
||||
|
||||
export default {
|
||||
export interface Token {
|
||||
address: string;
|
||||
symbol: string;
|
||||
decimal: number;
|
||||
error?: string | null;
|
||||
}
|
||||
export interface Tokens {
|
||||
[key: string]: Token;
|
||||
}
|
||||
|
||||
const TokenTypes: Tokens = {
|
||||
ETC,
|
||||
ETH,
|
||||
EXP,
|
||||
|
@ -17,3 +27,5 @@ export default {
|
|||
RSK,
|
||||
UBQ
|
||||
};
|
||||
|
||||
export default TokenTypes;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
declare module 'ethjs-util' {
|
||||
export function arrayContainsArray(arrayA: any[], arrayB: any[]): Boolean;
|
||||
export function getBinarySize(num: string): number;
|
||||
export function intToBuffer(integer: number): Buffer;
|
||||
export function isHexPrefixed(hex: string): boolean;
|
||||
export function stripHexPrefix(hexWithPrefix: string): string;
|
||||
export function padToEven(unpaddedNumber: string): string;
|
||||
export function intToHex(integer: number): string;
|
||||
export function fromAscii(ascii: string): string;
|
||||
export function fromUtf8(utf8: string): string;
|
||||
export function toAscii(nonAscii: string): string;
|
||||
export function toUtf8(nonUtf8: string): string;
|
||||
export function getKeys(keys: any[], query: string): any[];
|
||||
export function isHexString(inputString: string): boolean;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
declare module 'hdkey' {
|
||||
export function fromMasterSeed(seed: Buffer): any;
|
||||
}
|
|
@ -10,6 +10,8 @@
|
|||
"npm": ">= 5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/enzyme": "3.1.8",
|
||||
"@types/enzyme-adapter-react-16": "1.0.1",
|
||||
"babel-polyfill": "6.26.0",
|
||||
"bip39": "2.5.0",
|
||||
"bn.js": "4.11.8",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { NODES, NodeConfig } from 'config';
|
||||
import { RPCNode } from '../../common/libs/nodes';
|
||||
import { Validator } from 'jsonschema';
|
||||
import { Validator, ValidatorResult } from 'jsonschema';
|
||||
import { schema } from '../../common/libs/validators';
|
||||
import 'url-search-params-polyfill';
|
||||
import EtherscanNode from 'libs/nodes/etherscan';
|
||||
|
@ -24,6 +24,10 @@ const validRequests = {
|
|||
}
|
||||
};
|
||||
|
||||
interface RPCTestList {
|
||||
[key: string]: ((n: RPCNode) => Promise<ValidatorResult>);
|
||||
}
|
||||
|
||||
const testGetBalance = (n: RPCNode) => {
|
||||
return n.client
|
||||
.call(n.requests.getBalance(validRequests.address))
|
||||
|
@ -43,7 +47,7 @@ const testGetTokenBalance = (n: RPCNode) => {
|
|||
.then(data => v.validate(data, schema.RpcNode));
|
||||
};
|
||||
|
||||
const RPCTests = {
|
||||
const RPCTests: RPCTestList = {
|
||||
getBalance: testGetBalance,
|
||||
estimateGas: testEstimateGas,
|
||||
getTokenBalance: testGetTokenBalance
|
||||
|
|
|
@ -9,7 +9,7 @@ const dockerTag = 'latest';
|
|||
|
||||
function promiseFromChildProcess(command: string): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
return exec(command, (err, stdout) => {
|
||||
return exec(command, (err: any, stdout: any) => {
|
||||
err ? reject(err) : resolve(stdout);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,11 +8,12 @@ import {
|
|||
import { normalize } from 'normalizr';
|
||||
import * as schema from 'reducers/swap/schema';
|
||||
import { TypeKeys } from 'actions/swap/constants';
|
||||
import { Token } from 'config/tokens';
|
||||
import tokens from 'config/tokens/eth.json';
|
||||
import { SHAPESHIFT_TOKEN_WHITELIST } from 'api/shapeshift';
|
||||
|
||||
describe('ensure whitelist', () => {
|
||||
const findToken = (tkn: string) => tokens.find(t => t.symbol === tkn);
|
||||
const findToken = (tkn: string) => tokens.find((t: Token) => t.symbol === tkn);
|
||||
SHAPESHIFT_TOKEN_WHITELIST.forEach(t => {
|
||||
it(`Should find Token ${t}`, () => {
|
||||
expect(findToken(t)).toBeTruthy();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { configuredStore } from 'store';
|
||||
import { delay } from 'redux-saga';
|
||||
import { delay, SagaIterator } from 'redux-saga';
|
||||
import { call, cancel, fork, put, take, select } from 'redux-saga/effects';
|
||||
import { cloneableGenerator, createMockTask } from 'redux-saga/utils';
|
||||
import { toggleOfflineConfig, changeNode, changeNodeIntent, setLatestBlock } from 'actions/config';
|
||||
|
@ -158,7 +158,7 @@ describe('handleNodeChangeIntent*', () => {
|
|||
const data = {} as any;
|
||||
data.gen = cloneableGenerator(handleNodeChangeIntent)(changeNodeIntentAction);
|
||||
|
||||
function shouldBailOut(gen, nextVal, errMsg) {
|
||||
function shouldBailOut(gen: SagaIterator, nextVal: any, errMsg: any) {
|
||||
expect(gen.next(nextVal).value).toEqual(put(showNotification('danger', errMsg, 5000)));
|
||||
expect(gen.next().value).toEqual(
|
||||
put(changeNode(defaultNode, defaultNodeConfig, defaultNodeNetwork))
|
||||
|
@ -287,7 +287,7 @@ describe('unsetWeb3Node*', () => {
|
|||
});
|
||||
|
||||
describe('unsetWeb3NodeOnWalletEvent*', () => {
|
||||
const fakeAction = {};
|
||||
const fakeAction = {} as any;
|
||||
const mockNode = 'web3';
|
||||
const mockNodeConfig: Partial<NodeConfig> = { network: 'ETH' };
|
||||
const gen = unsetWeb3NodeOnWalletEvent(fakeAction);
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('loadBityRates*', () => {
|
|||
rate: 0.042958
|
||||
}
|
||||
};
|
||||
let random;
|
||||
let random: () => number;
|
||||
|
||||
beforeAll(() => {
|
||||
random = Math.random;
|
||||
|
@ -87,7 +87,7 @@ describe('loadShapeshiftRates*', () => {
|
|||
min: 7.86382979
|
||||
}
|
||||
};
|
||||
let random;
|
||||
let random: () => number;
|
||||
|
||||
beforeAll(() => {
|
||||
random = Math.random;
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('broadcastTransactionWrapper*', () => {
|
|||
blockExplorer: 'blockExplorer'
|
||||
};
|
||||
|
||||
let random;
|
||||
let random: () => number;
|
||||
const func: any = () => undefined;
|
||||
const action: any = {};
|
||||
const gens: any = {};
|
||||
|
|
|
@ -8,11 +8,11 @@ import {
|
|||
reparseCurrentValue,
|
||||
valueHandler
|
||||
} from 'sagas/transaction/current/currentValue';
|
||||
import { SagaIterator } from 'redux-saga';
|
||||
import { cloneableGenerator, SagaIteratorClone } from 'redux-saga/utils';
|
||||
import { select, call, put } from 'redux-saga/effects';
|
||||
import { SagaIterator } from 'redux-saga';
|
||||
|
||||
const itShouldBeDone = (gen: any) => {
|
||||
const itShouldBeDone = (gen: SagaIterator) => {
|
||||
it('should be done', () => {
|
||||
expect(gen.next().done).toEqual(true);
|
||||
});
|
||||
|
@ -85,7 +85,7 @@ describe('setCurrentValue*', () => {
|
|||
|
||||
describe('revalidateCurrentValue*', () => {
|
||||
const sharedLogic = (
|
||||
gen: any,
|
||||
gen: SagaIterator,
|
||||
etherTransaction: boolean,
|
||||
currVal: any,
|
||||
reparsedValue: boolean
|
||||
|
@ -165,7 +165,7 @@ describe('revalidateCurrentValue*', () => {
|
|||
});
|
||||
|
||||
describe('reparseCurrentValue*', () => {
|
||||
const sharedLogic = (gen: any) => {
|
||||
const sharedLogic = (gen: SagaIterator) => {
|
||||
it('should select getDecimal', () => {
|
||||
expect(gen.next().value).toEqual(select(getDecimal));
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import BN from 'bn.js';
|
||||
import { SagaIterator } from 'redux-saga';
|
||||
import { call, put } from 'redux-saga/effects';
|
||||
import { setDataField, setGasLimitField, setNonceField } from 'actions/transaction/actionCreators';
|
||||
import { isValidHex, isValidNonce, gasPriceValidator, gasLimitValidator } from 'libs/validators';
|
||||
|
@ -12,7 +13,7 @@ import {
|
|||
import { cloneableGenerator } from 'redux-saga/utils';
|
||||
import { setGasPriceField } from 'actions/transaction';
|
||||
|
||||
const itShouldBeDone = gen => {
|
||||
const itShouldBeDone = (gen: SagaIterator) => {
|
||||
it('should be done', () => {
|
||||
expect(gen.next().done).toEqual(true);
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { SagaIterator } from 'redux-saga';
|
||||
import { select, call, put } from 'redux-saga/effects';
|
||||
import { setDataField } from 'actions/transaction';
|
||||
import { encodeTransfer } from 'libs/transaction/utils/token';
|
||||
|
@ -7,7 +8,7 @@ import { getTokenTo, getData } from 'selectors/transaction';
|
|||
import { handleTokenTo, handleTokenValue } from 'sagas/transaction/meta/token';
|
||||
import { cloneableGenerator } from 'redux-saga/utils';
|
||||
|
||||
const itShouldBeDone = (gen: any) => {
|
||||
const itShouldBeDone = (gen: SagaIterator) => {
|
||||
it('should be done', () => {
|
||||
expect(gen.next().done).toEqual(true);
|
||||
});
|
||||
|
|
|
@ -22,14 +22,14 @@ import { rebaseUserInput, validateInput } from 'sagas/transaction/validationHelp
|
|||
import { handleSetUnitMeta } from 'sagas/transaction/meta/unitSwap';
|
||||
import BN from 'bn.js';
|
||||
|
||||
const itShouldBeDone = (gen: any) => {
|
||||
const itShouldBeDone = (gen: SagaIterator) => {
|
||||
it('should be done', () => {
|
||||
expect(gen.next().done).toEqual(true);
|
||||
});
|
||||
};
|
||||
|
||||
describe('handleSetUnitMeta*', () => {
|
||||
const expectedStart = (gen: any, previousUnit: string, currentUnit: string) => {
|
||||
const expectedStart = (gen: SagaIterator, previousUnit: string, currentUnit: string) => {
|
||||
it('should select getPreviousUnit', () => {
|
||||
expect(gen.next().value).toEqual(select(getPreviousUnit));
|
||||
});
|
||||
|
@ -118,7 +118,7 @@ describe('handleSetUnitMeta*', () => {
|
|||
};
|
||||
|
||||
const sharedLogicB = (
|
||||
gen: any,
|
||||
gen: SagaIterator,
|
||||
input: string,
|
||||
raw: string,
|
||||
value: BN,
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('handleFromRequest*', () => {
|
|||
const fromAddress = '0xa';
|
||||
const gens: any = {};
|
||||
gens.gen = cloneableGenerator(handleFromRequest)();
|
||||
let random;
|
||||
let random: () => number;
|
||||
|
||||
beforeAll(() => {
|
||||
random = Math.random;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { SagaIterator } from 'redux-saga';
|
||||
import { apply, put, select } from 'redux-saga/effects';
|
||||
import {
|
||||
sendEverythingFailed,
|
||||
|
@ -24,7 +25,7 @@ describe('handleSendEverything*', () => {
|
|||
Math.random = random;
|
||||
});
|
||||
|
||||
const sharedStart = (gen: any, transactionObj: any, currentBalance: BN | null) => {
|
||||
const sharedStart = (gen: SagaIterator, transactionObj: any, currentBalance: BN | null) => {
|
||||
it('should select getTransaction', () => {
|
||||
expect(gen.next().value).toEqual(select(getTransaction));
|
||||
});
|
||||
|
|
|
@ -95,7 +95,7 @@ describe('getWalletAndTransaction*', () => {
|
|||
describe('handleFailedTransaction*', () => {
|
||||
const err = new Error('Message');
|
||||
const gen = handleFailedTransaction(err);
|
||||
let random;
|
||||
let random: () => number;
|
||||
|
||||
beforeAll(() => {
|
||||
random = Math.random;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { SagaIterator } from 'redux-saga';
|
||||
import { select, call } from 'redux-saga/effects';
|
||||
import { getUnit, getDecimalFromUnit, getGasLimit, getGasPrice } from 'selectors/transaction';
|
||||
import { getEtherBalance, getTokenBalance } from 'selectors/wallet';
|
||||
|
@ -11,7 +12,7 @@ import {
|
|||
import { cloneableGenerator } from 'redux-saga/utils';
|
||||
import { getOffline } from 'selectors/config';
|
||||
|
||||
const itShouldBeDone = gen => {
|
||||
const itShouldBeDone = (gen: SagaIterator) => {
|
||||
it('should be done', () => {
|
||||
expect(gen.next().done).toEqual(true);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { shallow } from 'enzyme';
|
||||
|
||||
const shallowWithStore = (component, store) => {
|
||||
const shallowWithStore = (component: any, store: any) => {
|
||||
const context = {
|
||||
store
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue