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