Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3925a3b

Browse files
fixup! Fix @typescript-eslint/no-misused-promises
1 parent 4c7e763 commit 3925a3b

File tree

5 files changed

+37
-55
lines changed

5 files changed

+37
-55
lines changed

‎src/components/cards/EarnOptionCard.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface Props {
2222
/** If false, show "Stake"/"Earn"
2323
* If true, show "Staked"/"Earned" */
2424
isOpenPosition?: boolean
25-
onPress?: () => void
25+
onPress?: () => Promise<void>
2626
}
2727

2828
export function EarnOptionCard(props: Props) {

‎src/components/modals/TransferModal.tsx‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,11 @@ export const TransferModal = ({
9090
showCreateWallet
9191
/>
9292
))
93-
.then(result => {
93+
.then(asyncresult => {
9494
if (result?.type === 'wallet') {
9595
const { walletId, tokenId } = result
96-
dispatch(selectWalletToken({ navigation, walletId, tokenId }))
97-
.then(() => {
98-
navigation.navigate('request', { tokenId, walletId })
99-
})
100-
.catch((error: unknown) => {
101-
showError(error)
102-
})
96+
await dispatch(selectWalletToken({ navigation, walletId, tokenId }))
97+
navigation.navigate('request', { tokenId, walletId })
10398
}
10499
})
105100
.catch((error: unknown) => {

‎src/components/scenes/Staking/EarnScene.tsx‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ import {
3535
WalletListModal,
3636
type WalletListResult
3737
} from '../../modals/WalletListModal'
38-
import {
39-
Airship,
40-
showDevError,
41-
showError
42-
} from '../../services/AirshipInstance'
38+
import { Airship, showDevError } from '../../services/AirshipInstance'
4339
import { cacheStyles, type Theme, useTheme } from '../../services/ThemeContext'
4440
import { SearchFooter } from '../../themed/SearchFooter'
4541

@@ -366,11 +362,7 @@ export const EarnScene = (props: Props) => {
366362
currencyConfig={currencyConfigMap}
367363
stakePolicy={stakePolicy}
368364
isOpenPosition={false}
369-
onPress={() => {
370-
handlePress().catch((error: unknown) => {
371-
showError(error)
372-
})
373-
}}
365+
onPress={handlePress}
374366
/>
375367
</EdgeAnim>
376368
)
@@ -447,11 +439,7 @@ export const EarnScene = (props: Props) => {
447439
currencyConfig={currencyConfigMap}
448440
stakePolicy={stakePolicy}
449441
isOpenPosition
450-
onPress={() => {
451-
handlePress().catch((error: unknown) => {
452-
showError(error)
453-
})
454-
}}
442+
onPress={handlePress}
455443
/>
456444
</EdgeAnim>
457445
)

‎src/components/scenes/TransactionsExportScene.tsx‎

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -164,32 +164,29 @@ class TransactionsExportSceneComponent extends React.PureComponent<
164164
})
165165
}
166166

167-
componentDidMount(): void {
167+
loadInfoFile=async()=> {
168168
const { sourceWallet, tokenId } = this.props.route.params
169169
const { disklet } = sourceWallet
170-
disklet
171-
.getText(EXPORT_TX_INFO_FILE)
172-
.then(result => {
173-
const exportTxInfoMap = asExportTxInfoMap(JSON.parse(result))
174-
const tokenCurrencyCode =
175-
tokenId ?? sourceWallet.currencyInfo.currencyCode
176-
177-
const { isExportBitwave, isExportCsv, isExportQbo } =
178-
exportTxInfoMap[tokenCurrencyCode]
179-
180-
this.setState({
181-
isExportBitwave,
182-
isExportCsv,
183-
isExportQbo
184-
})
185-
})
186-
.catch((error: unknown) => {
187-
console.log(
188-
`Could not read ${EXPORT_TX_INFO_FILE} ${String(
189-
error
190-
)}. Failure is ok`
191-
)
192-
})
170+
const result = await disklet.getText(EXPORT_TX_INFO_FILE)
171+
const exportTxInfoMap = asExportTxInfoMap(JSON.parse(result))
172+
const tokenCurrencyCode = tokenId ?? sourceWallet.currencyInfo.currencyCode
173+
174+
const { isExportBitwave, isExportCsv, isExportQbo } =
175+
exportTxInfoMap[tokenCurrencyCode]
176+
177+
this.setState({
178+
isExportBitwave,
179+
isExportCsv,
180+
isExportQbo
181+
})
182+
}
183+
184+
componentDidMount(): void {
185+
this.loadInfoFile().catch((e: unknown) => {
186+
console.log(
187+
`Could not read ${EXPORT_TX_INFO_FILE} ${String(e)}. Failure is ok`
188+
)
189+
})
193190
}
194191

195192
render() {

‎src/plugins/gui/providers/banxaProvider.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { StringMap } from '../../../types/types'
2020
import { CryptoAmount } from '../../../util/CryptoAmount'
2121
import { getCurrencyCodeMultiplier } from '../../../util/CurrencyInfoHelpers'
2222
import { fetchInfo } from '../../../util/network'
23+
import { makePeriodicTask } from '../../../util/PeriodicTask'
2324
import { consify, removeIsoPrefix } from '../../../util/utils'
2425
import { SendErrorBackPressed, SendErrorNoTransaction } from '../fiatPlugin'
2526
import type { FiatDirection, FiatPaymentType } from '../fiatPluginTypes'
@@ -757,7 +758,7 @@ export const banxaProvider: FiatProviderFactory = {
757758
throw new Error(banxaQuote.errors.title)
758759
}
759760

760-
let interval: ReturnType<typeof setInterval> | undefined
761+
let interval: ReturnType<typeof makePeriodicTask> | undefined
761762
let insideInterval = false
762763

763764
if (direction === 'buy') {
@@ -845,18 +846,18 @@ export const banxaProvider: FiatProviderFactory = {
845846
): Promise<void> => {
846847
console.log(`onUrlChange url=${changeUrl}`)
847848
if (changeUrl === RETURN_URL_SUCCESS) {
848-
clearInterval(interval)
849+
interval?.stop()
849850

850851
await showUi.exitScene()
851852
} else if (changeUrl === RETURN_URL_CANCEL) {
852-
clearInterval(interval)
853+
interval?.stop()
853854
await showUi.showToast(
854855
lstrings.fiat_plugin_sell_cancelled,
855856
NOT_SUCCESS_TOAST_HIDE_MS
856857
)
857858
await showUi.exitScene()
858859
} else if (changeUrl === RETURN_URL_FAIL) {
859-
clearInterval(interval)
860+
interval?.stop()
860861
await showUi.showToast(
861862
lstrings.fiat_plugin_sell_failed_try_again,
862863
NOT_SUCCESS_TOAST_HIDE_MS
@@ -913,7 +914,7 @@ export const banxaProvider: FiatProviderFactory = {
913914
const edgeTx = await showUi.send(sendParams)
914915

915916
// At this point we'll call it success
916-
clearInterval(interval)
917+
interval?.stop()
917918
interval = undefined
918919

919920
await showUi.trackConversion('Sell_Success', {
@@ -971,17 +972,18 @@ export const banxaProvider: FiatProviderFactory = {
971972
insideInterval = false
972973
}
973974
}
974-
interval ??= setInterval(() => {
975+
interval ??= makePeriodicTask(() => {
975976
statusUpdateAsync().catch((error: unknown) => {
976977
showError(error)
977978
})
978979
}, 3000)
980+
interval.start({ wait: true })
979981
}
980982
}
981983
await showUi.openWebView({
982984
url: checkoutUrl,
983985
onClose: () => {
984-
clearInterval(interval)
986+
interval?.stop()
985987
},
986988
onUrlChange: (changeUrl: string) => {
987989
onUrlChangeAsync(changeUrl).catch((error: unknown) => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /