Skip to content

Commit

Permalink
Fixes #170
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Sep 10, 2023
1 parent 91fd8ef commit 82cc824
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/context/FocusClaim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { getMintsUrls } from '@db'
import { l } from '@log'
import type { ITokenInfo } from '@model'
import { NS } from '@src/i18n'
import { store } from '@store'
import { STORE_KEYS } from '@store/consts'
import { addToHistory } from '@store/latestHistoryEntries'
import { formatInt, formatMintUrl, getStrFromClipboard, hasTrustedMint, isCashuToken, isErr, sleep } from '@util'
import { claimToken, isTokenSpendable } from '@wallet'
Expand All @@ -29,8 +31,10 @@ const useFocusClaim = () => {
// in an empty string returned. Find a better way than the following function to handle it.
let isSpent = false
const fn = async () => {
const selfCreated = await store.get(STORE_KEYS.createdToken)
const clipboard = await getStrFromClipboard()
if (!clipboard?.length || !isCashuToken(clipboard)) { return false }
if (selfCreated === clipboard) { return false }
const info = getTokenInfo(clipboard)
if (!info) { return false }
// check if mint is a trusted one
Expand Down
8 changes: 7 additions & 1 deletion src/screens/Payment/Send/EncodedToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import TopNav from '@nav/TopNav'
import { isIOS } from '@src/consts'
import { useThemeContext } from '@src/context/Theme'
import { NS } from '@src/i18n'
import { store } from '@store'
import { STORE_KEYS } from '@store/consts'
import { globals, highlight as hi, mainColors } from '@styles'
import { share, vib } from '@util'
import { useEffect, useState } from 'react'
Expand All @@ -23,7 +25,11 @@ export default function EncodedTokenPage({ navigation, route }: TEncodedTokenPag
const { copied, copy } = useCopy()
const [error, setError] = useState({ msg: '', open: false })

useEffect(() => vib(400), [])
useEffect(() => {
// we can save the created token here to avoid foreground prompts of self-created tokens
void store.set(STORE_KEYS.createdToken, route.params.token)
vib(400)
}, [route.params.token])

return (
<View style={[globals(color).container, styles.container, { paddingBottom: isIOS ? 50 : 20 }]}>
Expand Down
3 changes: 2 additions & 1 deletion src/storage/store/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const STORE_KEYS = {
defaultMint: 'MINT_STORE=|:|=default_mint',
hiddenBal: 'privacy_balance',
hiddenTxs: 'privacy_txs',
latestHistory: 'history_latest'
latestHistory: 'history_latest',
createdToken: 'createdToken',
}

export const SECURESTORE_KEY = 'auth_pin'
Expand Down

0 comments on commit 82cc824

Please sign in to comment.