diff --git a/packages/kit/src/views/Market/components/tradeHook.tsx b/packages/kit/src/views/Market/components/tradeHook.tsx index 8282fb6f9fc..a1e74650e9d 100644 --- a/packages/kit/src/views/Market/components/tradeHook.tsx +++ b/packages/kit/src/views/Market/components/tradeHook.tsx @@ -209,10 +209,6 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => { if (!networkId) { throw new Error(`cannot find NetworkId ${networkId || ''}`); } - const deriveType = - await backgroundApiProxy.serviceNetwork.getGlobalDeriveTypeOfNetwork({ - networkId, - }); try { if ( accountUtils.isWatchingAccount({ @@ -223,6 +219,10 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => { return undefined; } if (activeAccount.account?.indexedAccountId) { + const deriveType = + await backgroundApiProxy.serviceNetwork.getGlobalDeriveTypeOfNetwork({ + networkId, + }); await backgroundApiProxy.serviceAccount.getNetworkAccount({ accountId: undefined, indexedAccountId: activeAccount.account?.indexedAccountId, @@ -237,7 +237,7 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => { return undefined; } } catch (error) { - await new Promise((resolve, reject) => { + const isCreated = await new Promise((resolve) => { const dialog = Dialog.show({ title: intl.formatMessage({ id: ETranslations.wallet_no_address, @@ -255,13 +255,13 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => { showFooter: false, onClose: (extra) => { if (extra?.flag !== 'created') { - reject(new Error('failed to create address')); + resolve(false); } }, renderContent: ( { - resolve(); + resolve(true); await dialog.close({ flag: 'created' }); Toast.success({ title: intl.formatMessage({ @@ -277,6 +277,10 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => { }); } + if (!isCreated) { + return undefined; + } + return { activeAccount, networkId,