Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import BigNumber from 'bignumber.js';
import { createActions } from 'spunky';
import { getStorage, setStorage } from 'shared/lib/storage';
const DEFAULT_FEE = '0.00000000';
export const ID = 'fee';
// Setters
export const setFee = createActions(ID, (fee) => async () => {
const value = new BigNumber(fee);
if (value.isNaN()) {
throw new Error(`Invalid fee value: "${fee}"`);
}
const formattedValue = value.toFixed(8);
await setStorage(ID, formattedValue);
return formattedValue;
});
// Getters
export default createActions(ID, () => async () => {
const fee = await getStorage(ID);
return typeof fee === 'string' ? fee : DEFAULT_FEE;
// @flow
import { api, u } from 'neon-js'
import { createActions } from 'spunky'
type Props = {
net: string,
address: string
}
export const ID = 'CLAIMS'
export default createActions(ID, ({ net, address }: Props = {}) => async (state: Object): Promise => {
const total = await api.getMaxClaimAmountFrom({ net, address }, api.neoscan)
return { total: total instanceof u.Fixed8 ? total.toString() : null }
})
// @flow
import { createActions } from 'spunky'
import { getDeviceInfo, getPublicKey } from '../ledger/ledgerNanoS'
export const ID = 'LEDGER'
export default createActions(ID, () => async (state: Object) => {
const deviceInfo = await getDeviceInfo()
const publicKey = await getPublicKey()
return { publicKey, deviceInfo }
})
const mapLedgerActionsToProps = (actions) => ({
poll: () => actions.call()
});
const mapLedgerDataToProps = (data) => {
const { deviceInfo, publicKey } = data || {};
return { deviceInfo, publicKey };
};
const mapLedgerErrorToProps = (error) => ({
deviceError: error
});
export default compose(
withActions(ledgerActions, mapLedgerActionsToProps),
withData(ledgerActions, mapLedgerDataToProps),
withError(ledgerActions, mapLedgerErrorToProps),
// redirect on login
withRouter,
withLogin((state, { history }) => history.push('/browser'))
)(LoginFormLedger);
const passDownProps = omit(this.props, DATA_PROP, PROGRESS_PROP)
return
}
getCallbackState = props => ({
data: props[DATA_PROP],
error: props[ERROR_PROP],
})
getCallbackProps = props =>
omit(props, DATA_PROP, ERROR_PROP, PROGRESS_PROP)
}
return compose(
withProgress(actions, { propName: PROGRESS_PROP }),
withData(actions, mapDataToProps),
withError(actions, mapErrorToProps),
)(WrappedComponent)
}
}
return (Component) => {
class WithCleanComponent extends React.PureComponent {
componentWillUnmount() {
this.props[propName]();
}
render() {
return ;
}
}
return withActions(actions, mapActionsToProps)(WithCleanComponent);
};
}
const passDownProps = omit(this.props, DATA_PROP, PROGRESS_PROP);
return ;
}
getCallbackState = (props) => {
return { data: props[DATA_PROP], error: props[ERROR_PROP] };
}
getCallbackProps = (props) => {
return omit(props, DATA_PROP, ERROR_PROP, PROGRESS_PROP);
}
}
return compose(
withProgress(actions, { propName: PROGRESS_PROP }),
withData(actions, mapDataToProps),
withError(actions, mapErrorToProps)
)(WrappedComponent);
};
}
export default function withProgressPanel(
actions,
{ title, strategy = recentlyCompletedStrategy, ...options } = {},
) {
const Loading = withProps({ title })(LoadingPanel)
const Failed = withProps(props => ({ title, onRetry: props.onRetry }))(
FailedPanel,
)
return compose(
withActions(actions, mapActionsToProps),
withProgressComponents(
actions,
{
[LOADING]: Loading,
[FAILED]: Failed,
},
{
strategy,
...options,
},
),
)
}
export default function withBalancesData(mapBalancesDataToProps: Function) {
return withData(balancesActions, mapBalancesDataToProps)
}
import { compose } from 'recompose';
import { withData } from 'spunky';
import withUnmountReset from 'shared/hocs/withUnmountReset';
import Register from './Register';
import createAccountActions from '../../actions/createAccountActions';
const mapAccountDataToProps = (account) => ({ account });
export default compose(
withUnmountReset(createAccountActions),
withData(createAccountActions, mapAccountDataToProps)
)(Register);