Skip to content

Commit

Permalink
Update tradeHook.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming committed Dec 26, 2024
1 parent b67cde1 commit ea8dd56
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/kit/src/views/Market/components/tradeHook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
Expand All @@ -237,7 +237,7 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => {
return undefined;
}
} catch (error) {
await new Promise<void>((resolve, reject) => {
const isCreated = await new Promise<boolean>((resolve) => {
const dialog = Dialog.show({
title: intl.formatMessage({
id: ETranslations.wallet_no_address,
Expand All @@ -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: (
<CreateAddressDialogContent
onCreate={async () => {
resolve();
resolve(true);
await dialog.close({ flag: 'created' });
Toast.success({
title: intl.formatMessage({
Expand All @@ -277,6 +277,10 @@ export const useMarketTradeActions = (token: IMarketTokenDetail | null) => {
});
}

if (!isCreated) {
return undefined;
}

return {
activeAccount,
networkId,
Expand Down

0 comments on commit ea8dd56

Please sign in to comment.