-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
plondon
committed
Jul 12, 2021
1 parent
1e0a85b
commit 03a02eb
Showing
22 changed files
with
216 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ges/blockchain-wallet-v4-frontend/src/components/Form/SelectBoxDogeAddresses/selectors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// @ts-ignore | ||
import { concat, curry, reduce, sequence } from 'ramda' | ||
|
||
import { Exchange, Remote } from 'blockchain-wallet-v4/src' | ||
import { ADDRESS_TYPES } from 'blockchain-wallet-v4/src/redux/payment/btc/utils' | ||
import { selectors } from 'data' | ||
|
||
export const getData = ( | ||
state, | ||
ownProps: { | ||
exclude?: Array<string> | ||
includeCustodial?: boolean | ||
includeExchangeAddress?: boolean | ||
} | ||
) => { | ||
const { /* exclude = [], */ includeCustodial, includeExchangeAddress } = ownProps | ||
|
||
const buildCustodialDisplay = (x) => { | ||
return ( | ||
`Trading Account` + | ||
` (${Exchange.displayCoinToCoin({ | ||
coin: 'DOGE', | ||
value: x ? x.available : 0 | ||
})})` | ||
) | ||
} | ||
// @ts-ignore | ||
// const excluded = filter(x => !exclude.includes(x.label)) | ||
const toGroup = curry((label, options) => [{ label, options }]) | ||
const toExchange = (x) => [{ label: `Exchange Account`, value: x }] | ||
const toCustodialDropdown = (currencyDetails) => [ | ||
{ | ||
label: buildCustodialDisplay(currencyDetails), | ||
value: { | ||
...currencyDetails, | ||
label: 'Trading Account', | ||
type: ADDRESS_TYPES.CUSTODIAL | ||
} | ||
} | ||
] | ||
|
||
const exchangeAddress = selectors.components.send.getPaymentsAccountExchange('DOGE', state) | ||
const hasExchangeAddress = Remote.Success.is(exchangeAddress) | ||
|
||
return sequence(Remote.of, [ | ||
includeExchangeAddress && hasExchangeAddress | ||
? exchangeAddress.map(toExchange).map(toGroup('Exchange')) | ||
: Remote.of([]), | ||
includeCustodial | ||
? selectors.components.simpleBuy | ||
.getSBBalances(state) | ||
.map((x) => x.DOGE) | ||
.map(toCustodialDropdown) | ||
.map(toGroup('Custodial Wallet')) | ||
: Remote.of([]) | ||
]).map(([b1, b2]) => ({ | ||
// @ts-ignore | ||
data: reduce(concat, [], [b1, b2]) | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/blockchain-wallet-v4-frontend/src/data/coins/selectors/coins/doge.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
import { lift } from 'ramda' | ||
|
||
import { SBBalanceType } from 'blockchain-wallet-v4/src/network/api/simpleBuy/types' | ||
import { ExtractSuccess } from 'blockchain-wallet-v4/src/remote/types' | ||
import { CoinType } from 'blockchain-wallet-v4/src/types' | ||
import { createDeepEqualSelector } from 'blockchain-wallet-v4/src/utils' | ||
import { generateTradingAccount } from 'data/coins/utils' | ||
import { SwapAccountType } from 'data/components/types' | ||
|
||
import { getTradingBalance } from '..' | ||
|
||
// retrieves introduction text for coin on its transaction page | ||
export const getTransactionPageHeaderText = () => ( | ||
<FormattedMessage | ||
id='coins.doge.intro' | ||
defaultMessage='Dogecoin (DOGE) was created in 2013 as an alternative to traditional cryptocurrencies like Bitcoin.' | ||
/> | ||
) | ||
|
||
// main selector for all DOGE account types | ||
// accepts a CoinAccountSelectorType config object | ||
// NOT IMPLEMENTED FOR COIN: non-custodial accounts, imported addresses/accounts | ||
export const getAccounts = createDeepEqualSelector( | ||
[ | ||
(state, { coin }) => getTradingBalance(coin, state), // custodial accounts | ||
(state, ownProps) => ownProps // selector config | ||
], | ||
(sbBalanceR, ownProps) => { | ||
const transform = (sbBalance: ExtractSuccess<typeof sbBalanceR>) => { | ||
const { coin } = ownProps | ||
let accounts: SwapAccountType[] = [] | ||
|
||
// add trading accounts if requested | ||
if (ownProps?.tradingAccounts) { | ||
accounts = accounts.concat( | ||
generateTradingAccount(coin as CoinType, sbBalance as SBBalanceType) | ||
) | ||
} | ||
|
||
return accounts | ||
} | ||
|
||
return lift(transform)(sbBalanceR) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/blockchain-wallet-v4-frontend/src/data/components/dogeTransactions/actionTypes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const TRANSACTIONS_INITIALIZED = '@EVENT.DOGE_TX.TRANSACTIONS_INITIALIZED' | ||
|
||
export const DOGE_TRANSACTIONS_LOAD_MORE = '@EVENT.DOGE_TX.TRANSACTIONS_LOAD_MORE' |
7 changes: 7 additions & 0 deletions
7
packages/blockchain-wallet-v4-frontend/src/data/components/dogeTransactions/actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as AT from './actionTypes' | ||
|
||
export const initialized = () => ({ type: AT.TRANSACTIONS_INITIALIZED }) | ||
|
||
export const loadMore = () => ({ | ||
type: AT.DOGE_TRANSACTIONS_LOAD_MORE | ||
}) |
13 changes: 13 additions & 0 deletions
13
packages/blockchain-wallet-v4-frontend/src/data/components/dogeTransactions/sagaRegister.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { takeEvery, takeLatest } from 'redux-saga/effects' | ||
|
||
import * as AT from './actionTypes' | ||
import sagas from './sagas' | ||
|
||
export default () => { | ||
const dogeTransactionsSagas = sagas() | ||
|
||
return function* dogeTransactionsSaga() { | ||
yield takeEvery(AT.TRANSACTIONS_INITIALIZED, dogeTransactionsSagas.initialized) | ||
yield takeLatest(AT.DOGE_TRANSACTIONS_LOAD_MORE, dogeTransactionsSagas.loadMore) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/blockchain-wallet-v4-frontend/src/data/components/dogeTransactions/sagas.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { put } from 'redux-saga/effects' | ||
|
||
import { actions } from 'data' | ||
|
||
export const logLocation = 'components/dogeTransactions/sagas' | ||
|
||
export default () => { | ||
const initialized = function* () { | ||
try { | ||
yield put(actions.core.data.doge.fetchTransactions('', true)) | ||
} catch (e) { | ||
yield put(actions.logs.logErrorMessage(logLocation, 'initialized', e)) | ||
} | ||
} | ||
|
||
const loadMore = function* () { | ||
try { | ||
yield put(actions.core.data.doge.fetchTransactions()) | ||
} catch (e) { | ||
yield put(actions.logs.logErrorMessage(logLocation, 'loadMore', e)) | ||
} | ||
} | ||
return { | ||
initialized, | ||
loadMore | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.