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

chore: Enable "Substrate Dev" netwok in Dev mode #417

Merged
merged 3 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 11 additions & 10 deletions src/components/PayloadDetailsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import fonts from '../fonts';
import colors from '../colors';
import { SUBSTRATE_NETWORK_LIST, SubstrateNetworkKeys } from '../constants';
import kusamaMetadata from '../util/static-kusama';
// import substrateDevMetadata from '../util/static-substrate';
import substrateDevMetadata from '../util/static-substrate';

export default class PayloadDetailsCard extends React.PureComponent {
static propTypes = {
Expand All @@ -51,7 +51,9 @@ export default class PayloadDetailsCard extends React.PureComponent {
const isKusama =
this.props.prefix ===
SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.KUSAMA].prefix;
// const isSubstrateDev = this.props.prefix === SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.SUBSTRATE_DEV].prefix;
Kriyszig marked this conversation as resolved.
Show resolved Hide resolved
const isSubstrateDev =
this.props.prefix ===
SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.SUBSTRATE_DEV].prefix;

let metadata;
if (isKusama) {
Expand All @@ -61,15 +63,14 @@ export default class PayloadDetailsCard extends React.PureComponent {
decimals: SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.KUSAMA].decimals,
unit: SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.KUSAMA].unit
});
} else if (__DEV__ && isSubstrateDev) {
metadata = new Metadata(substrateDevMetadata);
formatBalance.setDefaults({
decimals:
SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.SUBSTRATE_DEV].decimals,
unit: SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.SUBSTRATE_DEV].unit
});
}
// } else if (isSubstrateDev) {
// metadata = new Metadata(substrateDevMetadata);

// formatBalance.setDefaults({
// decimals: SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.SUBSTRATE_DEV].decimals,
// unit: SUBSTRATE_NETWORK_LIST[SubstrateNetworkKeys.SUBSTRATE_DEV].unit
// });
// }

if (!metadata) {
this.setState({
Expand Down
21 changes: 11 additions & 10 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export const EthereumNetworkKeys = Object.freeze({

// genesisHash is used as Network key for Substrate networks
export const SubstrateNetworkKeys = Object.freeze({
KUSAMA: '0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636' // https://polkascan.io/pre/kusama-cc2/block/0
// SUBSTRATE_DEV: '0x4393a679e1830a487e8ae92733f089a80f3e24ba515b08dd8adb40fc6cedee8d', // substrate --dev commit ac6a2a783f0e1f4a814cf2add40275730cd41be1 hosted on wss://dev-node.substrate.dev .
KUSAMA: '0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636', // https://polkascan.io/pre/kusama-cc2/block/0
SUBSTRATE_DEV:
'0x4393a679e1830a487e8ae92733f089a80f3e24ba515b08dd8adb40fc6cedee8d' // substrate --dev commit ac6a2a783f0e1f4a814cf2add40275730cd41be1 hosted on wss://dev-node.substrate.dev .
Tbaut marked this conversation as resolved.
Show resolved Hide resolved
});

const unknownNetworkBase = {
Expand All @@ -46,15 +47,15 @@ const substrateNetworkBase = {
prefix: 2,
title: 'Kusama CC2',
unit: 'KSM'
},
[SubstrateNetworkKeys.SUBSTRATE_DEV]: {
color: '#ff8c00',
decimals: 15,
genesisHash: SubstrateNetworkKeys.SUBSTRATE_DEV,
prefix: 42,
title: 'Substrate Development',
unit: 'UNIT'
}
// [SubstrateNetworkKeys.SUBSTRATE_DEV]: {
// color: '#ff8c00',
// decimals: 15,
// genesisHash: SubstrateNetworkKeys.SUBSTRATE_DEV,
// prefix: 42,
// title: 'Substrate Development',
// unit: 'UNIT'
// },
// [SubstrateNetworkKeys.POLKADOT]: {
// color: '#e6007a',
// decimals: 12,
Expand Down
13 changes: 11 additions & 2 deletions src/screens/AccountNetworkChooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import { Subscribe } from 'unstated';
import colors from '../colors';
import fonts from '../fonts';
import TouchableItem from '../components/TouchableItem';
import { NETWORK_LIST, UnknownNetworkKeys } from '../constants';
import {
NETWORK_LIST,
UnknownNetworkKeys,
SubstrateNetworkKeys
} from '../constants';
import AccountsStore from '../stores/AccountsStore';
import { empty } from '../util/account';

Expand Down Expand Up @@ -51,7 +55,12 @@ class AccountNetworkChooserView extends React.PureComponent {
<ScrollView style={styles.body} contentContainerStyle={{ padding: 20 }}>
<Text style={styles.title}>CHOOSE NETWORK</Text>
{Object.entries(NETWORK_LIST)
.filter(([networkKey]) => networkKey !== UnknownNetworkKeys.UNKNOWN)
.filter(
([networkKey]) =>
(__DEV__ && networkKey !== UnknownNetworkKeys.UNKNOWN) ||
(networkKey !== SubstrateNetworkKeys.SUBSTRATE_DEV &&
networkKey !== UnknownNetworkKeys.UNKNOWN)
)
.map(([networkKey, networkParams]) => (
<TouchableItem
key={networkKey}
Expand Down
20 changes: 20 additions & 0 deletions src/util/static-substrate.js

Large diffs are not rendered by default.