From 573bdaee50cc2d0d793a318b2b7142a0d2526e97 Mon Sep 17 00:00:00 2001 From: Angel Castillo Date: Thu, 21 Mar 2024 17:50:48 +0800 Subject: [PATCH] feat: add custom submit endpoint option --- .../src/assets/icons/pause-icon.component.svg | 9 ++ .../src/assets/icons/play-icon.component.svg | 14 ++ .../dapp/components/DappTransactionFail.tsx | 9 +- .../dapp/components/Layout.module.scss | 1 + .../MultiDelegationStakingPopup.tsx | 12 +- .../hooks/__tests__/useWalletManager.test.tsx | 2 +- .../src/hooks/index.ts | 2 + .../src/hooks/useAppInit.ts | 11 ++ .../src/hooks/useCustomSubmitApi.ts | 26 ++++ .../src/hooks/useWalletManager.ts | 50 ++++++- .../src/lib/scripts/background/config.ts | 11 +- .../src/lib/scripts/background/wallet.ts | 2 +- .../src/lib/scripts/types/storage.ts | 1 + .../src/lib/translations/en.json | 15 ++ .../slices/blockchain-provider-slice.ts | 1 + .../src/types/local-storage.ts | 6 + .../components/Form/Form.module.scss | 2 +- .../send-transaction/components/Form/Form.tsx | 12 +- .../components/SendTransaction.tsx | 9 +- .../components/TransactionFail.tsx | 14 +- .../TransactionSuccessView.module.scss | 4 + .../components/CustomSubmitApiDrawer.tsx | 128 ++++++++++++++++++ .../components/SettingsLayout.module.scss | 28 ++++ .../components/SettingsWalletBase.tsx | 28 +++- .../components/MultiDelegationStaking.tsx | 10 -- .../staking/components/StakingContainer.tsx | 12 +- .../browser-extension-wallet/webpack-utils.js | 4 +- packages/cardano/src/wallet/lib/providers.ts | 33 ++++- packages/common/src/analytics/types.ts | 3 + .../icons/red-warning-icon.component.svg | 3 + .../Banner/WarningBanner.module.scss | 7 + .../ui/components/Banner/WarningBanner.tsx | 12 ++ .../common/src/ui/components/Banner/index.ts | 1 + .../src/features/Drawer/TransactionFail.tsx | 19 ++- .../src/features/i18n/translations/en.ts | 2 + packages/staking/src/features/i18n/types.ts | 1 + .../outside-handles-provider/types.ts | 1 + 37 files changed, 455 insertions(+), 50 deletions(-) create mode 100644 apps/browser-extension-wallet/src/assets/icons/pause-icon.component.svg create mode 100644 apps/browser-extension-wallet/src/assets/icons/play-icon.component.svg create mode 100644 apps/browser-extension-wallet/src/hooks/useCustomSubmitApi.ts create mode 100644 apps/browser-extension-wallet/src/views/browser-view/features/settings/components/CustomSubmitApiDrawer.tsx create mode 100644 packages/common/src/ui/assets/icons/red-warning-icon.component.svg create mode 100644 packages/common/src/ui/components/Banner/WarningBanner.module.scss create mode 100644 packages/common/src/ui/components/Banner/WarningBanner.tsx diff --git a/apps/browser-extension-wallet/src/assets/icons/pause-icon.component.svg b/apps/browser-extension-wallet/src/assets/icons/pause-icon.component.svg new file mode 100644 index 000000000..f458660af --- /dev/null +++ b/apps/browser-extension-wallet/src/assets/icons/pause-icon.component.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/apps/browser-extension-wallet/src/assets/icons/play-icon.component.svg b/apps/browser-extension-wallet/src/assets/icons/play-icon.component.svg new file mode 100644 index 000000000..6036aa2de --- /dev/null +++ b/apps/browser-extension-wallet/src/assets/icons/play-icon.component.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/apps/browser-extension-wallet/src/features/dapp/components/DappTransactionFail.tsx b/apps/browser-extension-wallet/src/features/dapp/components/DappTransactionFail.tsx index 2db3ec9a9..8eada5728 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/DappTransactionFail.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/DappTransactionFail.tsx @@ -1,21 +1,25 @@ import React, { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { Button, PostHogAction } from '@lace/common'; +import { Button, PostHogAction, WarningBanner } from '@lace/common'; import Fail from '../../../assets/icons/exclamation-circle.svg'; import styles from './Layout.module.scss'; import { Image } from 'antd'; import { useAnalyticsContext } from '@providers'; import { TX_CREATION_TYPE_KEY, TxCreationType } from '@providers/AnalyticsProvider/analyticsTracker'; +import { useWalletStore } from '@stores'; +import { useCustomSubmitApi } from '@hooks'; export const DappTransactionFail = (): React.ReactElement => { const { t } = useTranslation(); const analytics = useAnalyticsContext(); + const { environmentName } = useWalletStore(); const onClose = async () => { await analytics?.sendEventToPostHog(PostHogAction.SendSomethingWentWrongCancelClick, { [TX_CREATION_TYPE_KEY]: TxCreationType.External }); window.close(); }; + const { getCustomSubmitApiForNetwork } = useCustomSubmitApi(); useEffect(() => { analytics?.sendEventToPostHog(PostHogAction.SendSomethingWentWrongView, { @@ -33,6 +37,9 @@ export const DappTransactionFail = (): React.ReactElement => {
{t('dapp.sign.failure.description')}
+ {getCustomSubmitApiForNetwork(environmentName).status && ( + + )}