Skip to content

Commit

Permalink
feat(coins): fixed input ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-bc committed Oct 28, 2024
1 parent 8baa0a0 commit 220a577
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { takeLatest } from 'redux-saga/effects'

import { actions } from './slice'
import sagas from './sagas'
import { actions } from './slice'

export default () => {
const preferencesSagas = sagas()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ const PageContent = styled.div<{ center: boolean }>`
}
`

export { PageContent, Container, Content, Nav, Wrapper }
export { Container, Content, Nav, PageContent, Wrapper }
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import React, { ReactElement } from 'react'
import { useIdleTimer } from 'react-idle-timer'
import { useDispatch, useSelector } from 'react-redux'

import { getAutoLogoutTime } from '@core/redux/wallet/selectors'
import Alerts from 'components/Alerts'
import { ServiceAnnouncement, StaticAnnouncement } from 'components/Announcements'
import { SofiBanner, UkBanner, UkFooterBanner } from 'components/Banner'
import { CowboysCardComponent } from 'components/Card/CowboysCard'
import ExchangePromo from 'components/Card/ExchangePromo'
import { SupportChatForGoldUserOnly } from 'components/SupportChat'
import Tooltips from 'components/Tooltips'
import { modals } from 'data/actions'
import { RootState } from 'data/rootReducer'
import { ModalName } from 'data/types'
import ErrorBoundary from 'providers/ErrorBoundaryProvider'

import Modals from '../../../modals'
import MenuLeft from '../MenuLeft'
import MenuTop from '../MenuTop'
import { Container, Content, Nav, PageContent, Wrapper } from './WalletLayout.styles'
import { modals } from 'data/actions'
import { RootState } from 'data/rootReducer'
import { getAutoLogoutTime } from '@core/redux/wallet/selectors'

const WalletLayout = ({
approvalDate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback, useState } from 'react'
import { FormattedMessage } from 'react-intl'
import { useDispatch, useSelector } from 'react-redux'
import { Padding } from '@blockchain-com/constellation'
import { addDays, format } from 'date-fns'
import styled from 'styled-components'

Expand All @@ -26,7 +27,7 @@ import {
DepositTerms
} from 'data/types'
import { useShowConversionAlert } from 'hooks'
import { Padding } from '@blockchain-com/constellation'

import { MoreInfoContainer } from './MoreInfoContainer'

// Auto margin top so it gets pushed to the bottom
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Padding, Button, Text } from '@blockchain-com/constellation'
import { FlyoutWrapper } from 'components/Flyout'
import React, { FC, ReactNode, useState } from 'react'
import { Button, Padding, Text } from '@blockchain-com/constellation'
import styled from 'styled-components'

import { FlyoutWrapper } from 'components/Flyout'

const Container = styled(FlyoutWrapper)`
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import { HeaderType, NodeItem, NodeItemTypes, NodeTextType } from '@core/types'
import { BlockchainLoader, Button, HeartbeatLoader, Icon, Text } from 'blockchain-info-components'
import { FlyoutWrapper } from 'components/Flyout'
import CheckBox from 'components/Form/CheckBox'
import DateInputBox from 'components/Form/DateInputBox'
import Form from 'components/Form/Form'
import FormGroup from 'components/Form/FormGroup'
import FormItem from 'components/Form/FormItem'
import SelectBox from 'components/Form/SelectBox'
import TextBox from 'components/Form/TextBox'
import DateInputBox from 'components/Form/DateInputBox'

import { model } from 'data'
import { required, validFormat, ageOverEighteen } from 'services/forms'
import { ageOverEighteen, required, validFormat } from 'services/forms'

import { Props as OwnProps, SuccessStateType } from '.'
import { GetInputPlaceholder, GetNodeQuestionElements } from './model'
Expand Down Expand Up @@ -257,7 +256,6 @@ const Success: React.FC<InjectedFormProps<{}, Props> & Props> = (props) => {
}

const onChangeInput = (e, value) => {
console.log({ e, value })
const itemId = e.currentTarget.name

const { blocking, context, nodes } = props.extraSteps
Expand Down Expand Up @@ -629,7 +627,6 @@ const Success: React.FC<InjectedFormProps<{}, Props> & Props> = (props) => {
if (node.type === NodeItemTypes.DATE_SELECTION) {
return RenderDateQuestion(node)
}
console.log('UNRECOGNIZED NODE_TYPE', node.type)
return null
})}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { NetworkWarning, NetworkWarningVariant } from 'components/NetworkWarning
import QRCodeWrapper from 'components/QRCode/Wrapper'
import { actions, selectors } from 'data'
import { SwapBaseCounterTypes } from 'data/types'

import { Props as OwnProps } from '../index'
import { ClipboardWrapper } from '../model'
import { RequestSteps } from '../types'
import {
AddressDisplay,
AddressWrapper,
Expand All @@ -22,9 +26,6 @@ import {
QRCodeContainer,
Wrapper
} from './styled'
import { Props as OwnProps } from '../index'
import { ClipboardWrapper } from '../model'
import { RequestSteps } from '../types'

const { formatAddr, hasPrefix } = utils.bch

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import styled from 'styled-components'

import { getCurrency } from '@core/redux/settings/selectors'
import { getCoinViewV2 } from '@core/redux/walletOptions/selectors'
import { CellText, HeaderText, HeaderToggle, TableWrapper } from 'components/Table'
import { getData as getUserCountry } from 'components/Banner/selectors'
import { CellText, HeaderText, HeaderToggle, TableWrapper } from 'components/Table'

import { Props as _P, SuccessStateType as _S } from '.'
import { getTableColumns } from './Table'
Expand All @@ -33,7 +33,7 @@ const PricesTable = (props: Props) => {
const textFilter = useSelector((state) => formValueSelector('prices')(state, 'textFilter'))
const walletCurrency = useSelector(getCurrency).getOrElse('USD')
const isUkUser = isUserFromUK || isIpFromUK

const {
analyticsActions,
buySellActions,
Expand Down
4 changes: 2 additions & 2 deletions packages/blockchain-wallet-v4/src/network/api/kyc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export enum ExtraKYCContext {
}

export enum NodeItemTypes {
DATE_SELECTION = 'DATE_SELECTION',
INFO = 'INFO',
MULTIPLE_SELECTION = 'MULTIPLE_SELECTION',
OPEN_ENDED = 'OPEN_ENDED',
SELECTION = 'SELECTION',
SINGLE_CHECKBOX = 'SINGLE_CHECKBOX',
SINGLE_SELECTION = 'SINGLE_SELECTION',
DATE_SELECTION = 'DATE_SELECTION'
SINGLE_SELECTION = 'SINGLE_SELECTION'
}

export type VerifiedType = {
Expand Down
34 changes: 17 additions & 17 deletions packages/blockchain-wallet-v4/src/redux/data/bch/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ export default ({ api }: { api: APIType }) => {
}
}

const __processTxs = function* (txs) {
// Page == Remote ([Tx])
// Remote(wallet)
const wallet = yield select(walletSelectors.getWallet)
const walletR = Remote.of(wallet)
const accountList = (yield select(getAccountsList)).getOrElse([])
const txNotes = (yield select(getBchTxNotes)).getOrElse({})

// transformTx :: wallet -> Tx
// ProcessPage :: wallet -> [Tx] -> [Tx]
const ProcessTxs = (wallet, txList, txNotes) =>
map(transformTx.bind(undefined, wallet.getOrFail(MISSING_WALLET), [], txNotes), txList)
// ProcessRemotePage :: Page -> Page
const processedTxs = ProcessTxs(walletR, txs, txNotes)
return addFromToAccountNames(wallet, accountList, processedTxs)
}

const fetchTransactions = function* (action) {
try {
const { payload } = action
Expand Down Expand Up @@ -95,23 +112,6 @@ export default ({ api }: { api: APIType }) => {
}
}

const __processTxs = function* (txs) {
// Page == Remote ([Tx])
// Remote(wallet)
const wallet = yield select(walletSelectors.getWallet)
const walletR = Remote.of(wallet)
const accountList = (yield select(getAccountsList)).getOrElse([])
const txNotes = (yield select(getBchTxNotes)).getOrElse({})

// transformTx :: wallet -> Tx
// ProcessPage :: wallet -> [Tx] -> [Tx]
const ProcessTxs = (wallet, txList, txNotes) =>
map(transformTx.bind(undefined, wallet.getOrFail(MISSING_WALLET), [], txNotes), txList)
// ProcessRemotePage :: Page -> Page
const processedTxs = ProcessTxs(walletR, txs, txNotes)
return addFromToAccountNames(wallet, accountList, processedTxs)
}

const fetchTransactionHistory = function* ({ payload }) {
const { address, end, start } = payload
const startDate = format(new Date(start), 'dd/MM/yyyy')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import { AddressMap, Wallet, Wrapper } from '../../types'
import * as Actions from './actions'
import walletReducer from './reducers'

const wrapperFixture = require('../../types/__mocks__/wrapper.v4')

const wrapperFixture = jest.mock('../../types/__mocks__/wrapper.v4')

describe('reducers', () => {
describe('wallet', () => {
const wrapped = Wrapper.fromJS(wrapperFixture)

it('should handle SET_WRAPPER', () => {
const action = Actions.setWrapper(wrapped)
const next = walletReducer(void 0, action)
const next = walletReducer(0, action)
expect(next).toEqual(wrapped)
})

Expand Down
8 changes: 4 additions & 4 deletions packages/blockchain-wallet-v4/src/walletCrypto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ const decryptBufferWithKey = (payload, iv, key, options) => {
return decryptedBytes.toString('utf8')
}

// sha256 :: Buffer -> Buffer
export const sha256 = (data) => crypto.createHash('sha256').update(data).digest()

// hashNTimes :: Integer -> String -> String
export const hashNTimes = curry((iterations, data) => {
assert(iterations > 0, '`iterations` must be a number greater than 0')
let result = data
for (let i = 1; i <= iterations; i++) {
for (let i = 1; i <= iterations; i += 1) {
result = sha256(result)
}
return result
Expand Down Expand Up @@ -123,9 +126,6 @@ export const decryptDataWithKey = curry((data, key) => {
return decryptBufferWithKey(payload, iv, key)
})

// sha256 :: Buffer -> Buffer
export const sha256 = (data) => crypto.createHash('sha256').update(data).digest()

// generateMnemonic :: Api -> Promise String
export const generateMnemonic = (api) => {
return createRng(16, api).then((rng) => BIP39.generateMnemonic(null, rng))
Expand Down

0 comments on commit 220a577

Please sign in to comment.