diff --git a/package.json b/package.json index 0150b908..c0900631 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "postinstall": "patch-package --exclude 'nothing'" }, "dependencies": { - "@cashu/cashu-ts": "minibits-cash/cashu-ts#1.0.0-minibits.3", + "@cashu/cashu-ts": "minibits-cash/cashu-ts#1.0.0-minibits.4", + "@exodus/borc": "^2.1.1", "@fortawesome/fontawesome-svg-core": "^6.5.2", "@fortawesome/free-brands-svg-icons": "^6.5.2", "@fortawesome/free-regular-svg-icons": "^6.5.2", diff --git a/src/components/Card.tsx b/src/components/Card.tsx index af944a3f..25bb18f2 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -123,7 +123,7 @@ interface CardProps extends TouchableOpacityProps { * * - [Documentation and Examples](https://github.com/infinitered/ignite/blob/master/docs/Components-Card.md) */ -export function Card(props: CardProps) { +export const Card = function (props: CardProps) { const backgroundColor = useThemeColor('card') diff --git a/src/components/ListItem.tsx b/src/components/ListItem.tsx index 76726db1..1fd56087 100644 --- a/src/components/ListItem.tsx +++ b/src/components/ListItem.tsx @@ -1,5 +1,5 @@ import { verticalScale } from "@gocodingnow/rn-size-matters" -import React, { ReactElement } from "react" +import { ReactElement } from "react" import { ColorValue, useColorScheme } from "react-native" import { StyleProp, @@ -122,7 +122,7 @@ interface ListItemActionProps { * * - [Documentation and Examples](https://github.com/infinitered/ignite/blob/master/docs/Components-ListItem.md) */ -export function ListItem(props: ListItemProps) { +export const ListItem = function (props: ListItemProps) { const colorScheme = useColorScheme() const { diff --git a/src/i18n_messages/en.json b/src/i18n_messages/en.json index e4e22467..ae177c8d 100644 --- a/src/i18n_messages/en.json +++ b/src/i18n_messages/en.json @@ -304,7 +304,7 @@ "profileToRecoverDesc": "This is the wallet address linked to your seed. If you press Complete, your wallet profile will reset to above seed and address.", "pushNotifications": "Push notifications", "qr": { - "fail": "Could not display QR code, copy or share the Ecash token instead." + "fail": "Could not display QR code, try new v4 token format or use option to send token to contact." }, "receiverMemo": "Memo for the receiver", "receiveScreen": { diff --git a/src/screens/Contacts/OwnName.tsx b/src/screens/Contacts/OwnName.tsx index d0fe4fcf..8c37a321 100644 --- a/src/screens/Contacts/OwnName.tsx +++ b/src/screens/Contacts/OwnName.tsx @@ -335,6 +335,7 @@ export const OwnName = observer(function (props: {navigation: any, pubkey: strin )} diff --git a/src/screens/LocalRecoveryScreen.tsx b/src/screens/LocalRecoveryScreen.tsx index 6f7aec46..ee7caa9e 100644 --- a/src/screens/LocalRecoveryScreen.tsx +++ b/src/screens/LocalRecoveryScreen.tsx @@ -1,5 +1,5 @@ import {observer} from 'mobx-react-lite' -import React, {FC, useState, useEffect, useRef, useMemo} from 'react' +import React, {FC, useState, useEffect} from 'react' import { TextStyle, ViewStyle, @@ -30,13 +30,10 @@ import AppError from '../utils/AppError' import {BackupProof, Proof} from '../models/Proof' import { useStores } from '../models' import { CashuUtils } from '../services/cashu/cashuUtils' -import JSONTree from 'react-native-json-tree' import Clipboard from '@react-native-clipboard/clipboard' -import { getEncodedToken } from '@cashu/cashu-ts' import { Transaction, TransactionData, TransactionRecord, TransactionStatus, TransactionType } from '../models/Transaction' import { WalletUtils } from '../services/wallet/utils' -import { MintUnit, MintUnits, getCurrency } from '../services/wallet/currency' -import { ScrollView } from 'react-native-gesture-handler' +import { MintUnits, getCurrency } from '../services/wallet/currency' import { CurrencyAmount } from './Wallet/CurrencyAmount' import { translate } from '../i18n' @@ -172,7 +169,7 @@ export const LocalRecoveryScreen: FC = log.trace(tokenByMint) - const encodedByMint = getEncodedToken(tokenByMint) + const encodedByMint = CashuUtils.encodeToken(tokenByMint) encodedTokens.push(encodedByMint) } } diff --git a/src/screens/PaymentRequests/OutgoingRequests.tsx b/src/screens/PaymentRequests/OutgoingRequests.tsx index 7a286ed9..a07ff0bd 100644 --- a/src/screens/PaymentRequests/OutgoingRequests.tsx +++ b/src/screens/PaymentRequests/OutgoingRequests.tsx @@ -112,6 +112,7 @@ export const OutgoingRequests = observer(function (props: { } diff --git a/src/screens/SendScreen.tsx b/src/screens/SendScreen.tsx index d5860ee8..cad00ae5 100644 --- a/src/screens/SendScreen.tsx +++ b/src/screens/SendScreen.tsx @@ -636,8 +636,9 @@ export const SendScreen: FC> = observer( {transactionStatus === TransactionStatus.PENDING && encodedTokenToSend && paymentOption && ( <> > = function TokenReceiveScreen(_props) { diff --git a/src/screens/TopupScreen.tsx b/src/screens/TopupScreen.tsx index 95c27643..d4be9208 100644 --- a/src/screens/TopupScreen.tsx +++ b/src/screens/TopupScreen.tsx @@ -752,7 +752,8 @@ export const TopupScreen: FC> = observer( <> diff --git a/src/screens/Wallet/QRCode.tsx b/src/screens/Wallet/QRCode.tsx index fe07e8d9..089d087e 100644 --- a/src/screens/Wallet/QRCode.tsx +++ b/src/screens/Wallet/QRCode.tsx @@ -7,16 +7,20 @@ import { moderateVerticalScale } from "@gocodingnow/rn-size-matters" import { colors, spacing } from "../../theme" import { useState } from "react" import { translate } from "../../i18n" +import { CashuUtils } from "../../services/cashu/cashuUtils" +import { log } from "../../services" export const QRCodeBlock = function (props: { - qrCodeData: string + qrCodeData: string title: string + type: 'EncodedV3Token' | 'EncodedV4Token' | 'Bolt11Invoice' | 'URL' size?: number } ) { - const {qrCodeData, title, size} = props - const [qrError, setQrError] = useState() + const {qrCodeData, title, type, size} = props + const [qrError, setQrError] = useState() + const [encodedV4Token, setEncodedV4Token] = useState() const handleQrError = function (error: Error) { setQrError(error) @@ -40,6 +44,26 @@ export const QRCodeBlock = function (props: { setQrError(e) } } + + + const switchTokenEncoding = function () { + try { + if(encodedV4Token) { + setEncodedV4Token(undefined) + } else if(type === 'EncodedV3Token') { + log.trace('[v3]', qrCodeData) + + const decoded = CashuUtils.decodeToken(qrCodeData) + const encodedV4 = CashuUtils.encodeToken(decoded, 4) + + log.trace('[v4]', encodedV4) + + setEncodedV4Token(encodedV4) + } + } catch (e: any) { + setQrError(e) + } + } const onCopy = function () { @@ -54,7 +78,7 @@ export const QRCodeBlock = function (props: { handleQrError(error)} /> - )} + )} FooterComponent={