All typings issues resolved. Need to rewrite hdkey declaration file though.
This commit is contained in:
parent
939f8b30b1
commit
cd0a1d2287
|
@ -19,7 +19,7 @@ export function initSwap(payload: interfaces.SwapInputs): interfaces.InitSwap {
|
|||
|
||||
export type TLoadBityRatesSucceededSwap = typeof loadBityRatesSucceededSwap;
|
||||
export function loadBityRatesSucceededSwap(
|
||||
payload: interfaces.ApiResponse
|
||||
payload: interfaces.BityResponse
|
||||
): interfaces.LoadBityRatesSucceededSwapAction {
|
||||
return {
|
||||
type: TypeKeys.SWAP_LOAD_BITY_RATES_SUCCEEDED,
|
||||
|
|
|
@ -28,26 +28,37 @@ export interface Option {
|
|||
image?: string;
|
||||
}
|
||||
|
||||
export interface ApiResponseObj {
|
||||
export interface ShapeshiftResponse {
|
||||
[key: string]: {
|
||||
id: string;
|
||||
options: Option[];
|
||||
options: {
|
||||
id: string;
|
||||
status: string;
|
||||
name: string;
|
||||
image: string;
|
||||
}[];
|
||||
rate: string;
|
||||
limit?: number;
|
||||
min?: number;
|
||||
limit: number;
|
||||
min: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ApiResponse {
|
||||
[name: string]: ApiResponseObj;
|
||||
export interface BityResponse {
|
||||
[name: string]: {
|
||||
id: string;
|
||||
options: { id: string }[];
|
||||
rate: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface LoadBityRatesSucceededSwapAction {
|
||||
type: TypeKeys.SWAP_LOAD_BITY_RATES_SUCCEEDED;
|
||||
payload: ApiResponse;
|
||||
payload: BityResponse;
|
||||
}
|
||||
|
||||
export interface LoadShapshiftRatesSucceededSwapAction {
|
||||
type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_SUCCEEDED;
|
||||
payload: ApiResponse;
|
||||
payload: ShapeshiftResponse;
|
||||
}
|
||||
|
||||
export interface DestinationAddressSwapAction {
|
||||
|
|
|
@ -56,6 +56,14 @@ interface Rates {
|
|||
[rate: string]: number;
|
||||
}
|
||||
|
||||
interface FiatSymbols {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
interface Icons {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
type Props = StateProps & DispatchProps;
|
||||
|
||||
class EquivalentValues extends React.Component<Props, State> {
|
||||
|
@ -124,13 +132,13 @@ class EquivalentValues extends React.Component<Props, State> {
|
|||
const isFetching =
|
||||
!balance || balance.isPending || !tokenBalances || Object.keys(rates).length === 0;
|
||||
const pairRates = this.generateValues(equivalentValues.label, equivalentValues.value);
|
||||
const fiatSymbols = {
|
||||
const fiatSymbols: FiatSymbols = {
|
||||
USD: '$',
|
||||
EUR: '€',
|
||||
GBP: '£',
|
||||
CHF: ' '
|
||||
};
|
||||
const coinAndTokenSymbols = {
|
||||
const coinAndTokenSymbols: Icons = {
|
||||
BTC: btcIco,
|
||||
ETH: ethIco,
|
||||
REP: repIco
|
||||
|
@ -140,8 +148,8 @@ class EquivalentValues extends React.Component<Props, State> {
|
|||
className: string;
|
||||
rate: string;
|
||||
value: BN | null;
|
||||
symbol: string;
|
||||
icon: string;
|
||||
symbol?: string;
|
||||
icon?: string;
|
||||
key?: number | string;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ interface TrackedTokens {
|
|||
}
|
||||
|
||||
interface State {
|
||||
trackedTokens: any;
|
||||
trackedTokens: TrackedTokens;
|
||||
showCustomTokenForm: boolean;
|
||||
}
|
||||
export default class TokenBalances extends React.PureComponent<Props, State> {
|
||||
|
@ -42,7 +42,7 @@ export default class TokenBalances extends React.PureComponent<Props, State> {
|
|||
public render() {
|
||||
const { allTokens, tokenBalances, hasSavedWalletTokens } = this.props;
|
||||
const { showCustomTokenForm } = this.state;
|
||||
const trackedTokens: any = this.state.trackedTokens;
|
||||
const trackedTokens: TrackedTokens = this.state.trackedTokens;
|
||||
|
||||
let bottom;
|
||||
let help;
|
||||
|
@ -134,7 +134,7 @@ export default class TokenBalances extends React.PureComponent<Props, State> {
|
|||
};
|
||||
|
||||
private handleSetWalletTokens = () => {
|
||||
const trackedTokens: any = this.state.trackedTokens;
|
||||
const trackedTokens: TrackedTokens = this.state.trackedTokens;
|
||||
const desiredTokens = Object.keys(trackedTokens).filter(t => trackedTokens[t]);
|
||||
this.props.setWalletTokens(desiredTokens);
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ export default class CurrentRates extends PureComponent<Props> {
|
|||
|
||||
public buildSSPairs = (shapeshiftRates: NormalizedShapeshiftRates, n: number = 4) => {
|
||||
const pairCollection = times(n, () => this.getRandomSSPairData(shapeshiftRates));
|
||||
const byId = pairCollection.reduce((acc: any, cur) => {
|
||||
const byId = pairCollection.reduce((acc: NormalizedShapeshiftRate[], cur) => {
|
||||
acc[cur.id] = cur;
|
||||
return acc;
|
||||
}, {});
|
||||
|
|
|
@ -6,6 +6,7 @@ import { IFullWallet } from 'libs/wallet';
|
|||
import { translateRaw } from 'translations';
|
||||
import { ITransaction, IHexStrTransaction } from '../typings';
|
||||
import { hexEncodeQuantity, hexEncodeData } from 'libs/nodes/rpc/utils';
|
||||
import { TransactionFieldValues } from 'selectors/transaction/helpers';
|
||||
|
||||
// we dont include the signature paramaters because web3 transactions are unsigned
|
||||
const computeIndexingHash = (tx: Buffer) => bufferToHex(makeTransaction(tx).hash(false));
|
||||
|
@ -75,7 +76,13 @@ const validAddress = (t: ITransaction) => {
|
|||
};
|
||||
|
||||
const makeTransaction = (
|
||||
t: Partial<Tx> | Partial<ITransaction> | Partial<IHexStrTransaction> | Buffer | string
|
||||
t:
|
||||
| Partial<Tx>
|
||||
| Partial<ITransaction>
|
||||
| Partial<IHexStrTransaction>
|
||||
| Buffer
|
||||
| string
|
||||
| TransactionFieldValues
|
||||
) => new Tx(t);
|
||||
|
||||
//TODO: check that addresses are always checksummed
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { EtherscanNode, InfuraNode, RPCNode } from 'libs/nodes';
|
||||
import { TypeKeys, NodeAction } from 'actions/config';
|
||||
import { NonWeb3NodeConfigs, Web3NodeConfigs } from 'types/node';
|
||||
import { StaticNodeConfig } from 'types/node';
|
||||
|
||||
export type State = NonWeb3NodeConfigs & Web3NodeConfigs;
|
||||
export interface State {
|
||||
[network: string]: StaticNodeConfig;
|
||||
}
|
||||
|
||||
export const INITIAL_STATE: State = {
|
||||
eth_mycrypto: {
|
||||
|
|
|
@ -16,7 +16,11 @@ import wallet from './wallet';
|
|||
import { ens } from './ens';
|
||||
import { transaction } from './transaction';
|
||||
|
||||
export default {
|
||||
interface Sagas {
|
||||
[saga: string]: any;
|
||||
}
|
||||
|
||||
const sagas: Sagas = {
|
||||
ens,
|
||||
liteSend,
|
||||
configSaga,
|
||||
|
@ -35,3 +39,5 @@ export default {
|
|||
swapProviderSaga,
|
||||
rates
|
||||
};
|
||||
|
||||
export default sagas;
|
||||
|
|
|
@ -23,7 +23,8 @@ export interface IInput {
|
|||
* @param {IInput} value
|
||||
* @returns {SagaIterator}
|
||||
*/
|
||||
export function* rebaseUserInput(value: IInput): SagaIterator {
|
||||
export function* rebaseUserInput(value: any): SagaIterator {
|
||||
//TODO need to change call on unitSwap spec to use IInput typing
|
||||
const unit: string = yield select(getUnit);
|
||||
// get decimal
|
||||
const newDecimal: number = yield select(getDecimalFromUnit, unit);
|
||||
|
|
|
@ -86,7 +86,7 @@ export function getSelectedNode(state: AppState) {
|
|||
return getNodes(state).selectedNode;
|
||||
}
|
||||
|
||||
export function isNodeChanging(state): boolean {
|
||||
export function isNodeChanging(state: AppState): boolean {
|
||||
return getSelectedNode(state).pending;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ export function isWalletFormatSupportedOnNetwork(state: AppState, format: Wallet
|
|||
}
|
||||
|
||||
export function unSupportedWalletFormatsOnNetwork(state: AppState): WalletName[] {
|
||||
const supportedFormats = walletNames.filter(walletName =>
|
||||
const supportedFormats = walletNames.filter((walletName: WalletName) =>
|
||||
isWalletFormatSupportedOnNetwork(state, walletName)
|
||||
);
|
||||
return difference(walletNames, supportedFormats);
|
||||
|
|
|
@ -3,7 +3,7 @@ import { ICurrentTo, ICurrentValue } from 'selectors/transaction';
|
|||
import { isEtherUnit } from 'libs/units';
|
||||
|
||||
type TransactionFields = AppState['transaction']['fields'];
|
||||
type TransactionFieldValues = {
|
||||
export type TransactionFieldValues = {
|
||||
[field in keyof TransactionFields]: TransactionFields[field]['value']
|
||||
};
|
||||
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
interface HDKeyProps {
|
||||
versions: any[];
|
||||
depth: number;
|
||||
index: number;
|
||||
_privateKey: any;
|
||||
_publicKey: any;
|
||||
chainCode: any;
|
||||
_fingerprint: any;
|
||||
parentFingerprint: number;
|
||||
}
|
||||
|
||||
declare class HDCLass<HDKeyProps> {
|
||||
constructor();
|
||||
}
|
||||
|
||||
declare namespace HDKey {
|
||||
|
||||
declare module 'hdkey' {
|
||||
export default class HDKey {
|
||||
privateKey: Buffer;
|
||||
publicKey: Buffer;
|
||||
chainCode: Buffer | string;
|
||||
fromMasterSeed(seedBuffer: Buffer, versions?: any[]): HDKey;
|
||||
fromExtendedKey(base58key: any, versions?: any[]): HDKey;
|
||||
fromJSON(obj: any): HDKey;
|
||||
derive(path: string): HDKey;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +1,38 @@
|
|||
interface PropTypes {
|
||||
activeStep: number;
|
||||
steps: any[];
|
||||
activeColor: string;
|
||||
completeColor: string;
|
||||
defaultColor: string;
|
||||
activeTitleColor: string;
|
||||
completeTitleColor: string;
|
||||
defaultTitleColor: string;
|
||||
circleFontColor: string;
|
||||
size: number;
|
||||
circleFontSize: number;
|
||||
titleFontSize: number;
|
||||
circleTop: number;
|
||||
titleTop: number;
|
||||
defaultOpacity: string;
|
||||
completeOpacity: string;
|
||||
activeOpacity: string;
|
||||
defaultTitleOpacity: string;
|
||||
completeTitleOpacity: string;
|
||||
activeTitleOpacity: string;
|
||||
barStyle: string;
|
||||
defaultBarColor: string;
|
||||
completeBarColor: string;
|
||||
defaultBorderColor: string;
|
||||
completeBorderColor: string;
|
||||
activeBorderColor: string;
|
||||
defaultBorderStyle: string;
|
||||
completeBorderStyle: string;
|
||||
activeBorderStyle: string;
|
||||
activeColor?: string;
|
||||
completeColor?: string;
|
||||
defaultColor?: string;
|
||||
activeTitleColor?: string;
|
||||
completeTitleColor?: string;
|
||||
defaultTitleColor?: string;
|
||||
circleFontColor?: string;
|
||||
size?: number;
|
||||
circleFontSize?: number;
|
||||
titleFontSize?: number;
|
||||
circleTop?: number;
|
||||
titleTop?: number;
|
||||
defaultOpacity?: string;
|
||||
completeOpacity?: string;
|
||||
activeOpacity?: string;
|
||||
defaultTitleOpacity?: string;
|
||||
completeTitleOpacity?: string;
|
||||
activeTitleOpacity?: string;
|
||||
barStyle?: string;
|
||||
defaultBarColor?: string;
|
||||
completeBarColor?: string;
|
||||
defaultBorderColor?: string;
|
||||
completeBorderColor?: string;
|
||||
activeBorderColor?: string;
|
||||
defaultBorderStyle?: string;
|
||||
completeBorderStyle?: string;
|
||||
activeBorderStyle?: string;
|
||||
}
|
||||
|
||||
declare module 'react-stepper-horizontal' {
|
||||
export const Stepper: any;
|
||||
import React from 'React';
|
||||
class Stepper extends React.Component<PropTypes> {
|
||||
constructor();
|
||||
}
|
||||
export = Stepper;
|
||||
}
|
||||
|
|
26
package.json
26
package.json
|
@ -12,6 +12,8 @@
|
|||
"dependencies": {
|
||||
"@types/enzyme": "3.1.8",
|
||||
"@types/enzyme-adapter-react-16": "1.0.1",
|
||||
"@types/rc-slider": "8.2.3",
|
||||
"@types/react-transition-group": "2.0.7",
|
||||
"babel-polyfill": "6.26.0",
|
||||
"bip39": "2.5.0",
|
||||
"bn.js": "4.11.8",
|
||||
|
@ -144,14 +146,10 @@
|
|||
"prebuild": "check-node-version --package",
|
||||
"build:downloadable": "webpack --config webpack_config/webpack.html.js",
|
||||
"prebuild:downloadable": "check-node-version --package",
|
||||
"build:electron":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && node webpack_config/buildElectron.js",
|
||||
"build:electron:osx":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=osx node webpack_config/buildElectron.js",
|
||||
"build:electron:windows":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=windows node webpack_config/buildElectron.js",
|
||||
"build:electron:linux":
|
||||
"webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=linux node webpack_config/buildElectron.js",
|
||||
"build:electron": "webpack --config webpack_config/webpack.electron-prod.js && node webpack_config/buildElectron.js",
|
||||
"build:electron:osx": "webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=osx node webpack_config/buildElectron.js",
|
||||
"build:electron:windows": "webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=windows node webpack_config/buildElectron.js",
|
||||
"build:electron:linux": "webpack --config webpack_config/webpack.electron-prod.js && ELECTRON_OS=linux node webpack_config/buildElectron.js",
|
||||
"prebuild:electron": "check-node-version --package",
|
||||
"test:coverage": "jest --config=jest_config/jest.config.json --coverage",
|
||||
"test": "jest --config=jest_config/jest.config.json",
|
||||
|
@ -163,18 +161,14 @@
|
|||
"predev": "check-node-version --package",
|
||||
"dev:https": "HTTPS=true node webpack_config/devServer.js",
|
||||
"predev:https": "check-node-version --package",
|
||||
"dev:electron":
|
||||
"concurrently --kill-others --names 'webpack,electron' 'BUILD_ELECTRON=true node webpack_config/devServer.js' 'webpack --config webpack_config/webpack.electron-dev.js && electron dist/electron-js/main.js'",
|
||||
"dev:electron:https":
|
||||
"concurrently --kill-others --names 'webpack,electron' 'BUILD_ELECTRON=true HTTPS=true node webpack_config/devServer.js' 'HTTPS=true webpack --config webpack_config/webpack.electron-dev.js && electron dist/electron-js/main.js'",
|
||||
"dev:electron": "concurrently --kill-others --names 'webpack,electron' 'BUILD_ELECTRON=true node webpack_config/devServer.js' 'webpack --config webpack_config/webpack.electron-dev.js && electron dist/electron-js/main.js'",
|
||||
"dev:electron:https": "concurrently --kill-others --names 'webpack,electron' 'BUILD_ELECTRON=true HTTPS=true node webpack_config/devServer.js' 'HTTPS=true webpack --config webpack_config/webpack.electron-dev.js && electron dist/electron-js/main.js'",
|
||||
"tslint": "tslint --project . --exclude common/vendor/**/*",
|
||||
"tscheck": "tsc --noEmit",
|
||||
"start": "npm run dev",
|
||||
"precommit": "lint-staged",
|
||||
"formatAll":
|
||||
"find ./common/ -name '*.ts*' | xargs prettier --write --config ./.prettierrc --config-precedence file-override",
|
||||
"prettier:diff":
|
||||
"prettier --write --config ./.prettierrc --list-different \"common/**/*.ts\" \"common/**/*.tsx\"",
|
||||
"formatAll": "find ./common/ -name '*.ts*' | xargs prettier --write --config ./.prettierrc --config-precedence file-override",
|
||||
"prettier:diff": "prettier --write --config ./.prettierrc --list-different \"common/**/*.ts\" \"common/**/*.tsx\"",
|
||||
"prepush": "npm run tslint && npm run tscheck"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
|
|
@ -22,7 +22,6 @@ import {
|
|||
import { Web3Wallet } from 'libs/wallet';
|
||||
import { showNotification } from 'actions/notifications';
|
||||
import { translateRaw } from 'translations';
|
||||
import { StaticNodeConfig } from 'types/node';
|
||||
import { staticNodesExpectedState } from './nodes/staticNodes.spec';
|
||||
import { metaExpectedState } from './meta/meta.spec';
|
||||
import { selectedNodeExpectedState } from './nodes/selectedNode.spec';
|
||||
|
@ -141,12 +140,12 @@ describe('handleNodeChangeIntent*', () => {
|
|||
|
||||
// normal operation variables
|
||||
const defaultNodeId = selectedNodeExpectedState.initialState.nodeId;
|
||||
const defaultNodeConfig: StaticNodeConfig = staticNodesExpectedState.initialState[defaultNodeId];
|
||||
const defaultNodeConfig = staticNodesExpectedState.initialState[defaultNodeId];
|
||||
const newNodeId = Object.keys(staticNodesExpectedState.initialState).reduce(
|
||||
(acc, cur) =>
|
||||
staticNodesExpectedState.initialState[cur].network !== defaultNodeConfig.network ? cur : acc
|
||||
);
|
||||
const newNodeConfig: StaticNodeConfig = staticNodesExpectedState.initialState[newNodeId];
|
||||
const newNodeConfig = staticNodesExpectedState.initialState[newNodeId];
|
||||
|
||||
const changeNodeIntentAction = changeNodeIntent(newNodeId);
|
||||
const latestBlock = '0xa';
|
||||
|
|
|
@ -4,7 +4,19 @@ import { EtherscanNode, InfuraNode, RPCNode } from 'libs/nodes';
|
|||
import { Web3NodeConfig } from 'types/node';
|
||||
import { Web3Service } from 'libs/nodes/web3';
|
||||
|
||||
const expectedInitialState = {
|
||||
export interface InitialStates {
|
||||
[network: string]: Network;
|
||||
}
|
||||
|
||||
interface Network {
|
||||
network: string;
|
||||
isCustom: boolean;
|
||||
lib: RPCNode;
|
||||
service: string;
|
||||
estimateGas: boolean;
|
||||
}
|
||||
|
||||
const expectedInitialState: InitialStates = {
|
||||
eth_mycrypto: {
|
||||
network: 'ETH',
|
||||
isCustom: false,
|
||||
|
|
|
@ -22,7 +22,8 @@ describe('ensure whitelist', () => {
|
|||
});
|
||||
|
||||
describe('swap reducer', () => {
|
||||
const shapeshiftApiResponse = {
|
||||
const shapeshiftApiResponse: swapActions.ShapeshiftResponse = {
|
||||
['1SSTANT']: {
|
||||
id: '1STANT',
|
||||
options: [
|
||||
{
|
||||
|
@ -41,9 +42,10 @@ describe('swap reducer', () => {
|
|||
rate: '0.24707537',
|
||||
limit: 5908.29166225,
|
||||
min: 7.86382979
|
||||
}
|
||||
};
|
||||
|
||||
const bityApiResponse = {
|
||||
const bityApiResponse: swapActions.BityResponse = {
|
||||
BTCETH: {
|
||||
id: 'BTCETH',
|
||||
options: [{ id: 'BTC' }, { id: 'ETH' }],
|
||||
|
|
|
@ -47,7 +47,9 @@ describe('loadBityRates*', () => {
|
|||
});
|
||||
|
||||
it('should put loadBityRatesSucceededSwap', () => {
|
||||
expect(gen1.next(apiResponse).value).toEqual(put(loadBityRatesSucceededSwap(apiResponse)));
|
||||
expect(gen1.next(apiResponse).value).toEqual(
|
||||
put(loadBityRatesSucceededSwap(apiResponse as any))
|
||||
);
|
||||
});
|
||||
|
||||
it('should call delay for 5 seconds', () => {
|
||||
|
|
|
@ -11,9 +11,7 @@ describe('saveState', () => {
|
|||
foo: 'bar'
|
||||
};
|
||||
saveState(persistMe);
|
||||
expect(JSON.parse(localStorage.getItem(REDUX_STATE) as string)).toEqual(
|
||||
persistMe
|
||||
);
|
||||
expect(JSON.parse(localStorage.getItem(REDUX_STATE) as string)).toEqual(persistMe);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -32,6 +30,6 @@ describe('loadStatePropertyOrEmptyObject', () => {
|
|||
two: 'bar'
|
||||
};
|
||||
saveState(serializeThis);
|
||||
expect(loadStatePropertyOrEmptyObject('one')).toEqual(serializeThis.one);
|
||||
expect(loadStatePropertyOrEmptyObject('one' as any)).toEqual(serializeThis.one);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue