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

Comment out new ScamWarning #5042

Merged
merged 1 commit into from
May 30, 2024
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
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

- added: Add Visa/MC buy support with Paybis
- added: Support for `promoId`-based filtering for Promo Cards
- added: Scam warning to the first login after app install, first view of private keys, and first use of WalletConnect
- added: New Asset Setting to manually enable tokens with detected balances across all wallets
- added: MUTE_CONSOLE_OUTPUT environment variable to disable specific console output functions
- added: Performance logging with app start-up time and login time as initial performance metrics
Expand Down
79 changes: 37 additions & 42 deletions src/actions/ScamWarningActions.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { asBoolean, asObject, asOptional } from 'cleaners'
import { Disklet, makeReactNativeDisklet } from 'disklet'
import { Disklet } from 'disklet'
import * as React from 'react'
import { AirshipBridge } from 'react-native-airship'
import { sprintf } from 'sprintf-js'

import { ConfirmContinueModal } from '../components/modals/ConfirmContinueModal'
import { ScamWarningModal } from '../components/modals/ScamWarningModal'
import { Airship } from '../components/services/AirshipInstance'
import { Paragraph, WarningText } from '../components/themed/EdgeText'
import { SCAM_WARNING, SCAM_WARNING_2 } from '../constants/constantSettings'
import { SCAM_WARNING } from '../constants/constantSettings'
import { lstrings } from '../locales/strings'
import { config } from '../theme/appConfig'
import { getFirstOpenInfo } from './FirstOpenActions'

let isSendScamWarningChecked = false

Expand Down Expand Up @@ -42,37 +39,37 @@ export const showSendScamWarningModal = async (disklet: Disklet) => {
}
}

const scamWarningDisklet = makeReactNativeDisklet()
// const scamWarningDisklet = makeReactNativeDisklet()
const asScamWarningInfo = asObject({
firstPrivateKeyView: asOptional(asBoolean, true),
firstWalletConnect: asOptional(asBoolean, true),
firstLogin: asOptional(asBoolean, true)
})
type ScamWarningInfo = ReturnType<typeof asScamWarningInfo>
let scamWarningInfo: ScamWarningInfo
// let scamWarningInfo: ScamWarningInfo

const getScamWarningInfo = async (): Promise<ScamWarningInfo> => {
if (scamWarningInfo == null) {
try {
const scamWarningText = await scamWarningDisklet.getText(SCAM_WARNING_2)
scamWarningInfo = asScamWarningInfo(JSON.parse(scamWarningText))
} catch (error: any) {
if ((await getFirstOpenInfo()).isFirstOpen === 'false') {
// If this isn't the first open, don't pester the user with new scam
// warnings. Assume this isn't their first rodeo across the board.
scamWarningInfo = {
firstPrivateKeyView: false,
firstWalletConnect: false,
firstLogin: false
}
} else {
scamWarningInfo = asScamWarningInfo({})
}
await scamWarningDisklet.setText(SCAM_WARNING_2, JSON.stringify(scamWarningInfo))
}
}
return scamWarningInfo
}
// const getScamWarningInfo = async (): Promise<ScamWarningInfo> => {
// if (scamWarningInfo == null) {
// try {
// const scamWarningText = await scamWarningDisklet.getText(SCAM_WARNING_2)
// scamWarningInfo = asScamWarningInfo(JSON.parse(scamWarningText))
// } catch (error: any) {
// if ((await getFirstOpenInfo()).isFirstOpen === 'false') {
// // If this isn't the first open, don't pester the user with new scam
// // warnings. Assume this isn't their first rodeo across the board.
// scamWarningInfo = {
// firstPrivateKeyView: false,
// firstWalletConnect: false,
// firstLogin: false
// }
// } else {
// scamWarningInfo = asScamWarningInfo({})
// }
// await scamWarningDisklet.setText(SCAM_WARNING_2, JSON.stringify(scamWarningInfo))
// }
// }
// return scamWarningInfo
// }

/**
* Warning the user about bad actors that are walking the user through
Expand All @@ -83,17 +80,15 @@ const getScamWarningInfo = async (): Promise<ScamWarningInfo> => {
* dangerous action.
**/
export const showScamWarningModal = async (scamWarningInfoKey: keyof ScamWarningInfo) => {
const scamWarningInfo = await getScamWarningInfo()

// Ignore if we've already triggered a particular warning
if (scamWarningInfo[scamWarningInfoKey]) {
// Make sure we don't show this warning again for this particular scenario
scamWarningInfo[scamWarningInfoKey] = false
await scamWarningDisklet.setText(SCAM_WARNING_2, JSON.stringify(scamWarningInfo))

// Show the scam warning modal
await Airship.show((bridge: AirshipBridge<'yes' | 'no' | undefined>) => {
return <ScamWarningModal bridge={bridge} />
})
}
// const scamWarningInfo = await getScamWarningInfo()
// // Ignore if we've already triggered a particular warning
// if (scamWarningInfo[scamWarningInfoKey]) {
// // Make sure we don't show this warning again for this particular scenario
// scamWarningInfo[scamWarningInfoKey] = false
// await scamWarningDisklet.setText(SCAM_WARNING_2, JSON.stringify(scamWarningInfo))
// // Show the scam warning modal
// await Airship.show((bridge: AirshipBridge<'yes' | 'no' | undefined>) => {
// return <ScamWarningModal bridge={bridge} />
// })
// }
}
Loading