Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace invalid Lightning Network routes. (OK-35333) #6587

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/kit-bg/src/providers/ProviderApiWebln.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ class ProviderApiWebln extends ProviderApiBase {
case 'login': {
return this.backgroundApi.serviceDApp.openModal({
request,
screens: [EModalRoutes.SendModal, EModalSendRoutes.LnurlAuth],
screens: [
EModalRoutes.SignatureConfirmModal,
EModalSignatureConfirmRoutes.LnurlAuth,
],
params: {
networkId,
accountId,
Expand All @@ -282,7 +285,10 @@ class ProviderApiWebln extends ProviderApiBase {
case 'payRequest': {
return this.backgroundApi.serviceDApp.openModal({
request,
screens: [EModalRoutes.SendModal, EModalSendRoutes.LnurlPayRequest],
screens: [
EModalRoutes.SignatureConfirmModal,
EModalSignatureConfirmRoutes.LnurlPayRequest,
],
params: {
networkId,
accountId,
Expand All @@ -300,7 +306,10 @@ class ProviderApiWebln extends ProviderApiBase {
case 'withdrawRequest': {
return this.backgroundApi.serviceDApp.openModal({
request,
screens: [EModalRoutes.SendModal, EModalSendRoutes.LnurlWithdraw],
screens: [
EModalRoutes.SignatureConfirmModal,
EModalSignatureConfirmRoutes.LnurlWithdraw,
],
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
params: {
networkId,
accountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import DappOpenModalPage from '@onekeyhq/kit/src/views/DAppConnection/pages/Dapp
import { OneKeyError } from '@onekeyhq/shared/src/errors';
import { ETranslations } from '@onekeyhq/shared/src/locale';
import type {
EModalSendRoutes,
IModalSendParamList,
EModalSignatureConfirmRoutes,
IModalSignatureConfirmParamList,
} from '@onekeyhq/shared/src/routes';
import { EDAppModalPageStatus } from '@onekeyhq/shared/types/dappConnection';

Expand All @@ -35,11 +35,18 @@ function LnurlAuthModal() {
const intl = useIntl();
const navigation = useAppNavigation();
const route =
useRoute<RouteProp<IModalSendParamList, EModalSendRoutes.LnurlAuth>>();
useRoute<
RouteProp<
IModalSignatureConfirmParamList,
EModalSignatureConfirmRoutes.LnurlAuth
>
>();
const routeParams = route.params;
const { isSendFlow } = routeParams;
const dAppQuery =
useDappQuery<IModalSendParamList[EModalSendRoutes.LnurlAuth]>();
useDappQuery<
IModalSignatureConfirmParamList[EModalSignatureConfirmRoutes.LnurlAuth]
>();
const { $sourceInfo } = dAppQuery;
const { accountId, networkId, lnurlDetails } = isSendFlow
? routeParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import type { ITransferInfo } from '@onekeyhq/kit-bg/src/vaults/types';
import { OneKeyError } from '@onekeyhq/shared/src/errors';
import { ETranslations } from '@onekeyhq/shared/src/locale';
import type {
EModalSendRoutes,
IModalSendParamList,
EModalSignatureConfirmRoutes,
IModalSignatureConfirmParamList,
} from '@onekeyhq/shared/src/routes';
import { EDAppModalPageStatus } from '@onekeyhq/shared/types/dappConnection';
import type { ILNURLPaymentInfo } from '@onekeyhq/shared/types/lightning';
Expand All @@ -41,11 +41,16 @@ function LnurlPayRequestModal() {
const intl = useIntl();
const route =
useRoute<
RouteProp<IModalSendParamList, EModalSendRoutes.LnurlPayRequest>
RouteProp<
IModalSignatureConfirmParamList,
EModalSignatureConfirmRoutes.LnurlPayRequest
>
>();
const routeParams = route.params;
const dAppQuery =
useDappQuery<IModalSendParamList[EModalSendRoutes.LnurlPayRequest]>();
useDappQuery<
IModalSignatureConfirmParamList[EModalSignatureConfirmRoutes.LnurlPayRequest]
>();
const { $sourceInfo } = dAppQuery;
const { accountId, networkId, lnurlDetails, transfersInfo } =
routeParams.isSendFlow ? routeParams : dAppQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import DappOpenModalPage from '@onekeyhq/kit/src/views/DAppConnection/pages/Dapp
import { OneKeyError } from '@onekeyhq/shared/src/errors';
import { ETranslations } from '@onekeyhq/shared/src/locale';
import type {
EModalSendRoutes,
IModalSendParamList,
EModalSignatureConfirmRoutes,
IModalSignatureConfirmParamList,
} from '@onekeyhq/shared/src/routes';
import { EDAppModalPageStatus } from '@onekeyhq/shared/types/dappConnection';

Expand All @@ -34,12 +34,19 @@ import type { RouteProp } from '@react-navigation/core';
function LnurlWithdrawModal() {
const intl = useIntl();
const route =
useRoute<RouteProp<IModalSendParamList, EModalSendRoutes.LnurlWithdraw>>();
useRoute<
RouteProp<
IModalSignatureConfirmParamList,
EModalSignatureConfirmRoutes.LnurlWithdraw
>
>();

const routeParams = route.params;
const { isSendFlow } = routeParams;
const dAppQuery =
useDappQuery<IModalSendParamList[EModalSendRoutes.LnurlWithdraw]>();
useDappQuery<
IModalSignatureConfirmParamList[EModalSignatureConfirmRoutes.LnurlWithdraw]
>();
const { $sourceInfo } = dAppQuery;
const { accountId, networkId, lnurlDetails } = isSendFlow
? routeParams
Expand Down
41 changes: 1 addition & 40 deletions packages/kit/src/views/Send/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,6 @@ const SendReplaceTx = LazyLoadPage(
),
);

const LnurlPayRequestModal = LazyLoadPage(
() =>
import(
'@onekeyhq/kit/src/views/LightningNetwork/pages/Send/LnurlPayRequestModal'
),
);

const LnurlWithdrawModal = LazyLoadPage(
() =>
import(
'@onekeyhq/kit/src/views/LightningNetwork/pages/Send/LnurlWithdrawModal'
),
);

const LnurlAuthModal = LazyLoadPage(
() =>
import(
'@onekeyhq/kit/src/views/LightningNetwork/pages/Send/LnurlAuthModal'
),
);

const WeblnSendPaymentModal = LazyLoadPage(
() =>
import(
'@onekeyhq/kit/src/views/LightningNetwork/pages/Webln/WeblnSendPaymentModal'
),
);

const TokenSelector = LazyLoadPage(
() => import('@onekeyhq/kit/src/views/AssetSelector/pages/TokenSelector'),
);
Expand Down Expand Up @@ -94,18 +66,7 @@ export const ModalSendStack: IModalFlowNavigatorConfig<
name: EModalSendRoutes.SendReplaceTx,
component: SendReplaceTx,
},
{
name: EModalSendRoutes.LnurlPayRequest,
component: LnurlPayRequestModal,
},
{
name: EModalSendRoutes.LnurlWithdraw,
component: LnurlWithdrawModal,
},
{
name: EModalSendRoutes.LnurlAuth,
component: LnurlAuthModal,
},
// TODO: The following two pages seem to not be referenced anywhere, consider removing them
{
name: EModalSendRoutes.SendSelectToken,
component: TokenSelector,
Expand Down
38 changes: 0 additions & 38 deletions packages/shared/src/routes/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { IEncodedTx, IUnsignedTxPro } from '@onekeyhq/core/src/types';
import type {
IAccountDeriveInfo,
IAccountDeriveTypes,
ITransferInfo,
ITransferPayload,
} from '@onekeyhq/kit-bg/src/vaults/types';
import type { IDappSourceInfo } from '@onekeyhq/shared/types';
Expand All @@ -13,11 +12,6 @@ import type { ITokenSelectorParamList } from './assetSelector';
import type { INetworkAccount } from '../../types/account';
import type { EDeriveAddressActionType } from '../../types/address';
import type { IAccountHistoryTx } from '../../types/history';
import type {
ILNURLAuthServiceResponse,
ILNURLPayServiceResponse,
ILNURLWithdrawServiceResponse,
} from '../../types/lightning';
import type { EReplaceTxType, ISendTxOnSuccessData } from '../../types/tx';

export enum EModalSendRoutes {
Expand All @@ -29,12 +23,6 @@ export enum EModalSendRoutes {
SendReplaceTx = 'SendReplaceTx',
SendSelectToken = 'SendSelectToken',
SendSelectDeriveAddress = 'SendSelectDeriveAddress',

// Lightning Network
LnurlPayRequest = 'LnurlPayRequest',
LnurlWithdraw = 'LnurlWithdraw',
LnurlAuth = 'LnurlAuth',
WeblnSendPayment = 'WeblnSendPayment',
}

export type IModalSendParamList = {
Expand Down Expand Up @@ -88,32 +76,6 @@ export type IModalSendParamList = {
historyTx: IAccountHistoryTx;
onSuccess?: (data: ISendTxOnSuccessData[]) => void;
};

// Lightning Network
[EModalSendRoutes.LnurlPayRequest]: {
networkId: string;
accountId: string;
transfersInfo: ITransferInfo[];
lnurlDetails: ILNURLPayServiceResponse;
sourceInfo?: IDappSourceInfo;
onSuccess?: (txs: ISendTxOnSuccessData[]) => void;
onFail?: (error: Error) => void;
onCancel?: () => void;
isSendFlow?: boolean;
};
[EModalSendRoutes.LnurlWithdraw]: {
networkId: string;
accountId: string;
lnurlDetails: ILNURLWithdrawServiceResponse;
sourceInfo?: IDappSourceInfo;
isSendFlow?: boolean;
};
[EModalSendRoutes.LnurlAuth]: {
networkId: string;
accountId: string;
lnurlDetails: ILNURLAuthServiceResponse;
isSendFlow: boolean;
};
[EModalSendRoutes.SendSelectDeriveAddress]: {
networkId: string;
indexedAccountId: string;
Expand Down
Loading