Skip to content

Commit

Permalink
#228: Bitski integration
Browse files Browse the repository at this point in the history
  • Loading branch information
generalpiston committed Jun 9, 2019
1 parent 4abaad4 commit eb3b872
Show file tree
Hide file tree
Showing 97 changed files with 2,518 additions and 1,548 deletions.
5 changes: 5 additions & 0 deletions App/NavigationProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class NavigationProvider extends React.Component {
componentId: this.props.componentId,
push: this.push,
pop: this.pop,
popToRoot: this.popToRoot,
showModal: showModal,
showErrorModal: showErrorModal,
dismissModal: this.dismissModal,
Expand All @@ -47,6 +48,10 @@ export default class NavigationProvider extends React.Component {
Navigation.pop(this.props.componentId);
};

popToRoot = () => {
Navigation.popToRoot(this.props.componentId);
};

dismissModal = () => {
Navigation.dismissModal(this.props.componentId);
};
Expand Down
2 changes: 1 addition & 1 deletion App/components/AddressText.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ethUtil from 'ethereumjs-util';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Text } from 'react-native-elements';
import { summarizeAddress } from '../../utils';
import { summarizeAddress } from '../../lib/utils';

export default class AddressText extends Component {
render() {
Expand Down
2 changes: 1 addition & 1 deletion App/components/FormattedForexAmount.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BigNumber } from '0x.js';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Text } from 'react-native-elements';
import { formatMoney } from '../../utils';
import { formatMoney } from '../../lib/utils';

export default class FormattedForexAmount extends Component {
static get propTypes() {
Expand Down
2 changes: 1 addition & 1 deletion App/components/FormattedPercent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BigNumber } from '0x.js';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Text } from 'react-native-elements';
import { formatPercent } from '../../utils';
import { formatPercent } from '../../lib/utils';

export default class FormattedPercent extends Component {
static get propTypes() {
Expand Down
2 changes: 1 addition & 1 deletion App/components/FormattedSymbol.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Text } from 'react-native-elements';
import { formatSymbol } from '../../utils';
import { formatSymbol } from '../../lib/utils';

export default class FormattedSymbol extends Component {
static get propTypes() {
Expand Down
2 changes: 1 addition & 1 deletion App/components/FormattedTokenAmount.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import { Text } from 'react-native-elements';
import * as AssetService from '../../services/AssetService';
import { styles } from '../../styles';
import { formatAmount, formatAmountWithDecimals } from '../../utils';
import { formatAmount, formatAmountWithDecimals } from '../../lib/utils';
import FormattedSymbol from './FormattedSymbol';

export default class FormattedTokenAmount extends React.PureComponent {
Expand Down
2 changes: 1 addition & 1 deletion App/components/PriceGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { G, Line, Text as SVGText } from 'react-native-svg';
import { AreaChart } from 'react-native-svg-charts';
import { colors, styles } from '../../styles';
import { styleProp } from '../../types/props/styles';
import { colorWithAlpha } from '../../utils';
import { colorWithAlpha } from '../../lib/utils';
import MutedText from './MutedText';
import Tabs from './Tabs';

Expand Down
2 changes: 1 addition & 1 deletion App/components/TokenAmount.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import React, { Component, Fragment } from 'react';
import { StyleSheet, View } from 'react-native';
import { Avatar, Text } from 'react-native-elements';
import { formatAmount, formatSymbol, getImage } from '../../utils';
import { formatAmount, formatSymbol, getImage } from '../../lib/utils';
import FormattedSymbol from './FormattedSymbol';
import MutedText from './MutedText';
import BlinkingCursor from './BlinkingCursor';
Expand Down
2 changes: 1 addition & 1 deletion App/components/TokenIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { View } from 'react-native';
import { Avatar, Text } from 'react-native-elements';
import * as AssetService from '../../services/AssetService';
import { fonts, images, styles } from '../../styles';
import { getImage } from '../../utils';
import { getImage } from '../../lib/utils';

export default class TokenIcon extends Component {
render() {
Expand Down
2 changes: 1 addition & 1 deletion App/components/UnlockButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { connect as connectNavigation } from '../../navigation';
import * as AssetService from '../../services/AssetService';
import { approve } from '../../thunks';
import { navigationProp } from '../../types/props';
import { formatSymbol } from '../../utils';
import { formatSymbol } from '../../lib/utils';
import Button from './Button';

class UnlockButton extends React.Component {
Expand Down
2 changes: 1 addition & 1 deletion App/layouts/OneButtonTokenAmountKeyboardLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import { SafeAreaView, ScrollView, View } from 'react-native';
import VirtualKeyboard from 'react-native-virtual-keyboard';
import { styles } from '../../styles';
import { processVirtualKeyboardCharacter } from '../../utils';
import { processVirtualKeyboardCharacter } from '../../lib/utils';
import Button from '../components/Button';

export default class OneButtonTokenAmountKeyboardLayout extends PureComponent {
Expand Down
2 changes: 1 addition & 1 deletion App/layouts/PinKeyboardLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import { SafeAreaView, View } from 'react-native';
import VirtualKeyboard from 'react-native-virtual-keyboard';
import { styles } from '../../styles';
import { processVirtualKeyboardCharacter } from '../../utils';
import { processVirtualKeyboardCharacter } from '../../lib/utils';
import PinView from '../components/PinView';

export default class PinKeyboardLayout extends PureComponent {
Expand Down
2 changes: 1 addition & 1 deletion App/layouts/TwoButtonTokenAmountKeyboardLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import { SafeAreaView, ScrollView, View } from 'react-native';
import VirtualKeyboard from 'react-native-virtual-keyboard';
import { styles } from '../../styles';
import { processVirtualKeyboardCharacter } from '../../utils';
import { processVirtualKeyboardCharacter } from '../../lib/utils';
import Button from '../components/Button';
import Row from '../components/Row';

Expand Down
11 changes: 8 additions & 3 deletions App/modals/ActionModal/base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Text } from 'react-native-elements';
import { connect as connectNavigation } from '../../../navigation';
import {
connect as connectNavigation,
waitForComponentAppear
} from '../../../navigation';
import { navigationProp } from '../../../types/props';
import BigCenter from '../../components/BigCenter';
import VerticalPadding from '../../components/VerticalPadding';
Expand All @@ -23,8 +26,10 @@ class BaseActionModal extends React.PureComponent {
try {
await this.props.action();
} catch (err) {
this.props.navigation.dismissModal();
this.props.callback(err);
waitForComponentAppear(this.props.navigation.componentId, () => {
this.props.navigation.dismissModal();
this.props.callback(err);
});
return;
}

Expand Down
18 changes: 9 additions & 9 deletions App/modals/PreviewOrderModal/FillOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ZERO } from '../../../constants/0x';
import { connect as connectNavigation } from '../../../navigation';
import * as AssetService from '../../../services/AssetService';
import * as OrderService from '../../../services/OrderService';
import * as WalletService from '../../../services/WalletService';
import { WalletService } from '../../../services/WalletService';
import * as ZeroExService from '../../../services/ZeroExService';
import { colors } from '../../../styles';
import {
Expand All @@ -21,7 +21,7 @@ import {
pruneOrders,
refreshGasPrice
} from '../../../thunks';
import { formatAmount } from '../../../utils';
import { formatAmount } from '../../../lib/utils';
import { navigationProp } from '../../../types/props';
import Button from '../../components/Button';
import FormattedTokenAmount from '../../components/FormattedTokenAmount';
Expand Down Expand Up @@ -87,16 +87,16 @@ class PreviewFillOrders extends Component {
const { side, amount } = this.props;
const relayerFeeAsset = AssetService.getFeeAsset();
const networkFeeAsset = AssetService.getNetworkFeeAsset();
const etherBalance = WalletService.getBalanceByAssetData(
const etherBalance = WalletService.instance.getBalanceByAssetData(
networkFeeAsset.assetData
);
const feeBalance = WalletService.getBalanceByAssetData(
const feeBalance = WalletService.instance.getBalanceByAssetData(
relayerFeeAsset.assetData
);
const quoteBalance = WalletService.getBalanceByAssetData(
const quoteBalance = WalletService.instance.getBalanceByAssetData(
this.props.quote.assetData
);
const baseBalance = WalletService.getBalanceByAssetData(
const baseBalance = WalletService.instance.getBalanceByAssetData(
this.props.base.assetData
);
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(
Expand Down Expand Up @@ -246,7 +246,7 @@ class PreviewFillOrders extends Component {
}

// 6. Load gas price
const gasPrice = WalletService.convertGasPriceToEth(
const gasPrice = WalletService.instance.convertGasPriceToEth(
await this.props.dispatch(refreshGasPrice())
);

Expand Down Expand Up @@ -291,11 +291,11 @@ class PreviewFillOrders extends Component {
for (const asset of assets) {
wallet[asset.address] = {
symbol: asset.symbol,
amount: WalletService.getBalanceByAddress(asset.address)
amount: WalletService.instance.getBalanceByAddress(asset.address)
};
walletAfterTransaction[asset.address] = {
symbol: asset.symbol,
amount: WalletService.getBalanceByAddress(asset.address)
amount: WalletService.instance.getBalanceByAddress(asset.address)
};
}

Expand Down
8 changes: 4 additions & 4 deletions App/modals/PreviewOrderModal/LimitOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import {
configureOrder,
convertZeroExOrderToLimitOrder
} from '../../../services/OrderService';
import * as WalletService from '../../../services/WalletService';
import { WalletService } from '../../../services/WalletService';
import { colors } from '../../../styles';
import {
ActionErrorSuccessFlow,
refreshGasPrice,
submitOrder
} from '../../../thunks';
import { formatAmount, formatTimestamp } from '../../../utils';
import { formatAmount, formatTimestamp } from '../../../lib/utils';
import { navigationProp } from '../../../types/props';
import Button from '../../components/Button';
import Row from '../../components/Row';
Expand Down Expand Up @@ -98,11 +98,11 @@ class PreviewLimitOrder extends Component {
for (const asset of assets) {
wallet[asset.address] = {
symbol: asset.symbol,
amount: WalletService.getBalanceByAddress(asset.address)
amount: WalletService.instance.getBalanceByAddress(asset.address)
};
walletAfterTransaction[asset.address] = {
symbol: asset.symbol,
amount: WalletService.getBalanceByAddress(asset.address)
amount: WalletService.instance.getBalanceByAddress(asset.address)
};
}

Expand Down
2 changes: 1 addition & 1 deletion App/modals/SendModal/AccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import { connect } from 'react-redux';
import Icon from 'react-native-vector-icons/FontAwesome';
import * as TickerService from '../../../services/TickerService';
import { formatAmount, formatMoney } from '../../../utils';
import { formatAmount, formatMoney } from '../../../lib/utils';
import AddressInput from '../../components/AddressInput';
import TwoColumnListItem from '../../components/TwoColumnListItem';
import ConfirmationView from '../../views/ConfirmationView';
Expand Down
16 changes: 10 additions & 6 deletions App/modals/SendModal/AmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import React from 'react';
import Entypo from 'react-native-vector-icons/Entypo';
import { connect } from 'react-redux';
import * as TickerService from '../../../services/TickerService';
import * as WalletService from '../../../services/WalletService';
import { WalletService } from '../../../services/WalletService';
import { styles } from '../../../styles';
import { refreshGasPrice } from '../../../thunks';
import { formatAmount, getForexIcon, isValidAmount } from '../../../utils';
import { formatAmount, getForexIcon, isValidAmount } from '../../../lib/utils';
import MaxButton from '../../components/MaxButton';
import Row from '../../components/Row';
import TokenAmount from '../../components/TokenAmount';
Expand Down Expand Up @@ -40,7 +40,7 @@ class AmountPage extends TwoButtonTokenAmountKeyboardLayout {

renderTop() {
const { asset } = this.props;
const balance = WalletService.getBalanceByAddress(asset.address);
const balance = WalletService.instance.getBalanceByAddress(asset.address);

return (
<React.Fragment>
Expand Down Expand Up @@ -176,12 +176,16 @@ class AmountPage extends TwoButtonTokenAmountKeyboardLayout {

setMaxTokenAmount = async () => {
const { asset } = this.props;
const balance = WalletService.getBalanceByAddress(asset.address || null);
const balance = WalletService.instance.getBalanceByAddress(
asset.address || null
);
let amount = balance;

if (!asset.address) {
const gasAmount = await WalletService.estimateEthSend();
const gasPrice = WalletService.convertGasPriceToEth(this.props.gasPrice);
const gasAmount = await WalletService.instance.estimateEthSend();
const gasPrice = WalletService.instance.convertGasPriceToEth(
this.props.gasPrice
);
const gasFee = gasPrice.mul(gasAmount);

amount = amount.sub(gasFee);
Expand Down
12 changes: 7 additions & 5 deletions App/modals/SendModal/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import FontAwesome from 'react-native-vector-icons/FontAwesome';
import { connect } from 'react-redux';
import { ZERO } from '../../../constants/0x';
import { connect as connectNavigation } from '../../../navigation';
import * as WalletService from '../../../services/WalletService';
import { WalletService } from '../../../services/WalletService';
import {
ReceiptActionErrorSuccessFlow,
sendEther,
sendTokens
} from '../../../thunks';
import { navigationProp } from '../../../types/props';
import { formatAmount } from '../../../utils';
import { formatAmount } from '../../../lib/utils';
import AmountPage from './AmountPage';
import AccountPage from './AccountPage';

Expand Down Expand Up @@ -149,7 +149,7 @@ class BaseSendScreen extends Component {
const extraWalletData = [];
const extraUpdatedWalletData = [];
const extraSections = [];
const gas = await WalletService.estimateEthSend();
const gas = await WalletService.instance.estimateEthSend();
const action = () => this.props.dispatch(sendEther(to, amount));
const value = baseUnitAmount;

Expand All @@ -168,7 +168,9 @@ class BaseSendScreen extends Component {
const { asset } = this.props;
const { amount } = this.state;
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, asset.decimals);
const balance = await WalletService.getBalanceByAssetData(asset.assetData);
const balance = await WalletService.instance.getBalanceByAssetData(
asset.assetData
);

const to = address || this.state.address;
const extraWalletData = [
Expand Down Expand Up @@ -196,7 +198,7 @@ class BaseSendScreen extends Component {
]
}
];
const gas = await WalletService.estimateTokenSend(
const gas = await WalletService.instance.estimateTokenSend(
asset.address,
to,
baseUnitAmount
Expand Down
6 changes: 3 additions & 3 deletions App/modals/UnlockAndSignModal/Unlocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Text } from 'react-native-elements';
import FontAwesome from 'react-native-vector-icons/FontAwesome';
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
import { connect as connectNavigation } from '../../../navigation';
import * as WalletService from '../../../services/WalletService';
import { WalletService } from '../../../services/WalletService';
import { colors } from '../../../styles';
import { navigationProp } from '../../../types/props';
import BigCenter from '../../components/BigCenter';
Expand All @@ -30,12 +30,12 @@ class Unlocking extends Component {

try {
if (tx) {
data = await WalletService.signTransaction(
data = await WalletService.instance.signTransaction(
tx,
pin ? pin.slice(0, 6) : null
);
} else if (message) {
data = await WalletService.signMessage(
data = await WalletService.instance.signMessage(
message,
pin ? pin.slice(0, 6) : null
);
Expand Down
6 changes: 3 additions & 3 deletions App/modals/UnlockAndSignModal/base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect as connectNavigation } from '../../../navigation';
import * as WalletService from '../../../services/WalletService';
import { WalletService } from '../../../services/WalletService';
import { navigationProp } from '../../../types/props';
import Loading from '../../views/Loading';
import UnlockWithTouchIdentification from './UnlockWithTouchIdentification';
Expand Down Expand Up @@ -38,8 +38,8 @@ class UnlockAndSignModal extends Component {
return this.props.navigation.dismissModal();
}

const supportsFingerPrint = await WalletService.supportsFingerPrintUnlock();
const supportsFaceID = await WalletService.supportsFaceIDUnlock();
const supportsFingerPrint = await WalletService.instance.supportsFingerPrintUnlock();
const supportsFaceID = await WalletService.instance.supportsFaceIDUnlock();
if (supportsFingerPrint && !this.forceShowPin) {
this.showTouchIdentification();
} else if (supportsFaceID && !this.forceShowPin) {
Expand Down
Loading

0 comments on commit eb3b872

Please sign in to comment.