diff --git a/apps/wallet-mobile/.storybook/storybook.requires.js b/apps/wallet-mobile/.storybook/storybook.requires.js
index ce14bcbce3..d1d11dfb54 100644
--- a/apps/wallet-mobile/.storybook/storybook.requires.js
+++ b/apps/wallet-mobile/.storybook/storybook.requires.js
@@ -166,7 +166,6 @@ const getStories = () => {
"./src/features/Receive/common/ShareDetailsCard/ShareDetailsCard.stories.tsx": require("../src/features/Receive/common/ShareDetailsCard/ShareDetailsCard.stories.tsx"),
"./src/features/Receive/common/SingleOrMultipleAddressesModal/SingleOrMultipleAddressesModal.stories.tsx": require("../src/features/Receive/common/SingleOrMultipleAddressesModal/SingleOrMultipleAddressesModal.stories.tsx"),
"./src/features/Receive/common/SmallAddressCard/SmallAddressCard.stories.tsx": require("../src/features/Receive/common/SmallAddressCard/SmallAddressCard.stories.tsx"),
- "./src/features/RegisterCatalyst/useCases/ConfirmVotingTx/ConfirmVotingTx.stories.tsx": require("../src/features/RegisterCatalyst/useCases/ConfirmVotingTx/ConfirmVotingTx.stories.tsx"),
"./src/features/RegisterCatalyst/useCases/ShowQrCode/ShowQrCode.stories.tsx": require("../src/features/RegisterCatalyst/useCases/ShowQrCode/ShowQrCode.stories.tsx"),
"./src/features/Scan/illustrations/Ilustrations.stories.tsx": require("../src/features/Scan/illustrations/Ilustrations.stories.tsx"),
"./src/features/Scan/useCases/ScanCodeScreen.stories.tsx": require("../src/features/Scan/useCases/ScanCodeScreen.stories.tsx"),
diff --git a/apps/wallet-mobile/src/features/RegisterCatalyst/CatalystNavigator.tsx b/apps/wallet-mobile/src/features/RegisterCatalyst/CatalystNavigator.tsx
index de0fd14e4d..99c9e521d4 100644
--- a/apps/wallet-mobile/src/features/RegisterCatalyst/CatalystNavigator.tsx
+++ b/apps/wallet-mobile/src/features/RegisterCatalyst/CatalystNavigator.tsx
@@ -5,7 +5,6 @@ import {catalystApiMaker} from '@yoroi/staking/src'
import {useTheme} from '@yoroi/theme'
import React from 'react'
import {useIntl} from 'react-intl'
-import {StyleSheet} from 'react-native'
import {Boundary} from '../../components/Boundary/Boundary'
import globalMessages from '../../kernel/i18n/global-messages'
@@ -18,7 +17,6 @@ import {
} from '../../kernel/navigation'
import {NetworkTag} from '../Settings/useCases/changeAppSettings/ChangeNetwork/NetworkTag'
import {ConfirmPin} from './useCases/ConfirmPin/ConfirmPin'
-import {ConfirmVotingTx} from './useCases/ConfirmVotingTx/ConfirmVotingTx'
import {DisplayPin} from './useCases/DisplayPin/DisplayPin'
import {DownloadCatalystAppScreen} from './useCases/DownloadCatalystAppScreen/DownloadCatalystAppScreen'
import {QrCode} from './useCases/ShowQrCode/ShowQrCode'
@@ -33,7 +31,6 @@ export const CatalystNavigator = () => {
const {atoms, color} = useTheme()
const strings = useStrings()
const {track} = useMetrics()
- const {styles} = useStyles()
useFocusEffect(
React.useCallback(() => {
@@ -68,14 +65,6 @@ export const CatalystNavigator = () => {
{/* STEP 3 */}
-
- {() => (
-
-
-
- )}
-
-
{/* STEP 4 */}
null}} />
@@ -91,7 +80,6 @@ export const useNavigateTo = () => {
return {
displayPin: () => navigation.navigate('display-pin'),
confirmPin: () => navigation.navigate('confirm-pin'),
- confirmTx: () => navigation.navigate('confirm-tx'),
qrCode: () => navigation.navigate('qr-code'),
txHistory: () => resetToTxHistory(),
}
@@ -104,14 +92,3 @@ const useStrings = () => {
title: intl.formatMessage(globalMessages.votingTitle),
}
}
-
-const useStyles = () => {
- const {color} = useTheme()
- const styles = StyleSheet.create({
- loadingBackground: {
- backgroundColor: color.bg_color_max,
- },
- })
-
- return {styles}
-}
diff --git a/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmPin/ConfirmPin.tsx b/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmPin/ConfirmPin.tsx
index a6a260c154..90c3fda793 100644
--- a/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmPin/ConfirmPin.tsx
+++ b/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmPin/ConfirmPin.tsx
@@ -9,8 +9,11 @@ import {Button} from '../../../../components/Button/Button'
import {BACKSPACE, NumericKeyboard} from '../../../../components/NumericKeyboard'
import {Space} from '../../../../components/Space/Space'
import {Spacer} from '../../../../components/Spacer/Spacer'
+import {useWalletNavigation} from '../../../../kernel/navigation'
import {generatePrivateKeyForCatalyst} from '../../../../yoroi-wallets/cardano/catalyst'
import {encryptWithPassword} from '../../../../yoroi-wallets/cardano/catalyst/catalystCipher'
+import {useReviewTx} from '../../../ReviewTx/common/ReviewTxProvider'
+import {useSelectedWallet} from '../../../WalletManager/common/hooks/useSelectedWallet'
import {useNavigateTo} from '../../CatalystNavigator'
import {Actions, Description, PinBox, Row, Stepper} from '../../common/components'
import {useStrings} from '../../common/strings'
@@ -19,16 +22,31 @@ export const ConfirmPin = () => {
const strings = useStrings()
const {isDark} = useTheme()
const styles = useStyles()
- const {pin, votingKeyEncryptedChanged, catalystKeyHexChanged} = useCatalyst()
+ const {pin, votingKeyEncryptedChanged} = useCatalyst()
const navigateTo = useNavigateTo()
const [currentActivePin, setCurrentActivePin] = React.useState(1)
+ const {wallet, meta} = useSelectedWallet()
+ const {onCIP36SupportChangeChanged, unsignedTxChanged, onSuccessChanged} = useReviewTx()
+ const {navigateToTxReview} = useWalletNavigation()
const {generateVotingKeys, isLoading} = useGenerateVotingKeys({
- onSuccess: ({catalystKeyHex, votingKeyEncrypted}) => {
+ onSuccess: async ({catalystKeyHex, votingKeyEncrypted}) => {
votingKeyEncryptedChanged(votingKeyEncrypted)
- catalystKeyHexChanged(catalystKeyHex)
- navigateTo.confirmTx()
+ let votingRegTx = await wallet.createVotingRegTx({
+ catalystKeyHex,
+ supportsCIP36: true,
+ addressMode: meta.addressMode,
+ })
+
+ unsignedTxChanged(votingRegTx.votingRegTx)
+ onCIP36SupportChangeChanged(async (supportsCIP36: boolean) => {
+ votingRegTx = await wallet.createVotingRegTx({catalystKeyHex, supportsCIP36, addressMode: meta.addressMode})
+ unsignedTxChanged(votingRegTx.votingRegTx)
+ })
+ onSuccessChanged(navigateTo.qrCode)
+
+ navigateToTxReview()
},
})
diff --git a/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmVotingTx/ConfirmVotingTx.stories.tsx b/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmVotingTx/ConfirmVotingTx.stories.tsx
deleted file mode 100644
index 74be329232..0000000000
--- a/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmVotingTx/ConfirmVotingTx.stories.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import {action} from '@storybook/addon-actions'
-import {storiesOf} from '@storybook/react-native'
-import {Catalyst, CatalystProvider} from '@yoroi/staking'
-import {catalystConfig} from '@yoroi/staking/src/catalyst/config'
-import {WalletMeta} from '@yoroi/types/lib/typescript/wallet/meta'
-import React from 'react'
-
-import {QueryProvider} from '../../../../../.storybook/decorators'
-import {Boundary} from '../../../../components/Boundary/Boundary'
-import {YoroiWallet} from '../../../../yoroi-wallets/cardano/types'
-import {mocks} from '../../../../yoroi-wallets/mocks/wallet'
-import {walletManagerMock, WalletManagerProviderMock} from '../../../../yoroi-wallets/mocks/WalletManagerProviderMock'
-import {ConfirmVotingTx} from './ConfirmVotingTx'
-
-storiesOf('Catalyst ConfirmVotingTx', module)
- .add('password', () => (
-
-
-
- ))
- .add('hw', () => (
-
-
-
- ))
- .add('os', () => (
-
-
-
- ))
-
-const Providers = ({wallet, children, meta}: {wallet: YoroiWallet; children: React.ReactNode; meta: WalletMeta}) => {
- walletManagerMock.setSelectedWalletId(wallet.id)
-
- const manager: Catalyst.Manager = {
- config: catalystConfig,
- getFundInfo: action('getFundInfo') as Catalyst.Manager['getFundInfo'],
- fundStatus: action('fundStatus') as Catalyst.Manager['fundStatus'],
- }
- return (
-
-
-
-
- {children}
-
-
-
-
- )
-}
diff --git a/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmVotingTx/ConfirmVotingTx.tsx b/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmVotingTx/ConfirmVotingTx.tsx
deleted file mode 100644
index 2ec8266a04..0000000000
--- a/apps/wallet-mobile/src/features/RegisterCatalyst/useCases/ConfirmVotingTx/ConfirmVotingTx.tsx
+++ /dev/null
@@ -1,157 +0,0 @@
-import {useCatalyst} from '@yoroi/staking'
-import {useTheme} from '@yoroi/theme'
-import React, {useState} from 'react'
-import {ScrollView, StyleSheet, Text, View} from 'react-native'
-import {SafeAreaView} from 'react-native-safe-area-context'
-
-import {Button} from '../../../../components/Button/Button'
-import {ConfirmTxWithHwModal} from '../../../../components/ConfirmTxWithHwModal/ConfirmTxWithHwModal'
-import {ConfirmTxWithOsModal} from '../../../../components/ConfirmTxWithOsModal/ConfirmTxWithOsModal'
-import {ConfirmTxWithSpendingPasswordModal} from '../../../../components/ConfirmTxWithSpendingPasswordModal/ConfirmTxWithSpendingPasswordModal'
-import {KeyboardAvoidingView} from '../../../../components/KeyboardAvoidingView/KeyboardAvoidingView'
-import {useModal} from '../../../../components/Modal/ModalContext'
-import {Space} from '../../../../components/Space/Space'
-import {Spacer} from '../../../../components/Spacer/Spacer'
-import {TextInput} from '../../../../components/TextInput/TextInput'
-import {Instructions as HWInstructions} from '../../../../legacy/HW'
-import {useVotingRegTx} from '../../../../yoroi-wallets/hooks'
-import {formatTokenWithSymbol} from '../../../../yoroi-wallets/utils/format'
-import {Amounts} from '../../../../yoroi-wallets/utils/utils'
-import {useSelectedWallet} from '../../../WalletManager/common/hooks/useSelectedWallet'
-import {useNavigateTo} from '../../CatalystNavigator'
-import {Actions, Description} from '../../common/components'
-import {useStrings} from '../../common/strings'
-
-export const ConfirmVotingTx = () => {
- const [supportsCIP36, setSupportsCIP36] = useState(true)
- const styles = useStyles()
- const strings = useStrings()
- const {openModal, closeModal} = useModal()
- const {catalystKeyHex, pin} = useCatalyst()
- const navigateTo = useNavigateTo()
-
- const onNext = () => {
- navigateTo.qrCode()
- }
-
- if (pin === null) throw new Error('pin cannot be null')
- if (catalystKeyHex === null) throw new Error('catalystKeyHex cannot be null')
-
- const {wallet, meta} = useSelectedWallet()
- const votingRegTx = useVotingRegTx({wallet, supportsCIP36, catalystKeyHex, addressMode: meta.addressMode})
-
- const [useUSB, setUseUSB] = useState(false)
-
- const handleCIP36SupportChange = (supportsCIP36: boolean) => {
- setSupportsCIP36(supportsCIP36)
- }
-
- const onSubmit = () => {
- if (meta.isHW) {
- openModal(
- strings.signTransaction,
- onNext()}
- />,
- )
- return
- }
-
- if (!meta.isHW && !meta.isEasyConfirmationEnabled) {
- openModal(
- strings.signTransaction,
- onNext()} />,
- )
- return
- }
-
- if (!meta.isHW && meta.isEasyConfirmationEnabled) {
- openModal(strings.signTransaction, onNext()} />)
- return
- }
- }
-
- return (
-
-
-
-
-
- {strings.confirmationTitle}
-
-
-
- {meta.isHW ? (
- <>
-
-
-
- >
- ) : (
- <>
-
- {meta.isEasyConfirmationEnabled ? strings.authOsInstructions : strings.passwordSignDescription}
-
-
-
- >
- )}
-
-
- {strings.fees}
-
-
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-const useStyles = () => {
- const {color, atoms} = useTheme()
- const styles = StyleSheet.create({
- safeAreaView: {
- backgroundColor: color.bg_color_max,
- ...atoms.flex_1,
- ...atoms.px_lg,
- ...atoms.pb_lg,
- },
- confirmVotingTxTitle: {
- ...atoms.body_2_md_regular,
- color: color.text_gray_medium,
- },
- label: {
- top: -3,
- left: 11,
- paddingHorizontal: 3,
- color: color.text_gray_max,
- backgroundColor: color.gray_min,
- ...atoms.z_50,
- ...atoms.absolute,
- ...atoms.body_3_sm_regular,
- },
- inputContainer: {
- ...atoms.relative,
- },
- })
-
- return styles
-}
diff --git a/apps/wallet-mobile/src/features/ReviewTx/common/ReviewTxProvider.tsx b/apps/wallet-mobile/src/features/ReviewTx/common/ReviewTxProvider.tsx
index 93f5632b61..44274bd96c 100644
--- a/apps/wallet-mobile/src/features/ReviewTx/common/ReviewTxProvider.tsx
+++ b/apps/wallet-mobile/src/features/ReviewTx/common/ReviewTxProvider.tsx
@@ -30,6 +30,10 @@ export const ReviewTxProvider = ({
onSuccessChanged: (onSuccess: ReviewTxState['onSuccess']) =>
dispatch({type: ReviewTxActionType.OnSuccessChanged, onSuccess}),
onErrorChanged: (onError: ReviewTxState['onError']) => dispatch({type: ReviewTxActionType.OnErrorChanged, onError}),
+ onNotSupportedCIP1694Changed: (onNotSupportedCIP1694: ReviewTxState['onNotSupportedCIP1694']) =>
+ dispatch({type: ReviewTxActionType.onNotSupportedCIP1694Changed, onNotSupportedCIP1694}),
+ onCIP36SupportChangeChanged: (onCIP36SupportChange: ReviewTxState['onCIP36SupportChange']) =>
+ dispatch({type: ReviewTxActionType.onCIP36SupportChangeChanged, onCIP36SupportChange}),
}).current
const context = React.useMemo(
@@ -74,6 +78,14 @@ const reviewTxReducer = (state: ReviewTxState, action: ReviewTxAction) => {
draft.onError = action.onError
break
+ case ReviewTxActionType.onNotSupportedCIP1694Changed:
+ draft.onNotSupportedCIP1694 = action.onNotSupportedCIP1694
+ break
+
+ case ReviewTxActionType.onCIP36SupportChangeChanged:
+ draft.onCIP36SupportChange = action.onCIP36SupportChange
+ break
+
default:
throw new Error('[ReviewTxContext] invalid action')
}
@@ -109,6 +121,14 @@ type ReviewTxAction =
type: ReviewTxActionType.OnErrorChanged
onError: ReviewTxState['onError']
}
+ | {
+ type: ReviewTxActionType.onNotSupportedCIP1694Changed
+ onNotSupportedCIP1694: ReviewTxState['onNotSupportedCIP1694']
+ }
+ | {
+ type: ReviewTxActionType.onCIP36SupportChangeChanged
+ onCIP36SupportChange: ReviewTxState['onCIP36SupportChange']
+ }
export type ReviewTxState = {
unsignedTx: YoroiUnsignedTx | null
@@ -118,6 +138,8 @@ export type ReviewTxState = {
details: {title: string; component: React.ReactNode} | null
onSuccess: ((signedTx: YoroiSignedTx) => void) | null
onError: (() => void) | null
+ onNotSupportedCIP1694: (() => void) | null
+ onCIP36SupportChange: ((isCIP36Supported: boolean) => void) | null
}
type ReviewTxActions = {
@@ -128,6 +150,8 @@ type ReviewTxActions = {
detailsChanged: (details: ReviewTxState['details']) => void
onSuccessChanged: (onSuccess: ReviewTxState['onSuccess']) => void
onErrorChanged: (onError: ReviewTxState['onError']) => void
+ onNotSupportedCIP1694Changed: (onNotSupportedCIP1694: ReviewTxState['onNotSupportedCIP1694']) => void
+ onCIP36SupportChangeChanged: (onCIP36SupportChange: ReviewTxState['onCIP36SupportChange']) => void
}
const defaultState: ReviewTxState = Object.freeze({
@@ -138,6 +162,8 @@ const defaultState: ReviewTxState = Object.freeze({
details: null,
onSuccess: null,
onError: null,
+ onNotSupportedCIP1694: null,
+ onCIP36SupportChange: null,
})
function missingInit() {
@@ -153,6 +179,8 @@ const initialReviewTxContext: ReviewTxContext = {
detailsChanged: missingInit,
onSuccessChanged: missingInit,
onErrorChanged: missingInit,
+ onNotSupportedCIP1694Changed: missingInit,
+ onCIP36SupportChangeChanged: missingInit,
}
enum ReviewTxActionType {
@@ -163,6 +191,8 @@ enum ReviewTxActionType {
DetailsChanged = 'detailsChanged',
OnSuccessChanged = 'onSuccessChanged',
OnErrorChanged = 'onErrorChanged',
+ onNotSupportedCIP1694Changed = 'onNotSupportedCIP1694Changed',
+ onCIP36SupportChangeChanged = 'onCIP36SupportChangeChanged',
}
type ReviewTxContext = ReviewTxState & ReviewTxActions
diff --git a/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useFormattedMetadata.tsx b/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useFormattedMetadata.tsx
index 7b67530d7c..d84816e045 100644
--- a/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useFormattedMetadata.tsx
+++ b/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useFormattedMetadata.tsx
@@ -1,13 +1,18 @@
+import _ from 'lodash'
+
import {YoroiUnsignedTx} from '../../../../yoroi-wallets/types/yoroi'
-import {TransactionBody} from '../types'
+import {FormattedMetadata, TransactionBody} from '../types'
-export const formatMetadata = (unsignedTx: YoroiUnsignedTx, txBody: TransactionBody) => {
+export const formatMetadata = (unsignedTx: YoroiUnsignedTx, txBody: TransactionBody): FormattedMetadata => {
const hash = txBody.auxiliary_data_hash ?? null
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- const metadata = unsignedTx.metadata?.['674']?.['msg' as any] ?? null
+ const msg = unsignedTx.metadata?.['674']?.['msg' as any] ?? JSON.stringify({})
+
+ const metadata = hash != null && typeof msg == 'string' ? {msg: [JSON.parse(msg) as unknown]} : null
return {
hash,
- metadata: {msg: [JSON.parse(metadata)]},
+ metadata,
}
}
diff --git a/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useOnConfirm.tsx b/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useOnConfirm.tsx
index 871badd91b..b00d30458b 100644
--- a/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useOnConfirm.tsx
+++ b/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useOnConfirm.tsx
@@ -5,7 +5,6 @@ import {ConfirmTxWithOsModal} from '../../../../components/ConfirmTxWithOsModal/
import {ConfirmTxWithSpendingPasswordModal} from '../../../../components/ConfirmTxWithSpendingPasswordModal/ConfirmTxWithSpendingPasswordModal'
import {useModal} from '../../../../components/Modal/ModalContext'
import {YoroiSignedTx, YoroiUnsignedTx} from '../../../../yoroi-wallets/types/yoroi'
-import {useNavigateTo} from '../../../Staking/Governance/common/navigation'
import {useSelectedWallet} from '../../../WalletManager/common/hooks/useSelectedWallet'
import {useStrings} from './useStrings'
@@ -14,18 +13,21 @@ export const useOnConfirm = ({
unsignedTx,
onSuccess,
onError,
+ onNotSupportedCIP1694,
+ onCIP36SupportChange,
}: {
onSuccess?: ((txId: YoroiSignedTx) => void) | null
onError?: (() => void) | null
cbor?: string
unsignedTx?: YoroiUnsignedTx
+ onNotSupportedCIP1694?: (() => void) | null
+ onCIP36SupportChange?: ((isCIP36Supported: boolean) => void) | null
}) => {
if (unsignedTx === undefined) throw new Error('useOnConfirm: unsignedTx missing')
const {meta} = useSelectedWallet()
const {openModal, closeModal} = useModal()
const strings = useStrings()
- const navigateTo = useNavigateTo()
const onConfirm = () => {
if (meta.isHW) {
@@ -36,9 +38,12 @@ export const useOnConfirm = ({
unsignedTx={unsignedTx}
onSuccess={(signedTx) => onSuccess?.(signedTx)}
onNotSupportedCIP1694={() => {
- closeModal()
- navigateTo.notSupportedVersion()
+ if (onNotSupportedCIP1694) {
+ closeModal()
+ onNotSupportedCIP1694()
+ }
}}
+ onCIP36SupportChange={onCIP36SupportChange ?? undefined}
/>,
400,
)
diff --git a/apps/wallet-mobile/src/features/ReviewTx/common/types.ts b/apps/wallet-mobile/src/features/ReviewTx/common/types.ts
index 74cb9b2451..04cf6aec6d 100644
--- a/apps/wallet-mobile/src/features/ReviewTx/common/types.ts
+++ b/apps/wallet-mobile/src/features/ReviewTx/common/types.ts
@@ -58,7 +58,7 @@ export type FormattedTx = {
fee: FormattedFee
}
-export type Metadata = {
- json: string | null
+export type FormattedMetadata = {
hash: string | null
+ metadata: {msg: Array} | null
}
diff --git a/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/Metadata/MetadataTab.tsx b/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/Metadata/MetadataTab.tsx
index c60e4d1c60..003cbcf55f 100644
--- a/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/Metadata/MetadataTab.tsx
+++ b/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/Metadata/MetadataTab.tsx
@@ -5,13 +5,9 @@ import {StyleSheet, Text, View} from 'react-native'
import {Space} from '../../../../../components/Space/Space'
import {CopiableText, CopyButton} from '../../../common/CopiableText'
import {useStrings} from '../../../common/hooks/useStrings'
+import {FormattedMetadata} from '../../../common/types'
-type Props = {
- hash: string | null
- metadata: {msg: Array} | null
-}
-
-export const MetadataTab = ({metadata, hash}: Props) => {
+export const MetadataTab = ({metadata, hash}: FormattedMetadata) => {
const {styles} = useStyles()
const strings = useStrings()
diff --git a/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/ReviewTxScreen.tsx b/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/ReviewTxScreen.tsx
index 9b0550327d..48f54294af 100644
--- a/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/ReviewTxScreen.tsx
+++ b/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/ReviewTxScreen.tsx
@@ -31,7 +31,8 @@ const MaterialTab = createMaterialTopTabNavigator()
export const ReviewTxScreen = () => {
const {styles} = useStyles()
const strings = useStrings()
- const {unsignedTx, operations, details, onSuccess, onError} = useReviewTx()
+ const {unsignedTx, operations, details, onSuccess, onError, onNotSupportedCIP1694, onCIP36SupportChange} =
+ useReviewTx()
if (unsignedTx === null) throw new Error('ReviewTxScreen: missing unsignedTx')
@@ -39,6 +40,8 @@ export const ReviewTxScreen = () => {
unsignedTx,
onSuccess,
onError,
+ onNotSupportedCIP1694,
+ onCIP36SupportChange,
})
// TODO: apply cbor
diff --git a/apps/wallet-mobile/src/features/Staking/Governance/common/helpers.tsx b/apps/wallet-mobile/src/features/Staking/Governance/common/helpers.tsx
index 8e02078802..6a838019e9 100644
--- a/apps/wallet-mobile/src/features/Staking/Governance/common/helpers.tsx
+++ b/apps/wallet-mobile/src/features/Staking/Governance/common/helpers.tsx
@@ -82,7 +82,8 @@ export const useGovernanceActions = () => {
const {manager} = useGovernance()
const {wallet} = useSelectedWallet()
const navigateTo = useNavigateTo()
- const {unsignedTxChanged, onSuccessChanged, onErrorChanged, operationsChanged} = useReviewTx()
+ const {unsignedTxChanged, onSuccessChanged, onErrorChanged, operationsChanged, onNotSupportedCIP1694Changed} =
+ useReviewTx()
const {updateLatestGovernanceAction} = useUpdateLatestGovernanceAction(wallet.id)
const {navigateToTxReview} = useWalletNavigation()
@@ -112,6 +113,9 @@ export const useGovernanceActions = () => {
})
onErrorChanged(() => navigateTo.txFailed())
unsignedTxChanged(unsignedTx)
+ onNotSupportedCIP1694Changed(() => {
+ navigateTo.notSupportedVersion()
+ })
navigateToTxReview()
}
@@ -135,6 +139,9 @@ export const useGovernanceActions = () => {
})
onErrorChanged(() => navigateTo.txFailed())
unsignedTxChanged(unsignedTx)
+ onNotSupportedCIP1694Changed(() => {
+ navigateTo.notSupportedVersion()
+ })
navigateToTxReview()
}
@@ -161,6 +168,9 @@ export const useGovernanceActions = () => {
})
onErrorChanged(() => navigateTo.txFailed())
unsignedTxChanged(unsignedTx)
+ onNotSupportedCIP1694Changed(() => {
+ navigateTo.notSupportedVersion()
+ })
navigateToTxReview()
}
diff --git a/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts b/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts
index 29dbd086a9..5765473a45 100644
--- a/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts
+++ b/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts
@@ -229,12 +229,12 @@ export const useVotingRegTx = (
catalystKeyHex,
supportsCIP36,
addressMode,
- }: {wallet: YoroiWallet; catalystKeyHex: string; supportsCIP36: boolean; addressMode: Wallet.AddressMode},
+ }: {wallet: YoroiWallet; catalystKeyHex: string | null; supportsCIP36: boolean; addressMode: Wallet.AddressMode},
options?: UseQueryOptions<
- VotingRegTxAndEncryptedKey,
+ VotingRegTxAndEncryptedKey | undefined,
Error,
VotingRegTxAndEncryptedKey,
- [string, string, 'voting-reg-tx', string]
+ [string | null, string, 'voting-reg-tx', string]
>,
) => {
const query = useQuery({
@@ -243,7 +243,10 @@ export const useVotingRegTx = (
cacheTime: 0,
suspense: true,
queryKey: [catalystKeyHex, wallet.id, 'voting-reg-tx', JSON.stringify({supportsCIP36})],
- queryFn: () => wallet.createVotingRegTx({catalystKeyHex, supportsCIP36, addressMode}),
+ queryFn: async () => {
+ if (catalystKeyHex === null) return
+ return wallet.createVotingRegTx({catalystKeyHex, supportsCIP36, addressMode})
+ },
})
if (!query.data) throw new Error('invalid state')
diff --git a/packages/staking/src/catalyst/translators/context.tsx b/packages/staking/src/catalyst/translators/context.tsx
index a1e4a910f3..65598d49fa 100644
--- a/packages/staking/src/catalyst/translators/context.tsx
+++ b/packages/staking/src/catalyst/translators/context.tsx
@@ -53,11 +53,6 @@ export function CatalystProvider({
type: CatalystActionType.VotingKeyEncryptedChanged,
votingKeyEncrypted,
}),
- catalystKeyHexChanged: (catalystKeyHex: CatalystState['catalystKeyHex']) =>
- dispatch({
- type: CatalystActionType.CatalystKeyHexChanged,
- catalystKeyHex,
- }),
reset: () =>
dispatch({
type: CatalystActionType.Reset,
diff --git a/packages/staking/src/catalyst/translators/state.test.tsx b/packages/staking/src/catalyst/translators/state.test.tsx
index 00096625de..6040327d02 100644
--- a/packages/staking/src/catalyst/translators/state.test.tsx
+++ b/packages/staking/src/catalyst/translators/state.test.tsx
@@ -39,20 +39,8 @@ describe('State Actions', () => {
expect(state.votingKeyEncrypted).toBe(votingKeyEncrypted)
})
- it('CatalystKeyHexChanged', () => {
- const catalystKeyHex = 'super-complex-hex'
- const action: CatalystAction = {
- type: CatalystActionType.CatalystKeyHexChanged,
- catalystKeyHex,
- }
-
- const state = catalystReducer(catalystDefaultState, action)
- expect(state.catalystKeyHex).toBe(catalystKeyHex)
- })
-
it('Reset', () => {
const votingKeyEncrypted = 'super-complex-voting-key'
- const catalystKeyHex = 'super-complex-catalyst-key'
const action: CatalystAction = {
type: CatalystActionType.Reset,
}
@@ -62,12 +50,10 @@ describe('State Actions', () => {
...catalystDefaultState,
pin: '1234',
votingKeyEncrypted,
- catalystKeyHex,
},
action,
)
expect(state.pin).toBe(null)
expect(state.votingKeyEncrypted).toBe(null)
- expect(state.catalystKeyHex).toBe(null)
})
})
diff --git a/packages/staking/src/catalyst/translators/state.tsx b/packages/staking/src/catalyst/translators/state.tsx
index 08e2f60517..b5d942f9b9 100644
--- a/packages/staking/src/catalyst/translators/state.tsx
+++ b/packages/staking/src/catalyst/translators/state.tsx
@@ -14,14 +14,10 @@ export const catalystReducer = (
draft.votingKeyEncrypted = action.votingKeyEncrypted
break
- case CatalystActionType.CatalystKeyHexChanged:
- draft.catalystKeyHex = action.catalystKeyHex
- break
-
case CatalystActionType.Reset:
draft.pin = catalystDefaultState.pin
draft.votingKeyEncrypted = catalystDefaultState.votingKeyEncrypted
- draft.catalystKeyHex = catalystDefaultState.catalystKeyHex
+
break
default:
@@ -34,7 +30,6 @@ export const catalystDefaultState: Readonly = freeze(
{
pin: null,
votingKeyEncrypted: null,
- catalystKeyHex: null,
},
true,
)
@@ -42,7 +37,6 @@ export const catalystDefaultState: Readonly = freeze(
export type CatalystState = {
pin: string | null
votingKeyEncrypted: string | null
- catalystKeyHex: string | null
}
export type CatalystAction =
@@ -51,10 +45,6 @@ export type CatalystAction =
type: CatalystActionType.VotingKeyEncryptedChanged
votingKeyEncrypted: CatalystState['votingKeyEncrypted']
}
- | {
- type: CatalystActionType.CatalystKeyHexChanged
- catalystKeyHex: CatalystState['catalystKeyHex']
- }
| {
type: CatalystActionType.Reset
}
@@ -62,7 +52,6 @@ export type CatalystAction =
export enum CatalystActionType {
PinChanged = 'pinChanged',
VotingKeyEncryptedChanged = 'votingKeyEncryptedChanged',
- CatalystKeyHexChanged = 'catalystKeyHexChanged',
Reset = 'reset',
}
@@ -71,9 +60,6 @@ export type CatalystActions = {
votingKeyEncryptedChanged: (
votingKeyEncrypted: CatalystState['votingKeyEncrypted'],
) => void
- catalystKeyHexChanged: (
- catalystKeyHex: CatalystState['catalystKeyHex'],
- ) => void
reset: () => void
}