Skip to content

Commit

Permalink
Merge pull request #738 from hubiinetwork/feature/0.10.0
Browse files Browse the repository at this point in the history
v0.10.0
  • Loading branch information
katat committed Mar 15, 2019
2 parents 5b3e1b1 + 81f396a commit 92c6f3b
Show file tree
Hide file tree
Showing 51 changed files with 4,280 additions and 1,514 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hubii-core",
"version": "0.9.6",
"version": "0.10.0-beta.1",
"author": {
"name": "hubii",
"email": "info@hubii.com",
Expand Down Expand Up @@ -292,6 +292,7 @@
"electron-reload": "^1.2.5",
"electron-remote": "^1.3.0",
"electron-updater": "^3.0.1",
"electron-window-state": "^5.0.3",
"emoji-dictionary": "^1.0.9",
"ensure-error": "^1.0.0",
"ethereumjs-tx": "^1.3.6",
Expand Down
1,008 changes: 792 additions & 216 deletions src/components/TransferForm/tests/__snapshots__/index.test.js.snap

Large diffs are not rendered by default.

126 changes: 73 additions & 53 deletions src/components/WalletItemCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
CardIcon,
LeftSideWrapper,
TotalBalance,
OuterWrapper,
DynamicOuterWrapper,
IconMenu as Menu,
MenuItem,
MenuDivider,
Expand All @@ -34,6 +34,7 @@ import {
QuickAddressWrapper,
QuickAddressText,
QuickAddressIcon,
ToggleExpandedArrow,
} from './style';

/**
Expand Down Expand Up @@ -113,13 +114,15 @@ export class WalletItemCard extends React.PureComponent {
const {
address,
name,
folded,
baseLayerBalancesLoading,
baseLayerBalancesError,
nahmiiBalancesLoading,
nahmiiBalancesError,
connected,
type,
handleCardClick,
handleToggleFold,
totalBalance,
isDecrypted,
baseLayerAssets,
Expand Down Expand Up @@ -196,27 +199,39 @@ export class WalletItemCard extends React.PureComponent {
walletType={isHardwareWallet(type) ? 'hardware' : 'software'}
/>
<IconsWrapper>
<CardIcon>
<Popover
placement="right"
trigger="hover"
content={
<WalletDetailPopoverContent address={address} type={type} />
}
>
<Icon type="info-circle-o" style={{ fontSize: '1.4rem' }} />
</Popover>
</CardIcon>
<CardIconSettings>
<Dropdown placement="bottomLeft" overlay={this.settingsMenu(type, isDecrypted)}>
<Icon
type="setting"
style={{ marginTop: -35, position: 'absolute', fontSize: '1.4rem' }}
/>
</Dropdown>
</CardIconSettings>
<div style={{ display: 'flex' }}>
<CardIcon>
<Popover
placement="right"
trigger="hover"
content={
<WalletDetailPopoverContent address={address} type={type} />
}
>
<Icon type="info-circle-o" style={{ fontSize: '1.4rem' }} />
</Popover>
</CardIcon>
<ToggleExpandedArrow
expanded={folded ? 0 : 1}
onClick={() => {
handleToggleFold(address);
}}
/>
</div>
{
!folded &&
<CardIconSettings>
<Dropdown placement="bottomLeft" overlay={this.settingsMenu(type, isDecrypted)}>
<Icon
type="setting"
style={{ marginTop: -35, position: 'absolute', fontSize: '1.4rem' }}
/>
</Dropdown>
</CardIconSettings>
}
</IconsWrapper>
<OuterWrapper
<DynamicOuterWrapper
folded={folded}
onClick={() => {
handleCardClick(address);
}}
Expand All @@ -238,40 +253,43 @@ export class WalletItemCard extends React.PureComponent {
<TotalBalance>{`${formatFiat(totalBalance, 'USD')}`}</TotalBalance>
}
</LeftSideWrapper>
<div>
{
!folded &&
<div>
<Text>{formatMessage({ id: 'base_layer_balances' })}</Text>
<AssetsWrapper>
{
baseLayerBalancesError
&& <WalletName>{formatMessage({ id: 'fetch_balance_error' })}</WalletName>
}
{
baseLayerBalancesLoading &&
<Spinner type="loading" />
}
{!baseLayerBalancesLoading && !baseLayerBalancesError && baseLayerAssetBubbles}
</AssetsWrapper>
<div>
<Text>{formatMessage({ id: 'base_layer_balances' })}</Text>
<AssetsWrapper>
{
baseLayerBalancesError
&& <WalletName>{formatMessage({ id: 'fetch_balance_error' })}</WalletName>
}
{
baseLayerBalancesLoading &&
<Spinner type="loading" />
}
{!baseLayerBalancesLoading && !baseLayerBalancesError && baseLayerAssetBubbles}
</AssetsWrapper>
</div>
<div style={{ marginTop: '1.25rem' }}>
<NahmiiText />
<Text>
&nbsp;{formatMessage({ id: 'balances' })}
</Text>
<AssetsWrapper>
{
nahmiiBalancesError
&& <WalletName>{formatMessage({ id: 'fetch_balance_error' })}</WalletName>
}
{
nahmiiBalancesLoading
&& <Spinner type="loading" />
}
{!nahmiiBalancesLoading && !nahmiiBalancesError && nahmiiAssetBubbles}
</AssetsWrapper>
</div>
</div>
<div style={{ marginTop: '1.25rem' }}>
<NahmiiText />
<Text>
&nbsp;{formatMessage({ id: 'balances' })}
</Text>
<AssetsWrapper>
{
nahmiiBalancesError
&& <WalletName>{formatMessage({ id: 'fetch_balance_error' })}</WalletName>
}
{
nahmiiBalancesLoading
&& <Spinner type="loading" />
}
{!nahmiiBalancesLoading && !nahmiiBalancesError && nahmiiAssetBubbles}
</AssetsWrapper>
</div>
</div>
</OuterWrapper>
}
</DynamicOuterWrapper>
<Modal
footer={null}
width={modalType === 'deleteWallet' ? '37.14rem' : '50rem'}
Expand All @@ -293,6 +311,7 @@ export class WalletItemCard extends React.PureComponent {

WalletItemCard.propTypes = {
name: PropTypes.string.isRequired,
folded: PropTypes.bool.isRequired,
totalBalance: PropTypes.number.isRequired,
baseLayerAssets: PropTypes.arrayOf(
PropTypes.shape({
Expand All @@ -314,6 +333,7 @@ WalletItemCard.propTypes = {
type: PropTypes.string.isRequired,
connected: PropTypes.bool,
handleCardClick: PropTypes.func.isRequired,
handleToggleFold: PropTypes.func.isRequired,
notify: PropTypes.func.isRequired,
deleteWallet: PropTypes.func.isRequired,
lock: PropTypes.func.isRequired,
Expand Down
23 changes: 21 additions & 2 deletions src/components/WalletItemCard/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const IconsWrapper = styled.div`
justify-content: space-between;
position: absolute;
right: 0;
margin-right: 1.65rem;
margin-top: 1.29rem;
margin-bottom: 1.29rem;
`;
Expand Down Expand Up @@ -81,7 +80,6 @@ export const OuterWrapper = styled.div`
display: flex;
flex-direction: column;
flex: 1;
min-height: 8.57rem;
padding: 1.29rem 1.71rem;
background-color: ${({ theme }) => theme.palette.primary4};
color: white;
Expand All @@ -94,6 +92,12 @@ export const OuterWrapper = styled.div`
}
`;

export const DynamicOuterWrapper = OuterWrapper.extend.attrs({
style: (props) => ({
height: props.folded ? '4.5rem' : 'fit-content',
}),
})``;

export const RightSideTopWrapper = styled.div`
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -147,3 +151,18 @@ export const QuickAddressIcon = styled(Button).attrs({
transform: scale(0.85);
word-break: break-word;
`;

export const ToggleExpandedArrow = styled(Icon).attrs({
type: 'down',
style: ({ expanded }) => ({
transform: `rotate(${expanded * 180}deg)`,
}),
})`
margin-right: 0.5rem;
margin-left: 0.3rem;
padding-top: 0.3rem;
color: ${({ theme }) => theme.palette.info};
&:hover {
cursor: pointer;
}
`;
20 changes: 12 additions & 8 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,40 @@ const trimmableWalletApiEndpoint = (endpoint) => (trimmed) => {
return endpoint;
};

const ROPSTEN_URL = 'https://api2.dev.hubii.net/';
const MAINNET_URL = 'https://api.nahmii.io/';
const ROPSTEN_API_URL = 'https://api2.dev.hubii.net/';
const MAINNET_API_URL = 'https://api.nahmii.io/';

const ROPSTEN_NODE = 'http://geth-ropsten.dev.hubii.net';
const MAINNET_NODE = 'http://ethereum.hubii.com:8545';

export const SUPPORTED_NETWORKS = {
mainnet: {
name: 'mainnet',
provider: getDefaultProvider('mainnet'),
nahmiiProvider: new nahmii.NahmiiProvider(
trimmableWalletApiEndpoint(MAINNET_URL)(true),
defaultNahmiiProvider: new nahmii.NahmiiProvider(
trimmableWalletApiEndpoint(MAINNET_API_URL)(true),
MAINNET_IDENTITY_SERVICE_APPID,
MAINNET_IDENTITY_SERVICE_SECRET,
MAINNET_NODE,
1
),
walletApiEndpoint: trimmableWalletApiEndpoint(MAINNET_URL),
apiDomain: trimmableWalletApiEndpoint(MAINNET_API_URL)(true),
walletApiEndpoint: trimmableWalletApiEndpoint(MAINNET_API_URL),
identityServiceSecret: process.env.NODE_ENV === 'test' ? 'secret' : MAINNET_IDENTITY_SERVICE_SECRET,
identityServiceAppId: process.env.NODE_ENV === 'test' ? 'appid' : MAINNET_IDENTITY_SERVICE_APPID,
},
ropsten: {
name: 'ropsten',
provider: getDefaultProvider('ropsten'),
nahmiiProvider: new nahmii.NahmiiProvider(
trimmableWalletApiEndpoint(ROPSTEN_URL)(true),
defaultNahmiiProvider: new nahmii.NahmiiProvider(
trimmableWalletApiEndpoint(ROPSTEN_API_URL)(true),
ROPSTEN_IDENTITY_SERVICE_APPID,
ROPSTEN_IDENTITY_SERVICE_SECRET,
ROPSTEN_NODE,
3
),
walletApiEndpoint: trimmableWalletApiEndpoint(ROPSTEN_URL),
apiDomain: trimmableWalletApiEndpoint(ROPSTEN_API_URL)(true),
walletApiEndpoint: trimmableWalletApiEndpoint(ROPSTEN_API_URL),
identityServiceSecret: process.env.NODE_ENV === 'test' ? 'secret' : ROPSTEN_IDENTITY_SERVICE_SECRET,
identityServiceAppId: process.env.NODE_ENV === 'test' ? 'appid' : ROPSTEN_IDENTITY_SERVICE_APPID,
},
Expand Down
27 changes: 25 additions & 2 deletions src/containers/App/actions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { SUPPORTED_NETWORKS } from 'config/constants';
import {
NOTIFY,
CHANGE_NETWORK,
INIT_NETWORK_ACTIVITY,
INIT_NAHMII_PROVIDERS,
UPDATE_NAHMII_PROVIDER,
UPDATE_CURRENT_NETWORK_NAHMII_PROVIDER,
} from './constants';


Expand All @@ -18,7 +20,28 @@ export function notify(messageType, message, customDuration) {
export function changeNetwork(name) {
return {
type: CHANGE_NETWORK,
network: SUPPORTED_NETWORKS[name],
name,
};
}

export function initNahmiiProviders() {
return {
type: INIT_NAHMII_PROVIDERS,
};
}

export function updateNahmiiProvider(nahmiiProvider, networkName) {
return {
type: UPDATE_NAHMII_PROVIDER,
nahmiiProvider,
networkName,
};
}

export function updateCurrentNetworkNahmiiProvider(nahmiiProvider) {
return {
type: UPDATE_CURRENT_NETWORK_NAHMII_PROVIDER,
nahmiiProvider,
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/containers/App/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ export const DEFAULT_LOCALE = 'en';

export const NOTIFY = 'src/App/NOTIFY';
export const CHANGE_NETWORK = 'src/App/CHANGE_NETWORK';
export const INIT_NAHMII_PROVIDERS = 'src/App/INIT_NAHMII_PROVIDERS';
export const UPDATE_NAHMII_PROVIDER = 'src/App/UPDATE_NAHMII_PROVIDER';
export const UPDATE_CURRENT_NETWORK_NAHMII_PROVIDER = 'src/App/UPDATE_CURRENT_NETWORK_NAHMII_PROVIDER';

export const INIT_NETWORK_ACTIVITY = 'src/App/INIT_NETWORK_ACTIVITY';
10 changes: 9 additions & 1 deletion src/containers/App/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {

import {
CHANGE_NETWORK,
UPDATE_NAHMII_PROVIDER,
UPDATE_CURRENT_NETWORK_NAHMII_PROVIDER,
} from './constants';

export const initialState = fromJS({
Expand All @@ -30,10 +32,16 @@ function appReducer(state = initialState, action) {
switch (action.type) {
case CHANGE_NETWORK:
return state
.set('currentNetwork', fromJS(action.network));
.set('currentNetwork', state.get('supportedNetworks').get(action.name));
case LOAD_IDENTITY_SERVICE_TOKEN_SUCCESS:
return state
.setIn(['currentNetwork', 'identityServiceToken'], fromJS(action.token));
case UPDATE_NAHMII_PROVIDER:
return state
.setIn(['supportedNetworks', action.networkName, 'nahmiiProvider'], fromJS(action.nahmiiProvider));
case UPDATE_CURRENT_NETWORK_NAHMII_PROVIDER:
return state
.setIn(['currentNetwork', 'nahmiiProvider'], action.nahmiiProvider);
default:
return state;
}
Expand Down
Loading

0 comments on commit 92c6f3b

Please sign in to comment.