Skip to content

Commit

Permalink
Merge pull request #189 from go-faast/mm-balances
Browse files Browse the repository at this point in the history
Mm balances
  • Loading branch information
dwolfgram committed Feb 4, 2021
2 parents 4dfe804 + b4f7d76 commit 0aab4d3
Show file tree
Hide file tree
Showing 40 changed files with 1,303 additions and 198 deletions.
1 change: 1 addition & 0 deletions netlify.toml
Expand Up @@ -22,6 +22,7 @@
[context.staging.environment]
DEPLOY_ENV = "staging"
SITE_ROOT = "https://staging.faast.us"
API_URL = "https://testapi.faa.st"

[context.develop]
[context.develop.environment]
Expand Down
Binary file modified res/img/binancesetup2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/img/binancesetup4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/img/binancesetup5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 68 additions & 6 deletions src/app/actions/maker.js
@@ -1,15 +1,16 @@
import { newScopedCreateAction } from 'Utilities/action'
import { push } from 'react-router-redux'
import Faast from 'Services/Faast'
import { getSession } from 'Services/Auth'
import { getSession, clearSession } from 'Services/Auth'
import { sessionStorageSetJson, sessionStorageGetJson, sessionStorageClear } from 'Utilities/storage'

import { isMakerLoggedIn, isMakerDataStale } from 'Selectors/maker'
import { isMakerLoggedIn, isMakerDataStale, getMakerProfile as selectMakerProfile, isAbleToRetractCapacity } from 'Selectors/maker'
import Toastr from 'Utilities/toastrWrapper'

const createAction = newScopedCreateAction(__filename)

export const makerDataUpdated = createAction('MAKER_UPDATED')
export const removeSecretKey = createAction('REMOVE_SECRET_KEY')
export const login = createAction('MAKER_LOGIN')
export const logout = createAction('MAKER_LOGOUT')
export const loadingData = createAction('MAKER_LOADING_LOGIN')
Expand Down Expand Up @@ -64,7 +65,6 @@ export const getAllMakerData = () => (dispatch) => {
export const loginMaker = () => async (dispatch) => {
try {
let user = await dispatch(getAuth0User())
user = user[0]
if (user && (!user.app_metadata || user.app_metadata && !user.app_metadata.maker_id)) {
return dispatch(push('/makers/register/profile'))
}
Expand All @@ -73,7 +73,7 @@ export const loginMaker = () => async (dispatch) => {
dispatch(push('/makers/dashboard'))
} catch (err) {
dispatch(loginError(err))
dispatch(push('/makers/login'))
dispatch(makerLogout())
Toastr.error(err.message)
}
}
Expand All @@ -93,14 +93,26 @@ export const registerMaker = (profile) => async (dispatch) => {
const makerProfile = await Faast.createMaker(accessToken, profile)
dispatch(updateProfile(makerProfile))
dispatch(login())
dispatch(push('/makers/dashboard'))
dispatch(push('/makers/dashboard/account'))
} catch (err) {
dispatch(loginError(err))
dispatch(push('/makers/login'))
Toastr.error('Unable to complete user signup. Please contact support@faa.st.')
}
}

export const updateMaker = (data) => async (dispatch) => {
try {
const accessToken = dispatch(getMakerAccessToken())
const maker = await Faast.updateMaker(accessToken, data)
dispatch(updateProfile(maker))
return maker
} catch (err) {
Toastr.error('Unable to update your maker. Please try again later.')
}

}

export const getMakerProfile = () => (dispatch) => {
const accessToken = dispatch(getMakerAccessToken())
if (accessToken) {
Expand All @@ -117,6 +129,56 @@ export const getMakerProfile = () => (dispatch) => {
return
}

export const disableMaker = () => (dispatch) => {
const accessToken = dispatch(getMakerAccessToken())
if (accessToken) {
return Faast.disableMaker(accessToken)
.then((profile) => {
Toastr.success('Your maker has been disabled.')
return dispatch(updateProfile(profile))
}).catch(() => {
Toastr.error('Unable to disable maker. Please try again.')
})
}
}

export const enableMaker = () => (dispatch) => {
const accessToken = dispatch(getMakerAccessToken())
return Faast.enableMaker(accessToken)
.then((profile) => {
Toastr.success('Your maker has been enabled.')
return dispatch(updateProfile(profile))
}).catch(() => {
Toastr.error('Unable to enable maker. Please try again.')
})
}

export const retractCapacity = (amount) => (dispatch, getState) => {
const accessToken = dispatch(getMakerAccessToken())
const ableToRetractCapacity = isAbleToRetractCapacity(getState())
if (!ableToRetractCapacity) {
Toastr.error('You are unable to withdrawal from your capacity address. support@faa.st')
}
return Faast.retractCapacity(accessToken, amount)
.then(() => {
Toastr.success(`Successfully retracted ${amount} BTC. Your balance should be reflected shortly.`)
}).catch(() => {
Toastr.error('Unable to enable maker. Please try again.')
})
}

export const getBalanceTargets = () => (dispatch, getState) => {
const accessToken = dispatch(getMakerAccessToken())
const makerProfile = selectMakerProfile(getState())
return Faast.getMakerBalanceTargets(accessToken)
.then((balanceTargets) => {
dispatch(updateProfile({ ...makerProfile, balanceTargets }))
}).catch(() => {
Toastr.error('Unable to enable maker. Please try again.')
})
}


export const getMakerSwaps = (page, limit = 20) => (dispatch) => {
const accessToken = dispatch(getMakerAccessToken())
if (accessToken) {
Expand Down Expand Up @@ -162,8 +224,8 @@ export const restoreCachedMakerInfo = () => (dispatch, getState) => {
}

export const makerLogout = () => (dispatch) => {
clearSession()
sessionStorageClear()
dispatch(resetMaker())
dispatch(logout())
dispatch(push('/makers/login'))
}
2 changes: 1 addition & 1 deletion src/app/components/Affiliate/AccountModal/index.jsx
Expand Up @@ -24,7 +24,7 @@ export default compose(
)(({ affiliateId, secretKey, toggle, ...props }) => {
return (
<Modal
size='md' toggle={toggle} className={'border-0 mt-6 mx-md-auto'} contentClassName={classNames(modalShadow, 'p-0 border-0 flat')}
size='md' toggle={toggle} className={'border-0 mt-6 mx-md-auto'} contentClassName={classNames(modalShadow, cardHeader, 'p-0 border-0 flat')}
{...pick(props, Object.keys(Modal.propTypes))}>
<ModalHeader close={<span className='cursor-pointer' onClick={toggle}>close</span>} tag='h4' toggle={toggle} className={cardHeader}>
Affiliate Account Info
Expand Down
25 changes: 22 additions & 3 deletions src/app/components/App/view.jsx
Expand Up @@ -39,10 +39,15 @@ import MakerBalances from 'Components/Maker/Balances'
import MakerSettings from 'Components/Maker/Settings'
import MakerRegister from 'Components/Maker/Signup'
import MakerRegisterProfile from 'Components/Maker/SignupProfile'
import MakerAccountModal from 'Components/Maker/AccountModal'
import LlamaSecretModal from 'Components/Maker/LlamaSecretModal'
import CapacityDepositModal from 'Components/Maker/CapacityDepositModal'
import NotificationDepositModal from 'Src/app/components/Maker/NotificationDepositModal'
import BalanceDepositModal from 'Src/app/components/Maker/BalanceDepositModal'
import RetractCapacityModal from 'Components/Maker/RetractCapacityModal'
import MakerSetup from 'Components/Maker/MakerSetup'
import MakerExchangeSetup from 'Components/Maker/BinanceSetup'
import MakerBalanceSetup from 'Components/Maker/BalanceSetup'
import MakerNotifications from 'Components/Maker/Notifications'
import { AuthenticatedRoute, AuthRoutes } from 'Components/Auth'

import {
Expand All @@ -54,7 +59,8 @@ import {
connectMobileWallet, settings, affiliateAcceptTerms, wallets, walletDepositModal,
walletWithdrawalModal, assetNews, makerLogin, makerDashboard, makerSwaps, makerSettings,
makerLoading, makerBalances, makerRegister, makerRegisterProfile, makerAccountModal,
makerSetup, makerExchangeSetup, makerBalanceSetup
makerSetup, makerExchangeSetup, makerBalanceSetup, capacityDepositModal, makerRetractCapacityModal,
makerNotifications, makerNotifcationsDepositModal, makerBalanceDepositModal
} from 'Routes'

const AppView = ({ hasNoWallets }) => {
Expand Down Expand Up @@ -105,6 +111,7 @@ const AppView = ({ hasNoWallets }) => {
<AuthenticatedRoute path={makerSwaps.path} component={MakerSwaps} />
<AuthenticatedRoute path={makerBalances.path} component={MakerBalances} />
<AuthenticatedRoute path={makerSettings.path} component={MakerSettings} />
<AuthenticatedRoute path={makerNotifications.path} component={MakerNotifications} />

{/* Legacy routes */}
<Redirect exact from='/affiliates' to={affiliateLogin.path}/>
Expand Down Expand Up @@ -135,7 +142,19 @@ const AppView = ({ hasNoWallets }) => {
<AffiliateAccountModal {...props}/>
)}/>
<ModalRoute closePath={makerDashboard.path} path={makerAccountModal.path} render={(props) => (
<MakerAccountModal {...props}/>
<LlamaSecretModal {...props}/>
)}/>
<ModalRoute closePath={makerDashboard.path} path={capacityDepositModal.path} render={(props) => (
<CapacityDepositModal {...props}/>
)}/>
<ModalRoute closePath={makerNotifications.path} path={makerNotifcationsDepositModal.path} render={(props) => (
<NotificationDepositModal {...props}/>
)}/>
<ModalRoute closePath={makerBalances.path} path={makerBalanceDepositModal.path} render={(props) => (
<BalanceDepositModal {...props}/>
)}/>
<ModalRoute closePath={makerSettings.path} path={makerRetractCapacityModal.path} render={(props) => (
<RetractCapacityModal {...props}/>
)}/>
<Footer />
</Fragment>
Expand Down
66 changes: 41 additions & 25 deletions src/app/components/HardwareWalletModal/ConnectAsset.jsx
Expand Up @@ -9,14 +9,16 @@ import { push } from 'react-router-redux'

import routes from 'Routes'
import { getAsset } from 'Selectors/asset'
import { isStatusConnected, isStatusReset } from 'Selectors/connectHardwareWallet'
import { isStatusConnected, isStatusReset, getDerivationPath } from 'Selectors/connectHardwareWallet'
import {
startConnect, retryConnect, cancelConnect,
startConnect, retryConnect, cancelConnect, changeDerivationPath,
} from 'Actions/connectHardwareWallet'
import conditionalRedirect from 'Hoc/conditionalRedirect'

import T from 'Components/i18n/T'

import Config from 'Config'

import SwitchPathButton from './SwitchPathButton'
import DerivationPathChanger from './DerivationPathChanger'
import BackButton from './BackButton'
Expand All @@ -32,12 +34,14 @@ export default compose(
connect(createStructuredSelector({
isConnected: isStatusConnected,
isReset: isStatusReset,
asset: (state, { assetSymbol }) => getAsset(state, assetSymbol)
asset: (state, { assetSymbol }) => getAsset(state, assetSymbol),
derivationPath: getDerivationPath
}), {
start: startConnect,
retry: retryConnect,
routerPush: push,
handleBack: cancelConnect,
changeDerivationPath
}),
withProps(({ walletType, assetSymbol }) => ({
continuePath: routes.connectHwWalletAssetConfirm(walletType, assetSymbol),
Expand All @@ -54,26 +58,38 @@ export default compose(
}
})
)(({
walletType, assetSymbol, asset, handleBack, continuePath, isConnected,
}) => (
<div>
<ModalBody className='py-4'>
<ConnectionStatus />
<ConnectionInstructions type={walletType} asset={asset}/>
<div className='my-3 w-50 mx-auto'>
<div className='mb-3'>
<SwitchPathButton walletType={walletType} assetSymbol={assetSymbol}/>
walletType, assetSymbol, asset, handleBack, continuePath, isConnected, changeDerivationPath, derivationPath
}) => {
const legacyPath = Config.walletTypes.ledger.supportedAssets.ETH.legacy
const isLegacy = derivationPath == legacyPath
const defaultPath = Config.walletTypes.ledger.supportedAssets.ETH.derivationPath
return (
<div>
<ModalBody className='py-4'>
<ConnectionStatus />
<ConnectionInstructions type={walletType} asset={asset}/>
<div className='my-3 w-50 mx-auto'>
<div className='mb-3'>
<SwitchPathButton walletType={walletType} assetSymbol={assetSymbol}/>
</div>
{walletType == 'ledger' && assetSymbol == 'ETH' ? (
<Button color='primary' className='mx-auto mb-2' onClick={() => changeDerivationPath(isLegacy ? defaultPath : legacyPath)}>
<T tag='span' i18nKey='app.hardwareWalletModal.derivationPath.legacy'>
{isLegacy ? 'Use default derivation path' : 'Use Legacy ETH Derivation Path'}
</T>
</Button>
) : null}
<DerivationPathChanger />
</div>
<DerivationPathChanger />
</div>
</ModalBody>
<ModalFooter>
<BackButton onClick={handleBack}>
<T tag='span' i18nKey='app.hardwareWalletModal.connectAsset.back'>Back</T>
</BackButton>
<Button tag={Link} to={continuePath} color='success' disabled={!isConnected}>
<T tag='span' i18nKey='app.hardwareWalletModal.connectAsset.continue'>Continue</T>
</Button>
</ModalFooter>
</div>
))
</ModalBody>
<ModalFooter>
<BackButton onClick={handleBack}>
<T tag='span' i18nKey='app.hardwareWalletModal.connectAsset.back'>Back</T>
</BackButton>
<Button tag={Link} to={continuePath} color='success' disabled={!isConnected}>
<T tag='span' i18nKey='app.hardwareWalletModal.connectAsset.continue'>Continue</T>
</Button>
</ModalFooter>
</div>
)
})
55 changes: 0 additions & 55 deletions src/app/components/Maker/AccountModal/index.jsx

This file was deleted.

0 comments on commit 0aab4d3

Please sign in to comment.