Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: custom rpc network #1060

Merged
merged 8 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ class Main extends PureComponent {
}
// Check if it's a payment channel deposit transaction to sign
const to = toChecksumAddress(transactionMeta.transaction.to);
const networkId = Networks[this.props.providerType].networkId.toString();
const networkId = Networks[this.props.providerType].networkId;
if (
this.props.paymentChannelsEnabled &&
AppConstants.CONNEXT.SUPPORTED_NETWORKS.includes(this.props.providerType) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ class TransactionReviewInformation extends PureComponent {
/**
* Callback for transaction edition
*/
edit: PropTypes.func
edit: PropTypes.func,
/**
* Current provider ticker
*/
ticker: PropTypes.string
};

state = {
Expand All @@ -139,11 +143,12 @@ class TransactionReviewInformation extends PureComponent {
const {
transaction: { gas, gasPrice },
currentCurrency,
conversionRate
conversionRate,
ticker
} = this.props;
const totalGas = isBN(gas) && isBN(gasPrice) ? gas.mul(gasPrice) : toBN('0x0');
const totalGasFiat = weiToFiat(totalGas, conversionRate, currentCurrency);
const totalGasEth = `${renderFromWei(totalGas)} ${strings('unit.eth')}`;
const totalGasEth = `${renderFromWei(totalGas)} ${ticker}`;

const [totalFiat, totalValue] = this.getRenderTotals(totalGas, totalGasFiat)();
this.setState({ totalGas, totalGasFiat, totalGasEth, totalFiat, totalValue });
Expand All @@ -168,16 +173,15 @@ class TransactionReviewInformation extends PureComponent {
transaction: { value, selectedAsset, assetType },
currentCurrency,
conversionRate,
contractExchangeRates
contractExchangeRates,
ticker
} = this.props;

const totals = {
ETH: () => {
const totalEth = isBN(value) ? value.add(totalGas) : totalGas;
const totalFiat = weiToFiat(totalEth, conversionRate, currentCurrency);
const totalValue = (
<Text style={styles.overviewEth}>{`${renderFromWei(totalEth)} ${strings('unit.eth')} `}</Text>
);
const totalValue = <Text style={styles.overviewEth}>{`${renderFromWei(totalEth)} ${ticker} `}</Text>;
return [totalFiat, totalValue];
},
ERC20: () => {
Expand All @@ -196,7 +200,7 @@ class TransactionReviewInformation extends PureComponent {
<Text numberOfLines={1} style={[styles.overviewEth, styles.assetName]}>
{amountToken + ' ' + selectedAsset.symbol}
</Text>
<Text style={styles.overviewEth}>{` + ${renderFromWei(totalGas)} ${strings('unit.eth')}`}</Text>
<Text style={styles.overviewEth}>{` + ${renderFromWei(totalGas)} ${ticker}`}</Text>
</View>
);
return [totalFiat, totalValue];
Expand All @@ -211,7 +215,7 @@ class TransactionReviewInformation extends PureComponent {
<Text numberOfLines={1} style={styles.overviewEth}>
{' (#' + selectedAsset.tokenId + ')'}
</Text>
<Text style={styles.overviewEth}>{` + ${renderFromWei(totalGas)} ${strings('unit.eth')}`}</Text>
<Text style={styles.overviewEth}>{` + ${renderFromWei(totalGas)} ${ticker}`}</Text>
</View>
);
return [totalFiat, totalValue];
Expand Down Expand Up @@ -262,7 +266,8 @@ const mapStateToProps = state => ({
conversionRate: state.engine.backgroundState.CurrencyRateController.conversionRate,
currentCurrency: state.engine.backgroundState.CurrencyRateController.currentCurrency,
contractExchangeRates: state.engine.backgroundState.TokenRatesController.contractExchangeRates,
transaction: state.transaction
transaction: state.transaction,
ticker: state.engine.backgroundState.NetworkController.provider.ticker
});

export default connect(mapStateToProps)(TransactionReviewInformation);
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ describe('TransactionReviewInformation', () => {
CurrencyRateController: {
currentCurrency: 'usd',
conversionRate: 0.1
},
NetworkController: {
provider: {
ticker: 'ETH'
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ class TransactionReviewSummary extends PureComponent {
/**
* Array of ERC20 assets
*/
tokens: PropTypes.array
tokens: PropTypes.array,
/**
* Current provider ticker
*/
ticker: PropTypes.string
};

state = {
Expand Down Expand Up @@ -125,11 +129,12 @@ class TransactionReviewSummary extends PureComponent {
const {
transaction: { value, selectedAsset, assetType },
currentCurrency,
contractExchangeRates
contractExchangeRates,
ticker
} = this.props;
const values = {
ETH: () => {
const assetAmount = `${renderFromWei(value)} ${strings('unit.eth')}`;
const assetAmount = `${renderFromWei(value)} ${ticker}`;
const conversionRate = this.props.conversionRate;
const fiatValue = weiToFiat(value, conversionRate, currentCurrency);
return [assetAmount, conversionRate, fiatValue];
Expand Down Expand Up @@ -195,7 +200,8 @@ const mapStateToProps = state => ({
currentCurrency: state.engine.backgroundState.CurrencyRateController.currentCurrency,
contractExchangeRates: state.engine.backgroundState.TokenRatesController.contractExchangeRates,
tokens: state.engine.backgroundState.AssetsController.tokens,
transaction: state.transaction
transaction: state.transaction,
ticker: state.engine.backgroundState.NetworkController.provider.ticker
});

export default connect(mapStateToProps)(TransactionReviewSummary);
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ describe('TransactionReviewSummary', () => {
},
AssetsController: {
tokens: []
},
NetworkController: {
provider: {
ticker: 'ETH'
}
}
}
},
Expand Down