Skip to content

Commit

Permalink
feat(dynamic custodial): drive custodial coins completely off currenc…
Browse files Browse the repository at this point in the history
…ies/custodial
  • Loading branch information
plondon committed Jul 28, 2021
1 parent 4fdbd93 commit 3883830
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 392 deletions.
88 changes: 0 additions & 88 deletions config/mocks/wallet-options-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,94 +218,6 @@
"learnMoreLink": "https://support.blockchain.com/hc/en-us/articles/360019105171-What-is-Stellar-",
"minConfirmations": 1,
"txExplorerBaseUrl": "https://stellarchain.io/tx"
},
"ALGO": {
"coinCode": "ALGO",
"coinTicker": "ALGO",
"coinfig": {
"name": "Algorand",
"precision": 6,
"products": ["CustodialWalletBalance"],
"symbol": "ALGO",
"type": {
"logoPngUrl": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/blockchains/algorand/info/logo.png",
"minimumOnChainConfirmations": 3,
"name": "Algorand",
"parentChain": "ALGO",
"websiteUrl": ""
}
},
"displayName": "Algorand",
"hasLockboxSupport": false,
"learnMoreLink": "",
"minConfirmations": 3,
"txExplorerBaseUrl": ""
},
"CLOUT": {
"coinCode": "CLOUT",
"coinTicker": "CLOUT",
"coinfig": {
"name": "BitClout",
"precision": 9,
"products": ["CustodialWalletBalance"],
"symbol": "CLOUT",
"type": {
"logoPngUrl": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/blockchains/bitclout/info/logo.png",
"minimumOnChainConfirmations": 4,
"name": "BitClout",
"parentChain": "CLOUT",
"websiteUrl": ""
}
},
"displayName": "BitClout",
"hasLockboxSupport": false,
"learnMoreLink": "",
"minConfirmations": 4,
"txExplorerBaseUrl": "https://bitclout.com"
},
"DOT": {
"coinCode": "DOT",
"coinTicker": "DOT",
"coinfig": {
"name": "Polkadot",
"precision": 10,
"products": ["CustodialWalletBalance"],
"symbol": "DOT",
"type": {
"logoPngUrl": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/blockchains/polkadot/info/logo.png",
"minimumOnChainConfirmations": 20,
"name": "Polkadot",
"parentChain": "DOT",
"websiteUrl": ""
}
},
"displayName": "Polkadot",
"hasLockboxSupport": false,
"learnMoreLink": "https://support.blockchain.com/hc/en-us/articles/360044952032",
"minConfirmations": 20,
"txExplorerBaseUrl": "https://polkascan.io/polkadot"
},
"DOGE": {
"coinCode": "DOGE",
"coinTicker": "DOGE",
"coinfig": {
"name": "DogeCoin",
"precision": 8,
"products": ["CustodialWalletBalance"],
"symbol": "DOGE",
"type": {
"logoPngUrl": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/blockchains/doge/info/logo.png",
"minimumOnChainConfirmations": 40,
"name": "DogeCoin",
"parentChain": "DOGE",
"websiteUrl": ""
}
},
"displayName": "DogeCoin",
"hasLockboxSupport": false,
"learnMoreLink": "",
"minConfirmations": 40,
"txExplorerBaseUrl": "https://dogechain.info/"
}
},
"erc20s": ["AAVE", "PAX", "USDC", "USDT", "WDGLD", "YFI"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@
"buttons.withdraw_value": "Withdraw {value}",
"buttons.withdrew": "Withdrew",
"coins.aave.intro": "Aave is a decentralized finance protocol that allows people to lend and borrow crypto.",
"coins.algo.intro": "Algorand (ALGO) is a public blockchain based on a pure proof-of-stake consensus protocol.",
"coins.bch.intro": "Bitcoin Cash (BCH) is a fork of Bitcoin built for everyday transactions.",
"coins.btc.intro": "Bitcoin (BTC) is the original crypto and the internet’s premier digital currency.",
"coins.clout.intro": "BitClout (CLOUT) is a decentralized, blockchain-based, open source social network.",
"coins.doge.intro": "Dogecoin (DOGE) was created in 2013 as an alternative to traditional cryptocurrencies like Bitcoin.",
"coins.dot.intro": "Polkadot (DOT) is a cross-chain data transfer protocol that allows independent blockchains to trustlessly share information with each other.",
"coins.eth.intro": "Ethereum (ETH) is a currency and platform for execution of decentralized smart contracts.",
"coins.eur.intro": "Store Euros in your wallet and use it to Buy crypto.",
"coins.gbp.intro": "Store British pounds in your wallet and use it to Buy crypto.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CoinAccountSelectorType } from 'data/coins/types'
// used in transaction list dropdown
export const ALL_ACCOUNTS_SELECTOR: CoinAccountSelectorType = {
importedAddresses: true,
tradingAccounts: true,
interestAccounts: true,
nonCustodialAccounts: true
nonCustodialAccounts: true,
tradingAccounts: true
}
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { CoinType, PaymentType, PaymentValue, RemoteDataType } from 'blockchain-wallet-v4/src/types'

// import * as ALGO from './coins/algo'
import * as BCH from './coins/bch'
import * as BTC from './coins/btc'
// import * as DOT from './coins/dot'
import * as ERC20 from './coins/erc20'
import * as ETH from './coins/eth'
// import * as EUR from './coins/eur'
Expand All @@ -13,7 +11,6 @@ import * as XLM from './coins/xlm'

// create a function map of all coins
const coinSagas = {
// ALGO,
BCH,
BTC,
ERC20,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { lift } from 'ramda'

import { SBBalanceType } from 'blockchain-wallet-v4/src/network/api/simpleBuy/types'
Expand All @@ -12,14 +10,9 @@ import { SwapAccountType } from 'data/components/types'
import { getTradingBalance } from '..'

// retrieves introduction text for coin on its transaction page
export const getTransactionPageHeaderText = () => (
<FormattedMessage
id='coins.clout.intro'
defaultMessage='BitClout (CLOUT) is a decentralized, blockchain-based, open source social network.'
/>
)
export const getTransactionPageHeaderText = () => null

// main selector for all CLOUT account types
// main selector for all CUSTODIAL account types
// accepts a CoinAccountSelectorType config object
// NOT IMPLEMENTED FOR COIN: non-custodial accounts, imported addresses/accounts
export const getAccounts = createDeepEqualSelector(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { any, isEmpty, isNil, map, values } from 'ramda'

import { Remote } from 'blockchain-wallet-v4/src'
import { CoinType, RemoteDataType } from 'blockchain-wallet-v4/src/types'
import { CoinfigType, CoinType, RemoteDataType } from 'blockchain-wallet-v4/src/types'
import { selectors } from 'data'
import { CoinAccountSelectorType } from 'data/coins/types'
import { SwapAccountType } from 'data/components/swap/types'
import { RootState } from 'data/rootReducer'

import * as ALGO from './coins/algo'
import * as BCH from './coins/bch'
import * as BTC from './coins/btc'
import * as CLOUT from './coins/clout'
import * as DOGE from './coins/doge'
import * as DOT from './coins/dot'
import * as CUSTODIAL from './coins/custodial'
import * as ERC20 from './coins/erc20'
import * as ETH from './coins/eth'
import * as EUR from './coins/eur'
Expand All @@ -22,12 +19,9 @@ import * as XLM from './coins/xlm'

// create a function map of all coins
const coinSelectors = {
ALGO,
BCH,
BTC,
CLOUT,
DOGE,
DOT,
CUSTODIAL,
ERC20,
ETH,
EUR,
Expand All @@ -36,12 +30,21 @@ const coinSelectors = {
XLM
}

export const getSelector = (coinfig: CoinfigType) => {
if (coinfig.type.erc20Address) {
return 'ERC20'
}
if (selectors.core.data.coins.getCoins().includes(coinfig.symbol)) {
return 'CUSTODIAL'
}
return coinfig.symbol
}

// retrieves introduction text for coin on its transaction page
export const getIntroductionText = (coin: string) => {
const { coinfig } = window.coins[coin]
return coinSelectors[
coinfig.type.erc20Address ? 'ERC20' : coinfig.symbol
]?.getTransactionPageHeaderText(coinfig.symbol)
const selector = getSelector(coinfig)
return coinSelectors[selector]?.getTransactionPageHeaderText(coinfig.symbol)
}

// retrieves custodial account balances
Expand All @@ -66,10 +69,9 @@ export const getCoinAccounts = (state: RootState, ownProps: CoinAccountSelectorT
? Remote.of({})
: coinList.reduce((accounts, coin) => {
const { coinfig } = window.coins[coin]
const selector = getSelector(coinfig)
// eslint-disable-next-line
accounts[coin] = coinSelectors[
coinfig.type.erc20Address ? 'ERC20' : coin
]?.getAccounts(state, { coin, ...ownProps })
accounts[coin] = coinSelectors[selector]?.getAccounts(state, { coin, ...ownProps })
return accounts
}, {})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const getCoinsWithMethodAndOrder = (state: RootState) => {
const sbBalancesR = selectors.components.simpleBuy.getSBBalances(state)
const erc20sR = selectors.core.data.eth.getErc20AccountTokenBalances(state)
const recentSwapTxs = selectors.custodial.getRecentSwapTxs(state).getOrElse([] as SwapOrderType[])
const custodials = selectors.core.data.coins.getCoins()

const transform = (
paymentMethods: ExtractSuccess<typeof sbMethodsR>,
Expand All @@ -39,10 +40,7 @@ export const getCoinsWithMethodAndOrder = (state: RootState) => {
'ETH',
'BCH',
'XLM',
'ALGO',
'DOT',
'CLOUT',
'DOGE',
...custodials,
// ...coins.rest // erc20s
// TODO: erc20 phase 2, key off hash not symbol
...erc20s.map(({ tokenSymbol }) => toUpper(tokenSymbol)),
Expand Down

0 comments on commit 3883830

Please sign in to comment.