Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanups for new core #4653

Merged
merged 7 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/__tests__/reducers/__snapshots__/RootReducer.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ exports[`initialState 1`] = `
"multiplier": "1",
"name": "",
},
"tokenId": undefined,
"walletId": "",
},
"genericShapeShiftError": null,
Expand All @@ -69,6 +70,7 @@ exports[`initialState 1`] = `
"multiplier": "1",
"name": "",
},
"tokenId": undefined,
"walletId": "",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports[`initialState 1`] = `
"multiplier": "1",
"name": "",
},
"tokenId": undefined,
"walletId": "",
},
"genericShapeShiftError": null,
Expand All @@ -39,6 +40,7 @@ exports[`initialState 1`] = `
"multiplier": "1",
"name": "",
},
"tokenId": undefined,
"walletId": "",
},
}
Expand Down
4 changes: 0 additions & 4 deletions src/__tests__/scenes/CryptoExchangeScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ describe('CryptoExchangeComponent', () => {
exchangeInfo={initialState}
fromWalletId=""
fromWalletBalances={[''] as any}
fromFiatCurrencyCode="USD"
fromIsoFiatCurrencyCode="iso:USD"
fromWalletName="BTC Wallet"
fromExchangeAmount="1000"
fromWalletPrimaryInfo={
Expand All @@ -32,8 +30,6 @@ describe('CryptoExchangeComponent', () => {
} as any
}
toWalletId=""
toFiatCurrencyCode="USD"
toIsoFiatCurrencyCode="iso:USD"
toWalletName="ETH Wallet"
toExchangeAmount="1000"
toWalletPrimaryInfo={
Expand Down
2 changes: 0 additions & 2 deletions src/__tests__/scenes/RequestScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('Request', () => {
wallet={null as any}
exchangeSecondaryToPrimaryRatio={null as any}
primaryCurrencyInfo={null as any}
secondaryCurrencyInfo={null as any}
theme={getTheme()}
refreshAllFioAddresses={async () => {}}
onSelectWallet={async (walletId, currencyCode) => {}}
Expand Down Expand Up @@ -48,7 +47,6 @@ describe('Request', () => {
wallet={fakeWallet}
exchangeSecondaryToPrimaryRatio={{} as any}
primaryCurrencyInfo={{ displayDenomination: { multiplier: '100000000' }, exchangeDenomination: { multiplier: '100000000' } } as any}
secondaryCurrencyInfo={{} as any}
theme={getTheme()}
refreshAllFioAddresses={async () => {}}
onSelectWallet={async (walletId, currencyCode) => {}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,6 @@ exports[`CryptoExchangeComponent should render with loading props 1`] = `
"exchangeCurrencyCode": "BTC",
}
}
secondaryCurrencyInfo={
{
"displayCurrencyCode": "USD",
"displayDenomination": {
"multiplier": "100",
"name": "USD",
"symbol": "$",
},
"exchangeCurrencyCode": "iso:USD",
"exchangeDenomination": {
"multiplier": "100",
"name": "USD",
"symbol": "$",
},
"walletId": "",
}
}
walletId=""
>
<MiniButton
Expand Down Expand Up @@ -110,23 +93,6 @@ exports[`CryptoExchangeComponent should render with loading props 1`] = `
},
}
}
secondaryCurrencyInfo={
{
"displayCurrencyCode": "USD",
"displayDenomination": {
"multiplier": "100",
"name": "USD",
"symbol": "$",
},
"exchangeCurrencyCode": "iso:USD",
"exchangeDenomination": {
"multiplier": "100",
"name": "USD",
"symbol": "$",
},
"walletId": "",
}
}
walletId=""
/>
</KeyboardAwareScrollView>
Expand Down
11 changes: 6 additions & 5 deletions src/actions/CryptoExchangeActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { getDisplayDenomination, getExchangeDenomination } from '../selectors/De
import { convertCurrency } from '../selectors/WalletSelectors'
import { RootState, ThunkAction } from '../types/reduxTypes'
import { NavigationBase } from '../types/routerTypes'
import { GuiCurrencyInfo, GuiDenomination, GuiSwapInfo } from '../types/types'
import { GuiCurrencyInfo, GuiSwapInfo } from '../types/types'
import { getTokenId } from '../util/CurrencyInfoHelpers'
import { getWalletName } from '../util/CurrencyWalletHelpers'
import { logActivity } from '../util/logger'
import { bestOfPlugins } from '../util/ReferralHelpers'
Expand Down Expand Up @@ -365,14 +366,14 @@ export function selectWalletForExchange(walletId: string, currencyCode: string,
return async (dispatch, getState) => {
const state = getState()
const wallet = state.core.account.currencyWallets[walletId]
const { currencyCode: chainCc, pluginId } = wallet.currencyInfo
const { currencyCode: chainCc } = wallet.currencyInfo
const cc = currencyCode || chainCc
const balanceMessage = await getBalanceMessage(state, walletId, cc)
const primaryDisplayDenomination: GuiDenomination = getDisplayDenomination(state, wallet.currencyInfo.pluginId, cc)
const primaryExchangeDenomination: GuiDenomination = getExchangeDenomination(state, wallet.currencyInfo.pluginId, cc)
const primaryDisplayDenomination = getDisplayDenomination(state, wallet.currencyInfo.pluginId, cc)
const primaryExchangeDenomination = getExchangeDenomination(state, wallet.currencyInfo.pluginId, cc)
const primaryInfo: GuiCurrencyInfo = {
walletId,
pluginId,
tokenId: getTokenId(state.core.account, wallet.currencyInfo.pluginId, cc),
displayCurrencyCode: cc,
exchangeCurrencyCode: cc,
displayDenomination: primaryDisplayDenomination,
Expand Down
4 changes: 2 additions & 2 deletions src/actions/DeepLinkingActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export async function handleLink(navigation: NavigationBase, dispatch: Dispatch,
case 'azteco': {
if (!allWalletsLoaded) return false
const result = await pickWallet({ account, assets: [{ pluginId: 'bitcoin' }], navigation, showCreateWallet: true })
if (result == null) {
if (result?.type !== 'wallet') {
// pickWallet returning undefined means user has no matching wallet.
// This should never happen. Even if the user doesn't have a bitcoin wallet, they will be presented with
// the option to create one.
Expand Down Expand Up @@ -235,7 +235,7 @@ export async function handleLink(navigation: NavigationBase, dispatch: Dispatch,
}

// User backed out of choosing a wallet
if (walletListResult.walletId == null) return true
if (walletListResult.type !== 'wallet') return true
const widUri = matchingWalletIdsAndUris.find(({ walletId }) => walletId === walletListResult.walletId)

if (widUri == null) {
Expand Down
9 changes: 4 additions & 5 deletions src/actions/PaymentProtoActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,13 @@ export async function launchPaymentProto(navigation: NavigationBase, account: Ed
selectedWallet = wallet
selectedCurrencyCode = currencyCode
} else {
const walletListResult = await pickWallet({ account, assets: paymentAssets, navigation })
if (walletListResult == null) {
const result = await pickWallet({ account, assets: paymentAssets, navigation })
if (result?.type !== 'wallet') {
throw new PaymentProtoError('NoPaymentOption', { text: paymentCurrencies.join(', ') })
}

const { walletId } = walletListResult
const { walletId, currencyCode } = result
selectedWallet = currencyWallets[walletId ?? '']
selectedCurrencyCode = walletListResult.currencyCode
selectedCurrencyCode = currencyCode
}
if (selectedWallet == null) return

Expand Down
5 changes: 3 additions & 2 deletions src/actions/ScanActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ export const doRequestAddress = async (navigation: NavigationBase, account: Edge

await Airship.show<WalletListResult>(bridge => (
<WalletListModal bridge={bridge} navigation={navigation} headerTitle={lstrings.select_wallet} allowedAssets={tokenId} showCreateWallet />
)).then(async ({ walletId, currencyCode }) => {
if (walletId != null && currencyCode != null) {
)).then(async result => {
if (result?.type === 'wallet') {
const { walletId, currencyCode } = result
const { currencyWallets } = account
const wallet = currencyWallets[walletId]

Expand Down
5 changes: 3 additions & 2 deletions src/components/FioAddress/FioActionSubmit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ class FioActionSubmitComponent extends React.Component<Props, State> {
Airship.show<WalletListResult>(bridge => (
<WalletListModal bridge={bridge} navigation={this.props.navigation} headerTitle={lstrings.fio_src_wallet} allowedAssets={[{ pluginId: 'fio' }]} />
))
.then(({ walletId, currencyCode }: WalletListResult) => {
if (walletId && currencyCode) {
.then(result => {
if (result?.type === 'wallet') {
const { walletId } = result
this.props.currencyWallets[walletId] &&
this.setState({ paymentWallet: this.props.currencyWallets[walletId] }, () => {
this.setBalance()
Expand Down
77 changes: 0 additions & 77 deletions src/components/common/ExchangeRate.tsx

This file was deleted.

10 changes: 6 additions & 4 deletions src/components/modals/TransferModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,24 @@ export const TransferModal = ({ account, bridge, depositOrSend, navigation }: Pr
Airship.clear()
})
const handleSend = useHandler(async () => {
const { walletId, tokenId } = await Airship.show<WalletListResult>(bridge => (
const result = await Airship.show<WalletListResult>(bridge => (
<WalletListModal bridge={bridge} headerTitle={lstrings.select_wallet_to_send_from} navigation={navigation} />
))
if (walletId != null) {
if (result?.type === 'wallet') {
const { walletId, tokenId } = result
navigation.push('send2', { walletId, tokenId, hiddenFeaturesMap: { scamWarning: false } })
}
Airship.clear()
})

const handleReceive = useHandler(async () => {
Airship.clear()
const { walletId, tokenId } = await Airship.show<WalletListResult>(bridge => (
const result = await Airship.show<WalletListResult>(bridge => (
<WalletListModal bridge={bridge} headerTitle={lstrings.select_receive_asset} navigation={navigation} showCreateWallet />
))

if (walletId != null) {
if (result?.type === 'wallet') {
const { walletId, tokenId } = result
await dispatch(selectWalletToken({ navigation, walletId, tokenId }))
navigation.navigate('request', {})
}
Expand Down
Loading
Loading