Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
963d40e
feat(wallet pubkey): preliminary refactor work for coins - part 1
Jul 15, 2022
00904b3
Merge branch 'development' into feat/wallet-pubkey-service
Aug 8, 2022
c16a328
feat(pubkey): finish coin folder refactor
Aug 8, 2022
3fb0bcc
feat(pubkey): add more accounts to init sub - wip
Aug 15, 2022
ddd0bf4
feat(pubkey): fetch unified balances after init sub
Aug 15, 2022
e9ac276
feat(pubkey): remove hardcoded non custodial coins from getCoinsWithB…
Aug 15, 2022
82edb96
feat(pubkey): remove unused balances selector utils
Aug 15, 2022
acbc72e
feat(pubkey): continue refactor of coins balance fetch - stx
Aug 16, 2022
0df0c60
Merge branch 'development' into feat/wallet-pubkey-service
Aug 16, 2022
679b583
feat(pubkey): add in stellar
Aug 17, 2022
56b5a9f
feat(pubkey): remove separate balance call for stx
Aug 22, 2022
398297d
Merge branch 'development' into feat/wallet-pubkey-service
Aug 22, 2022
29f4a53
chore(core): refactor coins to use slice
Aug 22, 2022
a79f961
feat(pubkey): move unified balance to core
Aug 22, 2022
fc94d79
feat(pubkey): remove account token balances erc20 request
Aug 22, 2022
5cea5e4
feat(eth): remove insufficent eth for send
Aug 22, 2022
ebc1f58
feat(pubkey): prefer pubkey service over xlm account fetch
Aug 23, 2022
6146ca4
feat: init save subs to state
rsteubs-bc Aug 23, 2022
64d3736
feat: add in sub to new coins
rsteubs-bc Aug 24, 2022
3ac9db4
fix: paths
rsteubs-bc Aug 24, 2022
f066874
Merge branch 'development' into feat/wallet-pubkey-service
Aug 24, 2022
5473af0
feat(pubkey): only fetch xlm account when send screen is loaded
Aug 24, 2022
f521328
feat(pubkey): fix xlm send
Aug 24, 2022
ff21b78
fix: cleanup
rsteubs-bc Aug 24, 2022
67182c0
Merge pull request #5319 from blockchain/feat/add-sub-when-generate-r…
rsteubs-bc Aug 25, 2022
89fc810
feat(pubkey): add separate matic subscription
Aug 26, 2022
2e6f366
Merge branch 'development' into feat/wallet-pubkey-service
Aug 26, 2022
a5b30d4
feat(pubkey): add dynamic self custody product to matic
Aug 29, 2022
6308521
feat(pubkey): more work making tx history page generic
Aug 29, 2022
3b5248c
feat(pubkey): show matic receive addr
Aug 30, 2022
e19c9f9
Merge branch 'feat/wallet-pubkey-service' of github.com:blockchain/bl…
Aug 30, 2022
84572f6
feat(pubkey): switch over to unified activity for dynamic self custod…
Aug 30, 2022
d9e691a
feat(pubkey): initial work for displaying unified activity
Aug 31, 2022
52122fc
feat(pubkey): wip - fix download tx history for dynamic
Aug 31, 2022
ad886ca
fix: add in matic to subscribe fn
rsteubs-bc Sep 6, 2022
b4bf231
WIP tx history fetch
Sep 6, 2022
75847c8
Merge branch 'feat/wallet-pubkey-service' of github.com:blockchain/bl…
Sep 6, 2022
abccc75
Merge branch 'development' into feat/wallet-pubkey-service
Sep 6, 2022
7a56553
feat(pubkey): get download tx history clear function working
Sep 7, 2022
3a71101
feat(pubkey): ability to download self custody coin tx history
Sep 7, 2022
0b90f92
feat(pubkey): get matic send working
Sep 14, 2022
b7be0fc
feat(pubkey): remove hardcoded evm likes
Sep 14, 2022
b9cb803
fix(pubkey): subscribe to coin not account
Sep 16, 2022
fac60ab
fix(send): remove is evm check on validator, use evm service
Sep 16, 2022
2297bf3
add comment
Sep 16, 2022
6c50bff
Merge branch 'development' into feat/wallet-pubkey-service
Sep 19, 2022
4843f78
fix(pubky): fix other tx types for unified activity
Sep 20, 2022
1ad509b
fix(pubkey): show coins w only trading balance
Sep 23, 2022
3a1da97
chore(merge): merge dev into feat branch
TheLeoB Oct 25, 2022
246559a
Merge branch 'development' into feat/wallet-pubkey-dev-merged
TheLeoB Nov 1, 2022
7972d29
Merge branch 'development' of https://github.com/blockchain/blockchai…
gribeiro-bc Nov 7, 2022
9aba216
Merge branch 'development' of ssh://github.com/blockchain/blockchain-…
gribeiro-bc Nov 8, 2022
a24b2b3
Merge branch 'development' of ssh://github.com/blockchain/blockchain-…
gribeiro-bc Nov 10, 2022
151f83b
Merge branch 'development' of ssh://github.com/blockchain/blockchain-…
gribeiro-bc Nov 21, 2022
264fca3
feat(unifiedws): barebones for activity
gribeiro-bc Nov 23, 2022
d3f032d
Merge branches 'feat/wallet-pubkey-dev-merged' and 'development' of s…
gribeiro-bc Dec 20, 2022
49a5837
Merge branch 'development' into feat/wallet-pubkey-dev-merged
gribeiro-bc Jan 3, 2023
53090e9
Merge branch 'development' into feat/wallet-pubkey-dev-merged
gribeiro-bc Jan 9, 2023
7a395a4
Merge branch 'development' of ssh://github.com/blockchain/blockchain-…
gribeiro-bc Jan 10, 2023
f51a754
Merge branch 'development' into feat/wallet-pubkey-dev-merged
TheLeoB Feb 6, 2023
77bcdc9
feat(super): mock up for balances
TheLeoB Feb 6, 2023
15e2e59
feat(super-app): prelim swap work
TheLeoB Feb 9, 2023
5f9203b
chore(Release): v4.82.4
TheLeoB Feb 10, 2023
332d914
chore(Release): v4.82.5
TheLeoB Feb 10, 2023
c61243d
feat(swap): wip swap account for defi v accts
TheLeoB Feb 11, 2023
d0e45b7
Merge branch 'release/v4.82' into feat/feb6-walletpubkey
TheLeoB Feb 13, 2023
a764a0e
fix(comments): add a couple of comments
TheLeoB Feb 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-function": "off",
"consistent-return": "off",
"class-methods-use-this": "off",
"func-names": "off",
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-param-reassign": "off",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blockchain-wallet-v4",
"version": "4.82.3",
"version": "4.82.5",
"license": "AGPL-3.0-or-later",
"private": true,
"author": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,6 @@
"modals.active-rewards.withdrawal.total-balance-message": "Requesting a withdrawal from your Active Rewards Account will send your total balance to your Bitcoin Trading Account.",
"modals.active-rewards.withdrawalrequested.activerewardsbutton": "Go to {coin} Active Rewards",
"modals.active-rewards.withdrawalrequested.description": "Your withdrawal will be executed once this week's strategy is complete.",
"modals.active-rewards.withdrawalrequested.historybutton": "See Transfer Details",
"modals.active-rewards.withdrawalrequested.title": "Withdrawal Requested",
"modals.activeRewards.balancedropdown.button": "Show in {currency}",
"modals.addbitcoinwallet.button": "Create New Bitcoin Wallet",
Expand Down Expand Up @@ -2466,8 +2465,8 @@
"scenes.recovery.import.body": "There’s no account associated with the seed phrase you entered. You can import and manage your wallet instead.",
"scenes.recovery.import.title": "Import Your Wallet",
"scenes.recovery.invalid_twofa": "Incorrect code",
"scenes.recovery.reset_warning_bodytext": "To restore your Private Key Wallets, please use your cloud backup or recovery phrase.",
"scenes.recovery.reset_warning_titletext": "This method only restores your Trading and Rewards Accounts",
"scenes.recovery.reset_warning_bodytext": "To restore your Private Key Wallet (DeFi Wallet), please use your cloud backup or recovery phrase.",
"scenes.recovery.reset_warning_titletext": "This method only restores your Trading and Earn Accounts",
"scenes.recovery.reverify_warning": "For your security, you may be to re-verify your identity before accessing your Wallet or Exchange funds.",
"scenes.recovery.setup2FA.getCode": "Get Verification Code",
"scenes.recovery.setup2FA.submitCode": "Submit Code",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styled from 'styled-components'
import Currencies from '@core/exchange/currencies'
import { Icon, Text } from 'blockchain-info-components'
import { AmountTextBox } from 'components/Exchange'
import { useCoinConfig } from 'hooks'
import { formatTextAmount } from 'services/forms'

const AmountContainer = styled.div`
Expand Down Expand Up @@ -63,6 +64,8 @@ const AmountFieldInput: React.FC<Props> = ({
return formatTextAmount(value, allValues && allValues.fix === 'FIAT')
}

const { coinfig } = window.coins[coin || 'BTC']

const resizeSymbol = (isFiat, inputNode, fontSizeRatio, fontSizeNumber) => {
if (Number(fontSizeRatio) > 0) {
setRatio(fontSizeRatio > 1 ? 1 : fontSizeRatio)
Expand Down Expand Up @@ -118,7 +121,7 @@ const AmountFieldInput: React.FC<Props> = ({

{fix === 'CRYPTO' && (
<Text size='56px' color={amountError ? 'red400' : 'textBlack'} weight={500}>
{coin}
{coinfig.displaySymbol}
</Text>
)}
{showToggle ? (
Expand All @@ -144,7 +147,7 @@ const AmountFieldInput: React.FC<Props> = ({
weight={500}
data-e2e='sendQuoteAmount'
>
{fix === 'FIAT' && coin} {quote} {fix === 'CRYPTO' && fiatCurrency}
{fix === 'FIAT' && coinfig.displaySymbol} {quote} {fix === 'CRYPTO' && fiatCurrency}
</Text>
</>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import { concat, curry, reduce, sequence } from 'ramda'

import { Exchange, Remote } from '@core'
import { getBalance } from '@core/redux/data/coins/selectors'
import { ADDRESS_TYPES } from '@core/redux/payment/btc/utils'
import { EarnAccountBalanceResponseType } from '@core/types'
import { selectors } from 'data'
import { getCoinNonCustodialBalance } from 'data/balances/selectors'

export const getData = (
state,
Expand Down Expand Up @@ -72,7 +72,7 @@ export const getData = (
const toSelfCustodyDropdown = (balance) => [
{
label: buildSelfCustodyDisplay(balance),
value: { balance, label: 'Private Key', type: ADDRESS_TYPES.ACCOUNT }
value: { balance, coin, label: 'Private Key', type: ADDRESS_TYPES.ACCOUNT }
}
]
const toInterestDropdown = (account) =>
Expand Down Expand Up @@ -104,7 +104,9 @@ export const getData = (
.map(toGroup('Custodial Wallet'))
: Remote.of([]),
includeSelfCustody
? getBalance(coin, state).map(toSelfCustodyDropdown).map(toGroup('Private Key'))
? getCoinNonCustodialBalance(coin)(state)
.map(toSelfCustodyDropdown)
.map(toGroup('Private Key'))
: Remote.of([]),
includeInterest
? selectors.components.interest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getData = (
if (has('balance', wallet)) {
const xlmDisplay = Exchange.displayCoinToCoin({
coin: 'XLM',
value: wallet.balnace
value: wallet.balance
})
return `${wallet.label} (${xlmDisplay})`
}
Expand Down
2 changes: 2 additions & 0 deletions packages/blockchain-wallet-v4-frontend/src/data/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as form from './form/actions'
import { actions as goals } from './goals/slice'
import { actions as logs } from './logs/slice'
import * as middleware from './middleware/actions'
import * as activities from './middleware/webSocket/activities/actions'
import * as ws from './middleware/webSocket/coins/actions'
import { actions as misc } from './misc/slice'
import { actions as modals } from './modals/slice'
Expand All @@ -24,6 +25,7 @@ import { actions as signup } from './signup/slice'
import * as wallet from './wallet/actions'

export {
activities,
alerts,
analytics,
auth,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Account Recovery Events
export enum Events {
ACCOUNT_RECOVERY_2FA_ACTIVATION = 'Account Recovery 2FA Activation',
ACCOUNT_RECOVERY_2FA_CONFIRMED = 'Account Recovery 2FA Confirmed',
ACCOUNT_RECOVERY_2FA_DISMISSED = 'Account Recovery 2FA Dismissed',
ACCOUNT_RECOVERY_2FA_PROMPTED = 'Account Recovery 2FA Prompted',
ACCOUNT_RECOVERY_EMAIL_CLICKED = 'Account Recovery Email Clicked',
ACCOUNT_RECOVERY_EMAIL_SENT = 'Account Recovery Email Sent',
ACCOUNT_RECOVERY_FORGOT_PASSWORD_VIEWED = 'Account Recovery Forgot Password Viewed',
Expand All @@ -21,6 +24,9 @@ export enum Events {
type AccountRecoveryActions = {
key:
| Events.ACCOUNT_RECOVERY_2FA_ACTIVATION
| Events.ACCOUNT_RECOVERY_2FA_PROMPTED
| Events.ACCOUNT_RECOVERY_2FA_DISMISSED
| Events.ACCOUNT_RECOVERY_2FA_CONFIRMED
| Events.ACCOUNT_RECOVERY_EMAIL_CLICKED
| Events.ACCOUNT_RECOVERY_EMAIL_SENT
| Events.ACCOUNT_RECOVERY_FORGOT_PASSWORD_VIEWED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum Events {
LOGIN_2FA_PAGE_VIEWED = '2fa Page Viewed',
LOGIN_CLICKED = 'Login Clicked',
LOGIN_DEVICE_VERIFIED = 'Device Verified',
LOGIN_FORGOT_PASSWORD_CLICKED = 'Forgot Your Password Clicked',
LOGIN_HELP_CLICKED = 'Login Help Clicked',
LOGIN_IDENTIFIER_ENTERED = 'Login Identifier Entered',
LOGIN_IDENTIFIER_FAILED = 'Login Identifier Failed',
Expand Down Expand Up @@ -32,6 +33,7 @@ type LoginActions = {
| Events.LOGIN_RECOVERY_OPTION_SELECTED
| Events.LOGIN_PASSWORD_DENIED
| Events.LOGIN_HELP_CLICKED
| Events.LOGIN_FORGOT_PASSWORD_CLICKED
| Events.LOGIN_DEVICE_VERIFIED
| Events.LOGIN_IDENTIFIER_ENTERED
| Events.LOGIN_IDENTIFIER_FAILED
Expand Down
55 changes: 51 additions & 4 deletions packages/blockchain-wallet-v4-frontend/src/data/auth/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { startSubmit, stopSubmit } from 'redux-form'
import { all, call, fork, put, select, take } from 'redux-saga/effects'

import { coreSelectors } from '@core'
import { APIType } from '@core/network/api'
import { CountryScope, WalletOptionsType } from '@core/types'
import { sha256 } from '@core/walletCrypto'
import { actions, actionTypes, selectors } from 'data'
import { ClientErrorProperties } from 'data/analytics/types/errors'
import { fetchBalances } from 'data/balances/sagas'
Expand Down Expand Up @@ -42,7 +44,7 @@ import {
ProductAuthOptions
} from './types'

export default ({ api, coreSagas, networks }) => {
export default ({ api, coreSagas, networks }: { api: APIType; coreSagas: any; networks: any }) => {
const logLocation = 'auth/sagas'
const { createExchangeUser, createUser } = profileSagas({
api,
Expand Down Expand Up @@ -242,6 +244,48 @@ export default ({ api, coreSagas, networks }) => {
}
}

const authWalletPubkeyService = function* ({
guid,
sharedKey
}: {
guid: string
sharedKey: string
}) {
try {
const sharedKeyHash = sha256(sharedKey).toString('hex')
const response = yield call(api.authWalletPubkeyService, { guid, sharedKeyHash })
return response.success
} catch (e) {
return false
}
}

const subscribeToUnifiedBalances = function* () {
const guid = yield select(selectors.core.wallet.getGuid)
const sharedKey = yield select(selectors.core.wallet.getSharedKey)

const guidHash = sha256(guid).toString('hex')
const sharedKeyHash = sha256(sharedKey).toString('hex')

const auth = yield call(authWalletPubkeyService, { guid, sharedKey })
if (!auth) return
try {
yield put(actions.core.data.coins.getSubscriptionsLoading())
const subscriptions: ReturnType<typeof api.getSubscriptions> = yield call(
api.getSubscriptions,
{ guidHash, sharedKeyHash }
)
yield put(actions.core.data.coins.getSubscriptionsSuccess(subscriptions))
if (subscriptions.currencies.length === 0) {
yield put(actions.core.data.coins.initializeSubscriptions())
} else {
yield put(actions.core.data.coins.fetchUnifiedBalances())
}
} catch (e) {
yield put(actions.core.data.coins.getSubscriptionsFailure())
}
}

const checkWalletDerivationsLegitimacy = function* () {
const accounts = yield call(coreSagas.wallet.getAccountsWithIncompleteDerivations)

Expand Down Expand Up @@ -325,7 +369,6 @@ export default ({ api, coreSagas, networks }) => {
yield call(coreSagas.kvStore.xlm.fetchMetadataXlm, askSecondPasswordEnhancer)
yield call(coreSagas.kvStore.bch.fetchMetadataBch)
yield call(coreSagas.data.xlm.fetchLedgerDetails)
yield call(coreSagas.data.xlm.fetchData)

yield call(authNabu, firstLogin)
if (product === ProductAuthOptions.EXCHANGE && (recovery || !firstLogin)) {
Expand All @@ -334,7 +377,7 @@ export default ({ api, coreSagas, networks }) => {
)
}
const guid = yield select(selectors.core.wallet.getGuid)
if (firstLogin && !isAccountReset && !recovery) {
if (firstLogin && !isAccountReset && !recovery && country) {
// create nabu user
yield call(createUser)
yield call(api.setUserInitialAddress, country, state)
Expand Down Expand Up @@ -390,6 +433,7 @@ export default ({ api, coreSagas, networks }) => {
} else {
yield put(actions.router.push('/home'))
}
yield call(subscribeToUnifiedBalances)
yield call(fetchBalances)
yield call(saveGoals, firstLogin)
// We run goals in accountResetSaga in this case
Expand All @@ -400,7 +444,8 @@ export default ({ api, coreSagas, networks }) => {
yield call(upgradeAddressLabelsSaga)
yield put(actions.auth.startLogoutTimer())
yield call(startCoinWebsockets)

// TODO: temp, do we want this here?
yield put(actions.activities.startSocket())
// store guid and email in cache for future login
yield put(actions.cache.guidEntered(guid))
if (email) {
Expand Down Expand Up @@ -521,6 +566,7 @@ export default ({ api, coreSagas, networks }) => {
session,
sharedKey
})

// Check which unification flow we're running
// to determine what we want to do after authing user
const magicLinkData: AuthMagicLink = yield select(S.getMagicLinkData)
Expand Down Expand Up @@ -548,6 +594,7 @@ export default ({ api, coreSagas, networks }) => {
yield call(loginRoutineSaga, {})
break
}

yield put(
actions.analytics.trackEvent({
key: Analytics.LOGIN_SIGNED_IN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pathOr } from 'ramda'
import { fork, join, put, select, take } from 'redux-saga/effects'
import { put, select, take } from 'redux-saga/effects'

import { Remote } from '@core'
import { actions, actionTypes, selectors } from 'data'
Expand All @@ -10,49 +10,10 @@ export const balancePath = ['payload', 'info', 'final_balance']
export const fetchBalances = function* () {
yield put(actions.core.data.bch.fetchData())
yield put(actions.core.data.btc.fetchData())
yield put(actions.core.data.xlm.fetchData())
yield put(actions.core.data.eth.fetchData())
yield put(actions.core.data.eth.fetchErc20Data())
yield put(actions.core.data.coins.fetchUnifiedBalances())
yield put(actions.components.refresh.refreshRates())
yield put(actions.custodial.fetchRecentSwapTxs())
yield put(actions.core.data.coins.fetchData())
}

export const getEthBalance = function* () {
try {
const ethBalanceR = yield select(selectors.core.data.eth.getBalance)
if (!Remote.Success.is(ethBalanceR)) {
const ethData = yield take([
actionTypes.core.data.eth.FETCH_ETH_DATA_SUCCESS,
actionTypes.core.data.eth.FETCH_ETH_DATA_FAILURE
])
return pathOr(0, balancePath, ethData)
}
return ethBalanceR.getOrElse(0)
} catch (e) {
yield put(actions.logs.logErrorMessage(logLocation, 'getEthBalance', e))
}
}

export const getErc20Balance = function* (token) {
try {
const erc20BalanceR = yield select(selectors.core.data.eth.getErc20Balance, token)
if (!Remote.Success.is(erc20BalanceR)) {
yield put(actions.core.data.eth.fetchErc20Data(token))
const erc20Data = yield take([
(action) =>
action.type === actionTypes.core.data.eth.FETCH_ERC20_TOKEN_DATA_SUCCESS &&
action.payload.token === token,
(action) =>
action.type === actionTypes.core.data.eth.FETCH_ERC20_TOKEN_DATA_FAILURE &&
action.payload.token === token
])
return pathOr(0, balancePath, erc20Data)
}
return erc20BalanceR.getOrElse(0)
} catch (e) {
yield put(actions.logs.logErrorMessage(logLocation, 'getErc20Balance', e))
}
}

export const getBtcBalance = function* () {
Expand Down Expand Up @@ -86,29 +47,3 @@ export const getBchBalance = function* () {
yield put(actions.logs.logErrorMessage(logLocation, 'getBchBalance', e))
}
}

export const getXlmBalance = function* () {
try {
const xlmBalanceR = yield select(selectors.core.data.xlm.getTotalBalance)
if (!Remote.Success.is(xlmBalanceR)) {
const xlmData = yield take(actionTypes.core.data.xlm.FETCH_DATA_SUCCESS)
return pathOr(0, balancePath, xlmData)
}
return xlmBalanceR.getOrElse(0)
} catch (e) {
yield put(actions.logs.logErrorMessage(logLocation, 'getXlmBalance', e))
}
}

export const waitForAllBalances = function* () {
const btcT = yield fork(getBtcBalance)
const bchT = yield fork(getBchBalance)
const ethT = yield fork(getEthBalance)
const xlmT = yield fork(getXlmBalance)
const btc = yield join(btcT)
const bch = yield join(bchT)
const eth = yield join(ethT)
const xlm = yield join(xlmT)

return { bch, btc, eth, xlm }
}
Loading