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

Feature: advanced custom rpc #661

Merged
merged 36 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
248ba5a
add rpc target chainid ticker and nickname
estebanmino May 21, 2019
d86187b
use network nickname
estebanmino May 21, 2019
60e5027
add isETH
estebanmino May 22, 2019
e4feb71
use of ticker
estebanmino May 22, 2019
1efffbe
move settings component to settings
estebanmino May 22, 2019
26b0189
basic networks settings
estebanmino May 22, 2019
29373ef
basic network settings
estebanmino May 22, 2019
0a7be7b
add and edit forms
estebanmino May 22, 2019
d2fdecd
adding custom rpc from network settings
estebanmino May 23, 2019
98bc41c
add block explorer url
estebanmino May 23, 2019
83caeaa
handle action anabled
estebanmino May 23, 2019
6baf297
validate chainid
estebanmino May 23, 2019
b5b970d
doc and locales
estebanmino May 23, 2019
0dca0a3
drawer view in blockexplorer
estebanmino May 23, 2019
cdca683
handle block explorer from tx detauls
estebanmino May 23, 2019
48944b9
handle tx unit with ticker
estebanmino May 23, 2019
e78f358
configure native currency
estebanmino May 23, 2019
148982e
if no conversion rate shpiw 0
estebanmino May 23, 2019
55b029e
handle send from drawer
estebanmino May 23, 2019
ad5760c
handle render from wei
estebanmino May 23, 2019
e444ac0
handle eth input
estebanmino May 23, 2019
2e804f7
action keys
estebanmino May 23, 2019
d80feba
update snapshots
estebanmino May 23, 2019
3943d8e
create snapshots
estebanmino May 23, 2019
ba52200
more locales
estebanmino May 23, 2019
526a38c
conditional rpc rendering in networks sett
estebanmino May 23, 2019
13bcc76
network icon top
estebanmino May 23, 2019
13ee5ee
ticker to uppercase
estebanmino May 23, 2019
51c1c62
android ui
estebanmino May 23, 2019
96071f3
small fixes
estebanmino May 23, 2019
fbda130
more android
estebanmino May 23, 2019
a16cd30
merge dev
estebanmino May 23, 2019
c66f801
getticker getblockexoplorer
estebanmino May 23, 2019
30fc571
parse url name
estebanmino May 23, 2019
c11fe3b
bump gaba
estebanmino May 23, 2019
af78468
Merge branch 'develop' into feature/advanced-custom-rpc
estebanmino May 23, 2019
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
4 changes: 4 additions & 0 deletions app/components/Nav/App/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ exports[`App should render correctly 1`] = `
"CompanySettings": null,
"ExperimentalSettings": null,
"GeneralSettings": null,
"NetworkSettings": null,
"NetworksSettings": null,
"RevealPrivateCredentialView": null,
"SecuritySettings": null,
"Settings": null,
Expand Down Expand Up @@ -538,6 +540,8 @@ exports[`App should render correctly 1`] = `
"CompanySettings": null,
"ExperimentalSettings": null,
"GeneralSettings": null,
"NetworkSettings": null,
"NetworksSettings": null,
"RevealPrivateCredentialView": null,
"SecuritySettings": null,
"Settings": null,
Expand Down
4 changes: 4 additions & 0 deletions app/components/Nav/Main/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ exports[`Main should render correctly 1`] = `
"CompanySettings": null,
"ExperimentalSettings": null,
"GeneralSettings": null,
"NetworkSettings": null,
"NetworksSettings": null,
"RevealPrivateCredentialView": null,
"SecuritySettings": null,
"Settings": null,
Expand Down Expand Up @@ -432,6 +434,8 @@ exports[`Main should render correctly 1`] = `
"CompanySettings": null,
"ExperimentalSettings": null,
"GeneralSettings": null,
"NetworkSettings": null,
"NetworksSettings": null,
"RevealPrivateCredentialView": null,
"SecuritySettings": null,
"Settings": null,
Expand Down
16 changes: 12 additions & 4 deletions app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import AddBookmark from '../../Views/AddBookmark';
import SimpleWebview from '../../Views/SimpleWebview';
import Approval from '../../Views/Approval';
import Settings from '../../Views/Settings';
import GeneralSettings from '../../Views/GeneralSettings';
import AdvancedSettings from '../../Views/AdvancedSettings';
import GeneralSettings from '../../Views/Settings/GeneralSettings';
import AdvancedSettings from '../../Views/Settings/AdvancedSettings';
import SecuritySettings from '../../Views/Settings/SecuritySettings';
import ExperimentalSettings from '../../Views/Settings/ExperimentalSettings';
import NetworksSettings from '../../Views/Settings/NetworksSettings';
import NetworkSettings from '../../Views/Settings/NetworksSettings/NetworkSettings';
import AppInformation from '../../UI/AppInformation';
import SecuritySettings from '../../Views/SecuritySettings';
import ExperimentalSettings from '../../Views/ExperimentalSettings';
import Wallet from '../../Views/Wallet';
import TransactionsView from '../../Views/TransactionsView';
import SyncWithExtension from '../../Views/SyncWithExtension';
Expand Down Expand Up @@ -154,6 +156,12 @@ const MainNavigator = createStackNavigator(
ExperimentalSettings: {
screen: ExperimentalSettings
},
NetworksSettings: {
screen: NetworksSettings
},
NetworkSettings: {
screen: NetworkSettings
},
CompanySettings: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

teh other one is NetworksSettings

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should start wearning my 👓

screen: AppInformation
},
Expand Down
9 changes: 7 additions & 2 deletions app/components/UI/AccountList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ export default class AccountList extends Component {
/**
* function to be called when importing an account
*/
onImportAccount: PropTypes.func
onImportAccount: PropTypes.func,
/**
* Current provider ticker
*/
ticker: PropTypes.string
};

state = {
Expand Down Expand Up @@ -254,6 +258,7 @@ export default class AccountList extends Component {
}

renderItem = ({ item }) => {
const { ticker } = this.props;
const { index, name, address, balance, isSelected, isImported } = item;

const selected = isSelected ? <Icon name="check-circle" size={30} color={colors.blue} /> : null;
Expand All @@ -278,7 +283,7 @@ export default class AccountList extends Component {
{name}
</Text>
<Text style={styles.accountBalance}>
{renderFromWei(balance)} {strings('unit.eth')}
{renderFromWei(balance)} {ticker || strings('unit.eth')}
</Text>
</View>
{imported && <View style={styles.importedView}>{imported}</View>}
Expand Down
21 changes: 13 additions & 8 deletions app/components/UI/AccountSelect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { connect } from 'react-redux';
import { hexToBN } from 'gaba/util';
import { toChecksumAddress } from 'ethereumjs-util';
import { weiToFiat, renderFromWei } from '../../../util/number';
import { strings } from '../../../../locales/i18n';
import { ScrollView } from 'react-native-gesture-handler';
import { strings } from '../../../../locales/i18n';

const styles = StyleSheet.create({
root: {
Expand Down Expand Up @@ -126,7 +126,11 @@ class AccountSelect extends Component {
/**
* Primary currency, either ETH or Fiat
*/
primaryCurrency: PropTypes.string
primaryCurrency: PropTypes.string,
/**
* Current provider ticker
*/
ticker: PropTypes.string
};

static defaultProps = {
Expand All @@ -153,17 +157,17 @@ class AccountSelect extends Component {
}

renderOption(account, onPress) {
const { conversionRate, currentCurrency, primaryCurrency } = this.props;
const { conversionRate, currentCurrency, primaryCurrency, ticker } = this.props;
const balance = hexToBN(account.balance);

// render balances according to selected 'primaryCurrency'
let mainBalance, secondaryBalance;
if (primaryCurrency === 'ETH') {
mainBalance = renderFromWei(balance) + ' ' + strings('unit.eth');
secondaryBalance = weiToFiat(balance, conversionRate, currentCurrency).toUpperCase();
mainBalance = renderFromWei(balance) + ' ' + ticker || strings('unit.eth');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a getTicker fn under utils that receives ticker and returns strings('unit.eth') if null?

secondaryBalance = weiToFiat(balance, conversionRate, currentCurrency.toUpperCase());
} else {
mainBalance = weiToFiat(balance, conversionRate, currentCurrency).toUpperCase();
secondaryBalance = renderFromWei(balance) + ' ' + strings('unit.eth');
mainBalance = weiToFiat(balance, conversionRate, currentCurrency.toUpperCase());
secondaryBalance = renderFromWei(balance) + ' ' + ticker || strings('unit.eth');
}

return (
Expand Down Expand Up @@ -218,7 +222,8 @@ const mapStateToProps = state => ({
identities: state.engine.backgroundState.PreferencesController.identities,
currentCurrency: state.engine.backgroundState.CurrencyRateController.currentCurrency,
selectedAddress: state.engine.backgroundState.PreferencesController.selectedAddress,
primaryCurrency: state.settings.primaryCurrency
primaryCurrency: state.settings.primaryCurrency,
ticker: state.engine.backgroundState.NetworkController.provider.ticker
});

export default connect(mapStateToProps)(AccountSelect);
8 changes: 4 additions & 4 deletions app/components/UI/AssetOverview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class AssetOverview extends Component {

onSend = async () => {
const { asset } = this.props;
if (asset.symbol === 'ETH') {
if (asset.isEth) {
this.props.setTokensTransaction({ symbol: 'ETH' });
this.props.navigation.navigate('SendView');
} else {
Expand All @@ -123,9 +123,9 @@ class AssetOverview extends Component {

renderLogo = () => {
const {
asset: { address, image, logo, symbol }
asset: { address, image, logo, isETH }
} = this.props;
if (symbol === 'ETH') {
if (isETH) {
return <Image source={ethLogo} style={styles.ethLogo} />;
}
const watchedAsset = image !== undefined;
Expand All @@ -150,7 +150,7 @@ class AssetOverview extends Component {
let mainBalance, secondaryBalance;
const itemAddress = (asset.address && toChecksumAddress(asset.address)) || undefined;
let balance, balanceFiat;
if (asset.symbol === 'ETH') {
if (asset.isETH) {
balance = renderFromWei(accounts[selectedAddress] && accounts[selectedAddress].balance);
balanceFiat = weiToFiat(
hexToBN(accounts[selectedAddress].balance),
Expand Down
33 changes: 22 additions & 11 deletions app/components/UI/CustomGas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ class CustomGas extends Component {
/**
* Callback to modify state in parent state
*/
onPress: PropTypes.func
onPress: PropTypes.func,
/**
* Current provider ticker
*/
ticker: PropTypes.string
};

state = {
Expand Down Expand Up @@ -204,6 +208,10 @@ class CustomGas extends Component {
componentDidMount = async () => {
await this.handleFetchBasicEstimates();
this.onPressGasAverage();
const { ticker } = this.props;
if (ticker && ticker !== 'ETH') {
this.setState({ advancedCustomGas: true });
}
};

handleFetchBasicEstimates = async () => {
Expand Down Expand Up @@ -239,7 +247,8 @@ class CustomGas extends Component {

renderCustomGasSelector = () => {
const { averageGwei, fastGwei, safeLowGwei } = this.state;
const { conversionRate, currentCurrency, gas } = this.props;
const { conversionRate, currentCurrency, gas, ticker } = this.props;
const unit = ticker || strings('unit.eth');
return (
<View style={styles.selectors}>
<TouchableOpacity
Expand All @@ -255,10 +264,10 @@ class CustomGas extends Component {
{strings('transaction.gas_fee_slow')}
</Text>
<Text style={[styles.text, { color: this.state.gasSlowSelected ? colors.white : undefined }]}>
{getRenderableEthGasFee(safeLowGwei, gas)} {strings('unit.eth')}
{getRenderableEthGasFee(safeLowGwei, gas)} {unit}
</Text>
<Text style={[styles.text, { color: this.state.gasSlowSelected ? colors.white : undefined }]}>
{getRenderableFiatGasFee(safeLowGwei, conversionRate, currentCurrency, gas).toUpperCase()}
{getRenderableFiatGasFee(safeLowGwei, conversionRate, currentCurrency.toUpperCase(), gas)}
</Text>
</TouchableOpacity>
<TouchableOpacity
Expand All @@ -276,10 +285,10 @@ class CustomGas extends Component {
{strings('transaction.gas_fee_average')}
</Text>
<Text style={[styles.text, { color: this.state.gasAverageSelected ? colors.white : undefined }]}>
{getRenderableEthGasFee(averageGwei, gas)} {strings('unit.eth')}
{getRenderableEthGasFee(averageGwei, gas)} {unit}
</Text>
<Text style={[styles.text, { color: this.state.gasAverageSelected ? colors.white : undefined }]}>
{getRenderableFiatGasFee(averageGwei, conversionRate, currentCurrency, gas).toUpperCase()}
{getRenderableFiatGasFee(averageGwei, conversionRate, currentCurrency.toUpperCase(), gas)}
</Text>
</TouchableOpacity>
<TouchableOpacity
Expand All @@ -295,10 +304,10 @@ class CustomGas extends Component {
{strings('transaction.gas_fee_fast')}
</Text>
<Text style={[styles.text, { color: this.state.gasFastSelected ? colors.white : undefined }]}>
{getRenderableEthGasFee(fastGwei, gas)} {strings('unit.eth')}
{getRenderableEthGasFee(fastGwei, gas)} {unit}
</Text>
<Text style={[styles.text, { color: this.state.gasFastSelected ? colors.white : undefined }]}>
{getRenderableFiatGasFee(fastGwei, conversionRate, currentCurrency, gas).toUpperCase()}
{getRenderableFiatGasFee(fastGwei, conversionRate, currentCurrency.toUpperCase(), gas)}
</Text>
</TouchableOpacity>
</View>
Expand All @@ -307,11 +316,12 @@ class CustomGas extends Component {

renderCustomGasInput = () => {
const { customGasLimit, customGasPrice, warningGasLimit, warningGasPrice } = this.state;
const { totalGas } = this.props;
const { totalGas, ticker } = this.props;
const unit = ticker || strings('unit.eth');
return (
<View>
<Text style={styles.textTotalGas}>
{fromWei(totalGas)} {strings('unit.eth')}
{fromWei(totalGas)} {unit}
</Text>
<Text style={styles.text}>{strings('custom_gas.gas_limit')}</Text>
<TextInput
Expand Down Expand Up @@ -361,7 +371,8 @@ class CustomGas extends Component {

const mapStateToProps = state => ({
conversionRate: state.engine.backgroundState.CurrencyRateController.conversionRate,
currentCurrency: state.engine.backgroundState.CurrencyRateController.currentCurrency
currentCurrency: state.engine.backgroundState.CurrencyRateController.currentCurrency,
ticker: state.engine.backgroundState.NetworkController.provider.ticker
});

export default connect(mapStateToProps)(CustomGas);
5 changes: 5 additions & 0 deletions app/components/UI/CustomGas/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ describe('CustomGas', () => {
CurrencyRateController: {
currentCurrency: 'usd',
conversionRate: 0.1
},
NetworkController: {
provider: {
ticker: 'ETH'
}
}
}
}
Expand Down
Loading