From 73abee345a8127a3513009761989c9e8a739a1bf Mon Sep 17 00:00:00 2001 From: Michal Date: Tue, 19 Dec 2023 09:19:06 +0000 Subject: [PATCH] feat(governance): Add governance feature (#2931) --- apps/wallet-mobile/.env | 2 +- apps/wallet-mobile/.env.nightly | 2 +- apps/wallet-mobile/.env.production | 2 +- apps/wallet-mobile/.env.staging | 2 +- .../.storybook/storybook.requires.js | 13 +- apps/wallet-mobile/ios/Podfile.lock | 4 +- apps/wallet-mobile/package.json | 11 +- .../src/Catalyst/VotingBanner.tsx | 6 +- .../wallet-mobile/src/Dashboard/Dashboard.tsx | 33 +- .../src/Dashboard/DashboardNavigator.tsx | 54 +- .../WalletSelection/WalletSelectionScreen.tsx | 22 + .../src/TxHistory/ActionsBanner.tsx | 3 +- .../src/TxHistory/TxHistoryNavigator.tsx | 5 +- apps/wallet-mobile/src/WalletNavigator.tsx | 3 + .../ConfirmTxWithHwModal.stories.tsx | 17 + .../ConfirmTxWithHwModal.tsx | 111 ++ .../components/ConfirmTxWithHwModal/index.ts | 1 + .../ConfirmTxWithHwModal/strings.ts | 8 + .../ConfirmTxWithOsModal.stories.tsx | 17 + .../ConfirmTxWithOsModal.tsx | 69 + .../components/ConfirmTxWithOsModal/index.ts | 1 + ...irmTxWithSpendingPasswordModal.stories.tsx | 17 + .../ConfirmTxWithSpendingPasswordModal.tsx | 133 ++ .../index.ts | 1 + .../strings.ts | 14 + .../src/components/Icon/ArrowRight.tsx | 19 + .../src/components/Icon/Governance.tsx | 16 + .../src/components/Icon/Icon.stories.tsx | 4 + .../src/components/Icon/index.ts | 4 + .../ModalError/ModalError.stories.tsx | 0 .../ModalError/ModalError.tsx | 8 +- .../src/components/ModalError/strings.ts | 19 + .../features/Claim/module/useClaimTokens.tsx | 2 +- apps/wallet-mobile/src/features/Menu/Menu.tsx | 24 +- .../Settings/PrivacyMode/PrivacyMode.tsx | 4 +- .../Settings/ScreenShare/ScreenShare.ts | 4 +- .../Governance/GovernanceNavigator.tsx | 56 + .../common/Action/Action.stories.tsx | 15 + .../Governance/common/Action/Action.tsx | 78 ++ .../Staking/Governance/common/Action/index.ts | 1 + .../LearnMoreLink/LearnMoreLink.stories.tsx | 6 + .../common/LearnMoreLink/LearnMoreLink.tsx | 37 + .../Governance/common/LearnMoreLink/index.ts | 1 + .../Staking/Governance/common/SafeArea.tsx | 25 + .../Staking/Governance/common/helpers.ts | 66 + .../Staking/Governance/common/index.ts | 12 + .../Staking/Governance/common/mocks.ts | 69 + .../Staking/Governance/common/navigation.ts | 34 + .../Staking/Governance/common/strings.ts | 253 ++++ .../Governance/illustrations/BrokenImage.tsx | 62 + .../illustrations/SuccessTxImage.tsx | 78 ++ .../Staking/Governance/illustrations/index.ts | 2 + .../src/features/Staking/Governance/index.ts | 5 + .../src/features/Staking/Governance/types.ts | 1 + .../ChangeVote/ChangeVoteScreen.stories.tsx | 65 + .../useCases/ChangeVote/ChangeVoteScreen.tsx | 159 +++ .../Governance/useCases/ChangeVote/index.ts | 1 + .../ConfirmTx/ConfirmTxScreen.stories.tsx | 55 + .../useCases/ConfirmTx/ConfirmTxScreen.tsx | 258 ++++ .../Governance/useCases/ConfirmTx/index.ts | 1 + .../EnterDrepIdModal.stories.tsx | 16 + .../EnterDrepIdModal/EnterDrepIdModal.tsx | 89 ++ .../useCases/EnterDrepIdModal/index.ts | 1 + .../FailedTx/FailedTxScreen.stories.tsx | 9 + .../useCases/FailedTx/FailedTxScreen.tsx | 66 + .../Governance/useCases/FailedTx/index.ts | 1 + .../useCases/Home/HomeScreen.stories.tsx | 120 ++ .../Governance/useCases/Home/HomeScreen.tsx | 391 ++++++ .../Staking/Governance/useCases/Home/index.ts | 1 + .../SuccessTx/SuccessTxScreen.stories.tsx | 9 + .../useCases/SuccessTx/SuccessTxScreen.tsx | 90 ++ .../Governance/useCases/SuccessTx/index.ts | 1 + .../WithdrawWarningModal.tsx | 40 + .../useCases/WithdrawWarningModal/index.ts | 1 + .../Staking/Governance/useCases/index.ts | 5 + .../Swap/common/ConfirmRawTx/ConfirmRawTx.tsx | 2 +- .../src/features/Swap/common/useSwapTx.ts | 2 +- .../useCases/ConfirmTxScreen/ConfirmTx.tsx | 2 +- .../CreateOrder/CreateOrder.tsx | 4 +- .../wallet-mobile/src/i18n/global-messages.ts | 12 + .../wallet-mobile/src/i18n/locales/en-US.json | 47 + apps/wallet-mobile/src/legacy/config.ts | 7 + apps/wallet-mobile/src/navigation.tsx | 26 + .../src/yoroi-wallets/auth/auth.ts | 3 +- .../cardano/addressInfo/addressInfo.ts | 6 +- .../cardano/byron/ByronWallet.ts | 75 +- .../cardano/catalyst/catalystUtils.test.ts | 13 - .../cardano/catalyst/catalystUtils.ts | 89 -- .../src/yoroi-wallets/cardano/chain/chain.ts | 8 +- .../cardano/common/signatureUtils.ts | 2 + .../cardano/constants/sanchonet/constants.ts | 108 ++ .../src/yoroi-wallets/cardano/getWallet.ts | 7 +- .../src/yoroi-wallets/cardano/networks.ts | 15 +- .../cardano/shelley/ShelleyWallet.ts | 63 +- .../yoroi-wallets/cardano/shelley/wallets.ts | 2 + .../src/yoroi-wallets/cardano/types.ts | 3 +- .../cardano/unsignedTx/unsignedTx.ts | 21 +- .../src/yoroi-wallets/cardano/utils.ts | 12 +- .../utxoManager/useSetCollateralId.tsx | 2 +- .../src/yoroi-wallets/hooks/index.ts | 32 +- .../src/yoroi-wallets/mocks/wallet.ts | 24 +- .../src/yoroi-wallets/types/other.ts | 1 + .../src/yoroi-wallets/types/yoroi.ts | 1 + .../src/yoroi-wallets/utils/utils.ts | 8 + .../messages/src/Catalyst/VotingBanner.json | 8 +- .../messages/src/Dashboard/Dashboard.json | 8 +- .../src/Dashboard/DashboardNavigator.json | 8 +- .../WalletSelectionScreen.json | 40 +- .../src/TxHistory/TxHistoryNavigator.json | 128 +- .../messages/src/WalletNavigator.json | 72 +- .../Staking/Governance/common/strings.json | 677 +++++++++ .../messages/src/i18n/global-messages.json | 1125 +++++++-------- .../messages/src/yoroi-wallets/auth/auth.json | 24 +- metro.config.js | 1 + packages/common/src/index.ts | 1 + .../src/translators/reactjs/hooks/index.ts | 1 + .../useMutationWithInvalidations.test.tsx | 43 + .../hooks/useMutationWithInvalidations.ts} | 6 +- .../common/src/translators/reactjs/index.ts | 1 + packages/staking/.dependency-cruiser.js | 449 ++++++ packages/staking/.gitignore | 71 + packages/staking/README.md | 3 + packages/staking/babel.config.js | 3 + packages/staking/jest.setup.js | 7 + packages/staking/package.json | 220 +++ packages/staking/scripts/flowgen.sh | 3 + packages/staking/src/catalyst/index.ts | 1 + packages/staking/src/catalyst/manager.test.ts | 30 + packages/staking/src/catalyst/manager.ts | 47 + packages/staking/src/governance/api.ts | 102 ++ packages/staking/src/governance/config.ts | 21 + .../staking/src/governance/helpers/index.ts | 1 + .../staking/src/governance/helpers/parsing.ts | 45 + packages/staking/src/governance/index.ts | 14 + .../staking/src/governance/manager.test.ts | 156 +++ packages/staking/src/governance/manager.ts | 198 +++ packages/staking/src/governance/mocks.ts | 23 + .../governance/translators/react/context.tsx | 24 + .../translators/react/hooks.test.tsx | 140 ++ .../src/governance/translators/react/hooks.ts | 114 ++ .../src/governance/translators/react/index.ts | 9 + packages/staking/src/governance/types.ts | 37 + packages/staking/src/index.ts | 2 + packages/staking/src/types.ts | 41 + packages/staking/tsconfig.build.json | 5 + packages/staking/tsconfig.json | 28 + .../reactjs/hooks/useSwapCreateOrder.tsx | 2 +- .../reactjs/hooks/useSwapSetSlippage.tsx | 2 +- yarn.lock | 1209 ++--------------- yoroi.code-workspace | 4 + 150 files changed, 6535 insertions(+), 2051 deletions(-) create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithHwModal/ConfirmTxWithHwModal.stories.tsx create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithHwModal/ConfirmTxWithHwModal.tsx create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithHwModal/index.ts create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithHwModal/strings.ts create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithOsModal/ConfirmTxWithOsModal.stories.tsx create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithOsModal/ConfirmTxWithOsModal.tsx create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithOsModal/index.ts create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithSpendingPasswordModal/ConfirmTxWithSpendingPasswordModal.stories.tsx create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithSpendingPasswordModal/ConfirmTxWithSpendingPasswordModal.tsx create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithSpendingPasswordModal/index.ts create mode 100644 apps/wallet-mobile/src/components/ConfirmTxWithSpendingPasswordModal/strings.ts create mode 100644 apps/wallet-mobile/src/components/Icon/ArrowRight.tsx create mode 100644 apps/wallet-mobile/src/components/Icon/Governance.tsx rename apps/wallet-mobile/src/{features/Swap/common => components}/ModalError/ModalError.stories.tsx (100%) rename apps/wallet-mobile/src/{features/Swap/common => components}/ModalError/ModalError.tsx (93%) create mode 100644 apps/wallet-mobile/src/components/ModalError/strings.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/GovernanceNavigator.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/Action/Action.stories.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/Action/Action.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/Action/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/LearnMoreLink/LearnMoreLink.stories.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/LearnMoreLink/LearnMoreLink.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/LearnMoreLink/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/SafeArea.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/helpers.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/mocks.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/navigation.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/common/strings.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/illustrations/BrokenImage.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/illustrations/SuccessTxImage.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/illustrations/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/types.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/ChangeVote/ChangeVoteScreen.stories.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/ChangeVote/ChangeVoteScreen.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/ChangeVote/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/ConfirmTx/ConfirmTxScreen.stories.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/ConfirmTx/ConfirmTxScreen.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/ConfirmTx/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/EnterDrepIdModal/EnterDrepIdModal.stories.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/EnterDrepIdModal/EnterDrepIdModal.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/EnterDrepIdModal/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/FailedTx/FailedTxScreen.stories.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/FailedTx/FailedTxScreen.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/FailedTx/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/Home/HomeScreen.stories.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/Home/HomeScreen.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/Home/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/SuccessTx/SuccessTxScreen.stories.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/SuccessTx/SuccessTxScreen.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/SuccessTx/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/WithdrawWarningModal/WithdrawWarningModal.tsx create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/WithdrawWarningModal/index.ts create mode 100644 apps/wallet-mobile/src/features/Staking/Governance/useCases/index.ts delete mode 100644 apps/wallet-mobile/src/yoroi-wallets/cardano/catalyst/catalystUtils.test.ts create mode 100644 apps/wallet-mobile/src/yoroi-wallets/cardano/constants/sanchonet/constants.ts create mode 100644 apps/wallet-mobile/translations/messages/src/features/Staking/Governance/common/strings.json create mode 100644 packages/common/src/translators/reactjs/hooks/index.ts create mode 100644 packages/common/src/translators/reactjs/hooks/useMutationWithInvalidations.test.tsx rename packages/{swap/src/utils/useMutationsWithInvalidations.tsx => common/src/translators/reactjs/hooks/useMutationWithInvalidations.ts} (89%) create mode 100644 packages/common/src/translators/reactjs/index.ts create mode 100644 packages/staking/.dependency-cruiser.js create mode 100644 packages/staking/.gitignore create mode 100644 packages/staking/README.md create mode 100644 packages/staking/babel.config.js create mode 100644 packages/staking/jest.setup.js create mode 100644 packages/staking/package.json create mode 100644 packages/staking/scripts/flowgen.sh create mode 100644 packages/staking/src/catalyst/index.ts create mode 100644 packages/staking/src/catalyst/manager.test.ts create mode 100644 packages/staking/src/catalyst/manager.ts create mode 100644 packages/staking/src/governance/api.ts create mode 100644 packages/staking/src/governance/config.ts create mode 100644 packages/staking/src/governance/helpers/index.ts create mode 100644 packages/staking/src/governance/helpers/parsing.ts create mode 100644 packages/staking/src/governance/index.ts create mode 100644 packages/staking/src/governance/manager.test.ts create mode 100644 packages/staking/src/governance/manager.ts create mode 100644 packages/staking/src/governance/mocks.ts create mode 100644 packages/staking/src/governance/translators/react/context.tsx create mode 100644 packages/staking/src/governance/translators/react/hooks.test.tsx create mode 100644 packages/staking/src/governance/translators/react/hooks.ts create mode 100644 packages/staking/src/governance/translators/react/index.ts create mode 100644 packages/staking/src/governance/types.ts create mode 100644 packages/staking/src/index.ts create mode 100644 packages/staking/src/types.ts create mode 100644 packages/staking/tsconfig.build.json create mode 100644 packages/staking/tsconfig.json diff --git a/apps/wallet-mobile/.env b/apps/wallet-mobile/.env index 9fe20e2b3c..bf3b4c923e 100644 --- a/apps/wallet-mobile/.env +++ b/apps/wallet-mobile/.env @@ -16,4 +16,4 @@ WALLET_2_MNEMONIC=abandon abandon abandon abandon abandon abandon abandon abando BANXA_TEST_WALLET=addr1qyfuspldlchc5kechfe5jzdrr9jms2s9w0tq4hggy9zgkhxssydveuc8xyx4zh27fwcmr62mraeezjwf24hzkyejwfmq7yptmd FRONTEND_FEE_ADDRESS_MAINNET=addr1q9ry6jfdgm0lcrtfpgwrgxg7qfahv80jlghhrthy6w8hmyjuw9ngccy937pm7yw0jjnxasm7hzxjrf8rzkqcj26788lqws5fke -FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km \ No newline at end of file +FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km diff --git a/apps/wallet-mobile/.env.nightly b/apps/wallet-mobile/.env.nightly index f01172cf46..24ff2b7c36 100644 --- a/apps/wallet-mobile/.env.nightly +++ b/apps/wallet-mobile/.env.nightly @@ -7,4 +7,4 @@ DISABLE_LOGBOX=true BANXA_TEST_WALLET=addr1qyfuspldlchc5kechfe5jzdrr9jms2s9w0tq4hggy9zgkhxssydveuc8xyx4zh27fwcmr62mraeezjwf24hzkyejwfmq7yptmd FRONTEND_FEE_ADDRESS_MAINNET=addr1q9ry6jfdgm0lcrtfpgwrgxg7qfahv80jlghhrthy6w8hmyjuw9ngccy937pm7yw0jjnxasm7hzxjrf8rzkqcj26788lqws5fke -FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km \ No newline at end of file +FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km diff --git a/apps/wallet-mobile/.env.production b/apps/wallet-mobile/.env.production index 729f3ffb33..44d32e4a7b 100644 --- a/apps/wallet-mobile/.env.production +++ b/apps/wallet-mobile/.env.production @@ -4,4 +4,4 @@ BUILD_VARIANT=PROD SENTRY_DSN=https://7f7c6cb60a6f429facd34f491dfc5133@o1138840.ingest.sentry.io/6783228 FRONTEND_FEE_ADDRESS_MAINNET=addr1q9ry6jfdgm0lcrtfpgwrgxg7qfahv80jlghhrthy6w8hmyjuw9ngccy937pm7yw0jjnxasm7hzxjrf8rzkqcj26788lqws5fke -FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km \ No newline at end of file +FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km diff --git a/apps/wallet-mobile/.env.staging b/apps/wallet-mobile/.env.staging index 65dcd903dc..052b636071 100644 --- a/apps/wallet-mobile/.env.staging +++ b/apps/wallet-mobile/.env.staging @@ -16,4 +16,4 @@ WALLET_2_MNEMONIC=abandon abandon abandon abandon abandon abandon abandon abando BANXA_TEST_WALLET=addr1qyfuspldlchc5kechfe5jzdrr9jms2s9w0tq4hggy9zgkhxssydveuc8xyx4zh27fwcmr62mraeezjwf24hzkyejwfmq7yptmd FRONTEND_FEE_ADDRESS_MAINNET=addr1q9ry6jfdgm0lcrtfpgwrgxg7qfahv80jlghhrthy6w8hmyjuw9ngccy937pm7yw0jjnxasm7hzxjrf8rzkqcj26788lqws5fke -FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km \ No newline at end of file +FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km diff --git a/apps/wallet-mobile/.storybook/storybook.requires.js b/apps/wallet-mobile/.storybook/storybook.requires.js index d2c35fc4b2..e656480dec 100644 --- a/apps/wallet-mobile/.storybook/storybook.requires.js +++ b/apps/wallet-mobile/.storybook/storybook.requires.js @@ -75,6 +75,9 @@ const getStories = () => { "./src/components/Checkbox/Checkbox.stories.tsx": require("../src/components/Checkbox/Checkbox.stories.tsx"), "./src/components/ConfirmTx/ConfirmTx.stories.tsx": require("../src/components/ConfirmTx/ConfirmTx.stories.tsx"), "./src/components/ConfirmTx/Dialog.stories.tsx": require("../src/components/ConfirmTx/Dialog.stories.tsx"), + "./src/components/ConfirmTxWithHwModal/ConfirmTxWithHwModal.stories.tsx": require("../src/components/ConfirmTxWithHwModal/ConfirmTxWithHwModal.stories.tsx"), + "./src/components/ConfirmTxWithOsModal/ConfirmTxWithOsModal.stories.tsx": require("../src/components/ConfirmTxWithOsModal/ConfirmTxWithOsModal.stories.tsx"), + "./src/components/ConfirmTxWithSpendingPasswordModal/ConfirmTxWithSpendingPasswordModal.stories.tsx": require("../src/components/ConfirmTxWithSpendingPasswordModal/ConfirmTxWithSpendingPasswordModal.stories.tsx"), "./src/components/DangerousActionModal/DangerousActionModal.stories.tsx": require("../src/components/DangerousActionModal/DangerousActionModal.stories.tsx"), "./src/components/ErrorBoundary/ErrorBoundary.stories.tsx": require("../src/components/ErrorBoundary/ErrorBoundary.stories.tsx"), "./src/components/ErrorModal/ErrorModal.stories.tsx": require("../src/components/ErrorModal/ErrorModal.stories.tsx"), @@ -86,6 +89,7 @@ const getStories = () => { "./src/components/LanguagePicker/LanguagePickerWarning.stories.tsx": require("../src/components/LanguagePicker/LanguagePickerWarning.stories.tsx"), "./src/components/Link/Link.stories.tsx": require("../src/components/Link/Link.stories.tsx"), "./src/components/LoadingOverlay/LoadingOverlay.stories.tsx": require("../src/components/LoadingOverlay/LoadingOverlay.stories.tsx"), + "./src/components/ModalError/ModalError.stories.tsx": require("../src/components/ModalError/ModalError.stories.tsx"), "./src/components/ModalScreenWrapper/ModalScreenWrapper.stories.tsx": require("../src/components/ModalScreenWrapper/ModalScreenWrapper.stories.tsx"), "./src/components/NftImageGallery/NftImageGallery.stories.tsx": require("../src/components/NftImageGallery/NftImageGallery.stories.tsx"), "./src/components/NftPreview/NftPreview.stories.tsx": require("../src/components/NftPreview/NftPreview.stories.tsx"), @@ -141,12 +145,19 @@ const getStories = () => { "./src/features/Settings/RemoveWallet/RemoveWalletScreen.stories.tsx": require("../src/features/Settings/RemoveWallet/RemoveWalletScreen.stories.tsx"), "./src/features/Settings/TermsOfService/TermsOfServiceScreen.stories.tsx": require("../src/features/Settings/TermsOfService/TermsOfServiceScreen.stories.tsx"), "./src/features/Settings/WalletSettings/WalletSettingsScreen.stories.tsx": require("../src/features/Settings/WalletSettings/WalletSettingsScreen.stories.tsx"), + "./src/features/Staking/Governance/common/Action/Action.stories.tsx": require("../src/features/Staking/Governance/common/Action/Action.stories.tsx"), + "./src/features/Staking/Governance/common/LearnMoreLink/LearnMoreLink.stories.tsx": require("../src/features/Staking/Governance/common/LearnMoreLink/LearnMoreLink.stories.tsx"), + "./src/features/Staking/Governance/useCases/ChangeVote/ChangeVoteScreen.stories.tsx": require("../src/features/Staking/Governance/useCases/ChangeVote/ChangeVoteScreen.stories.tsx"), + "./src/features/Staking/Governance/useCases/ConfirmTx/ConfirmTxScreen.stories.tsx": require("../src/features/Staking/Governance/useCases/ConfirmTx/ConfirmTxScreen.stories.tsx"), + "./src/features/Staking/Governance/useCases/EnterDrepIdModal/EnterDrepIdModal.stories.tsx": require("../src/features/Staking/Governance/useCases/EnterDrepIdModal/EnterDrepIdModal.stories.tsx"), + "./src/features/Staking/Governance/useCases/FailedTx/FailedTxScreen.stories.tsx": require("../src/features/Staking/Governance/useCases/FailedTx/FailedTxScreen.stories.tsx"), + "./src/features/Staking/Governance/useCases/Home/HomeScreen.stories.tsx": require("../src/features/Staking/Governance/useCases/Home/HomeScreen.stories.tsx"), + "./src/features/Staking/Governance/useCases/SuccessTx/SuccessTxScreen.stories.tsx": require("../src/features/Staking/Governance/useCases/SuccessTx/SuccessTxScreen.stories.tsx"), "./src/features/Swap/common/AmountCard/AmountCard.stories.tsx": require("../src/features/Swap/common/AmountCard/AmountCard.stories.tsx"), "./src/features/Swap/common/ButtonGroup/ButtonGroup.stories.tsx": require("../src/features/Swap/common/ButtonGroup/ButtonGroup.stories.tsx"), "./src/features/Swap/common/ConfirmRawTx/ConfirmRawTx.stories.tsx": require("../src/features/Swap/common/ConfirmRawTx/ConfirmRawTx.stories.tsx"), "./src/features/Swap/common/ConfirmWithSpendingPassword/ConfirmWithSpendingPassword.stories.tsx": require("../src/features/Swap/common/ConfirmWithSpendingPassword/ConfirmWithSpendingPassword.stories.tsx"), "./src/features/Swap/common/LiquidityPool/LiquidityPool.stories.tsx": require("../src/features/Swap/common/LiquidityPool/LiquidityPool.stories.tsx"), - "./src/features/Swap/common/ModalError/ModalError.stories.tsx": require("../src/features/Swap/common/ModalError/ModalError.stories.tsx"), "./src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.stories.tsx": require("../src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.stories.tsx"), "./src/features/Swap/common/ServiceUnavailable/ServiceUnavailable.stories.tsx": require("../src/features/Swap/common/ServiceUnavailable/ServiceUnavailable.stories.tsx"), "./src/features/Swap/useCases/ConfirmTxScreen/ConfirmTxScreen.stories.tsx": require("../src/features/Swap/useCases/ConfirmTxScreen/ConfirmTxScreen.stories.tsx"), diff --git a/apps/wallet-mobile/ios/Podfile.lock b/apps/wallet-mobile/ios/Podfile.lock index 7eff5f118c..c8ecaa4269 100644 --- a/apps/wallet-mobile/ios/Podfile.lock +++ b/apps/wallet-mobile/ios/Podfile.lock @@ -383,7 +383,7 @@ PODS: - react-native-config/App (= 1.5.1) - react-native-config/App (1.5.1): - React-Core - - react-native-haskell-shelley (5.1.3): + - react-native-haskell-shelley (6.0.0-alpha.2): - React - react-native-pager-view (6.2.0): - React-Core @@ -900,7 +900,7 @@ SPEC CHECKSUMS: react-native-background-timer: 17ea5e06803401a379ebf1f20505b793ac44d0fe react-native-ble-plx: f10240444452dfb2d2a13a0e4f58d7783e92d76e react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8 - react-native-haskell-shelley: 92544de7277b53cda2393528d530b526c81b48a6 + react-native-haskell-shelley: c01783e1181b8fc1fea715a288801056d70afc07 react-native-pager-view: 0ccb8bf60e2ebd38b1f3669fa3650ecce81db2df react-native-quick-base64: 62290829c619fbabca4c41cfec75ae759d08fc1c react-native-randombytes: b6677f7d495c27e9ee0dbd77ebc97b3c59173729 diff --git a/apps/wallet-mobile/package.json b/apps/wallet-mobile/package.json index e8314af352..9891babc3b 100644 --- a/apps/wallet-mobile/package.json +++ b/apps/wallet-mobile/package.json @@ -94,12 +94,12 @@ "@cardano-foundation/ledgerjs-hw-app-cardano": "^6.0.0", "@emurgo/cip14-js": "^3.0.1", "@emurgo/cip4-js": "1.0.7", - "@emurgo/cross-csl-core": "^3.1.0", - "@emurgo/cross-csl-mobile": "^3.1.0", - "@emurgo/csl-mobile-bridge": "5.1.3", + "@emurgo/cross-csl-core": "^4.0.0-alpha.1", + "@emurgo/cross-csl-mobile": "^4.0.0-alpha.1", + "@emurgo/csl-mobile-bridge": "6.0.0-alpha.2", "@emurgo/react-native-blockies-svg": "^0.0.2", "@emurgo/react-native-hid": "^5.15.6", - "@emurgo/yoroi-lib": "^0.11.0", + "@emurgo/yoroi-lib": "^0.14.1", "@formatjs/intl-datetimeformat": "^6.7.0", "@formatjs/intl-getcanonicallocales": "^2.1.0", "@formatjs/intl-locale": "^3.2.1", @@ -125,6 +125,7 @@ "@yoroi/banxa": "1.3.0", "@yoroi/common": "1.3.0", "@yoroi/links": "1.3.0", + "@yoroi/staking": "1.0.0", "@yoroi/swap": "1.3.0", "add": "2.0.6", "assert": "^2.0.0", @@ -202,7 +203,7 @@ "@babel/preset-react": "^7.16.7", "@babel/runtime": "^7.20.0", "@emurgo/cardano-serialization-lib-nodejs": "^9.1.4", - "@emurgo/cross-csl-nodejs": "^3.1.0", + "@emurgo/cross-csl-nodejs": "^4.0.0-alpha.1", "@formatjs/cli": "^6.1.0", "@formatjs/ts-transformer": "^3.13.0", "@react-navigation/devtools": "^6.0.13", diff --git a/apps/wallet-mobile/src/Catalyst/VotingBanner.tsx b/apps/wallet-mobile/src/Catalyst/VotingBanner.tsx index 18babe7f27..e51764d695 100644 --- a/apps/wallet-mobile/src/Catalyst/VotingBanner.tsx +++ b/apps/wallet-mobile/src/Catalyst/VotingBanner.tsx @@ -1,3 +1,4 @@ +import {catalystManagerMaker} from '@yoroi/staking' import React, {useEffect, useState} from 'react' import {defineMessages, useIntl} from 'react-intl' import {StyleSheet, TouchableOpacity, View} from 'react-native' @@ -8,7 +9,6 @@ import globalMessages, {confirmationMessages} from '../i18n/global-messages' import {isNightly} from '../legacy/config' import {Logger} from '../legacy/logging' import {COLORS} from '../theme' -import {isRegistrationOpen} from '../yoroi-wallets/cardano/catalyst/catalystUtils' import {useCanVote} from './hooks' import {InsufficientFundsModal} from './InsufficientFundsModal' @@ -42,7 +42,9 @@ export const VotingBanner = ({onPress, disabled}: Props) => { } } - setShowCatalystBanner((canVote && isRegistrationOpen(fundInfo)) || isNightly() || __DEV__) + const catalyst = catalystManagerMaker() + + setShowCatalystBanner((canVote && catalyst.isRegistrationOpen(fundInfo)) || isNightly() || __DEV__) } checkCatalystFundInfo() diff --git a/apps/wallet-mobile/src/Dashboard/Dashboard.tsx b/apps/wallet-mobile/src/Dashboard/Dashboard.tsx index 2a52824f98..1be5a78e8e 100644 --- a/apps/wallet-mobile/src/Dashboard/Dashboard.tsx +++ b/apps/wallet-mobile/src/Dashboard/Dashboard.tsx @@ -5,7 +5,13 @@ import React from 'react' import {defineMessages, useIntl} from 'react-intl' import {ActivityIndicator, RefreshControl, ScrollView, StyleSheet, View, ViewProps} from 'react-native' -import {Banner, Button, StatusBar} from '../components' +import {Banner, Button, StatusBar, useModal} from '../components' +import { + useGovernanceStrings, + useIsParticipatingInGovernance, + WithdrawWarningModal, +} from '../features/Staking/Governance' +import {useIsGovernanceFeatureEnabled} from '../features/Staking/Governance' import globalMessages from '../i18n/global-messages' import {Modal} from '../legacy/Modal' import {useWalletNavigation} from '../navigation' @@ -30,19 +36,40 @@ import {WithdrawStakingRewards} from './WithdrawStakingRewards' export const Dashboard = () => { const intl = useIntl() const navigateTo = useNavigateTo() + const governanceStrings = useGovernanceStrings() const wallet = useSelectedWallet() const {isLoading: isSyncing, sync} = useSync(wallet) const isOnline = useIsOnline(wallet) + const {openModal} = useModal() const balances = useBalances(wallet) const primaryAmount = Amounts.getAmount(balances, '') const {stakingInfo, refetch: refetchStakingInfo, error, isLoading} = useStakingInfo(wallet) + const isGovernanceFeatureEnabled = useIsGovernanceFeatureEnabled(wallet) const [showWithdrawalDialog, setShowWithdrawalDialog] = React.useState(false) const {resetToTxHistory} = useWalletNavigation() + const isParticipatingInGovernance = useIsParticipatingInGovernance(wallet) + const walletNavigateTo = useWalletNavigation() + + const handleOnParticipatePress = () => { + walletNavigateTo.navigateToGovernanceCentre({navigateToStakingOnSuccess: true}) + } + + const onWithdraw = () => { + if (isGovernanceFeatureEnabled && !isParticipatingInGovernance) { + openModal( + governanceStrings.withdrawWarningTitle, + , + ) + return + } + setShowWithdrawalDialog(true) + } + return ( @@ -77,7 +104,7 @@ export const Dashboard = () => { totalAdaSum={!isEmptyString(primaryAmount.quantity) ? new BigNumber(primaryAmount.quantity) : null} totalRewards={new BigNumber(stakingInfo.rewards)} totalDelegated={new BigNumber(stakingInfo.amount)} - onWithdraw={() => setShowWithdrawalDialog(true)} + onWithdraw={onWithdraw} disableWithdraw={wallet.isReadOnly} /> ) : ( @@ -85,7 +112,7 @@ export const Dashboard = () => { totalAdaSum={!isEmptyString(primaryAmount.quantity) ? new BigNumber(primaryAmount.quantity) : null} totalRewards={null} totalDelegated={null} - onWithdraw={() => setShowWithdrawalDialog(true)} + onWithdraw={onWithdraw} disableWithdraw /> )} diff --git a/apps/wallet-mobile/src/Dashboard/DashboardNavigator.tsx b/apps/wallet-mobile/src/Dashboard/DashboardNavigator.tsx index 74d518cd4a..a319e137b6 100644 --- a/apps/wallet-mobile/src/Dashboard/DashboardNavigator.tsx +++ b/apps/wallet-mobile/src/Dashboard/DashboardNavigator.tsx @@ -1,9 +1,11 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import {createStackNavigator} from '@react-navigation/stack' +import {GovernanceProvider} from '@yoroi/staking' import React from 'react' import {defineMessages, useIntl} from 'react-intl' import {SettingsButton} from '../components/Button' +import {useGovernanceManagerMaker} from '../features/Staking/Governance' import {DashboardRoutes, defaultStackNavigationOptions, useWalletNavigation} from '../navigation' import {useSelectedWallet} from '../SelectedWallet' import {DelegationConfirmation} from '../Staking' @@ -17,34 +19,38 @@ export const DashboardNavigator = () => { const walletName = useWalletName(wallet) const strings = useStrings() + const manager = useGovernanceManagerMaker() + return ( - - , + + + > + , + }} + /> - + - - + + + ) } diff --git a/apps/wallet-mobile/src/SelectedWallet/WalletSelection/WalletSelectionScreen.tsx b/apps/wallet-mobile/src/SelectedWallet/WalletSelection/WalletSelectionScreen.tsx index 6b273ca27f..d0fcfcc859 100644 --- a/apps/wallet-mobile/src/SelectedWallet/WalletSelection/WalletSelectionScreen.tsx +++ b/apps/wallet-mobile/src/SelectedWallet/WalletSelection/WalletSelectionScreen.tsx @@ -15,6 +15,7 @@ import {useWalletNavigation} from '../../navigation' import {COLORS} from '../../theme' import {useWalletManager} from '../../WalletManager' import * as HASKELL_SHELLEY from '../../yoroi-wallets/cardano/constants/mainnet/constants' +import * as SANCHONET from '../../yoroi-wallets/cardano/constants/sanchonet/constants' import * as HASKELL_SHELLEY_TESTNET from '../../yoroi-wallets/cardano/constants/testnet/constants' import {InvalidState, NetworkError} from '../../yoroi-wallets/cardano/errors' import {isJormungandr} from '../../yoroi-wallets/cardano/networks' @@ -89,6 +90,8 @@ export const WalletSelectionScreen = () => { + + @@ -197,6 +200,25 @@ const OnlyNightlyShelleyTestnetButton = () => { ) } +const OnlyNightlyShelleySanchonetButton = () => { + const navigation = useNavigation() + const strings = useStrings() + + if (!isNightly() && !__DEV__) return null + + const handleOnPress = () => { + navigation.navigate('new-wallet', { + screen: 'choose-create-restore', + params: { + networkId: SANCHONET.NETWORK_ID, + walletImplementationId: SANCHONET.WALLET_IMPLEMENTATION_ID, + }, + }) + } + + return