Skip to content

Commit

Permalink
refactor: simplify component structure and update PayWithAsset import…
Browse files Browse the repository at this point in the history
… paths
  • Loading branch information
ap211unitech committed Jan 30, 2025
1 parent 852fbda commit 22d1b20
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 27 deletions.
36 changes: 17 additions & 19 deletions packages/apps/src/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,23 @@ function Content ({ className }: Props): React.ReactElement<Props> {
<Suspense fallback='...'>
<ErrorBoundary trigger={name}>
<TabsCtx.Provider value={{ icon, text }}>
<>
{missingApis.length
? (
<NotFound
basePath={`/${name}`}
location={location}
missingApis={missingApis}
onStatusChange={queueAction}
/>
)
: (
<Component
basePath={`/${name}`}
location={location}
onStatusChange={queueAction}
/>
)
}
</>
{missingApis.length
? (
<NotFound
basePath={`/${name}`}
location={location}
missingApis={missingApis}
onStatusChange={queueAction}
/>
)
: (
<Component
basePath={`/${name}`}
location={location}
onStatusChange={queueAction}
/>
)
}
</TabsCtx.Provider>
</ErrorBoundary>
</Suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Dropdown } from '@polkadot/react-components';
import { useApi, usePayWithAsset } from '@polkadot/react-hooks';
import { BN } from '@polkadot/util';

import { useTranslation } from '../translate.js';
import { useTranslation } from './translate.js';

const PayWithAsset = () => {
const { t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export { default as Output } from './Output.js';
export { default as ParaLink } from './ParaLink.js';
export { default as Password } from './Password.js';
export { default as PasswordStrength } from './PasswordStrength.js';
export { default as PayWithAsset } from './PayWithAsset/index.js';
export { default as PayWithAsset } from './PayWithAsset.js';
export { default as Popup } from './Popup/index.js';
export { default as Progress } from './Progress.js';
export { default as ProgressBar } from './ProgressBar.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/src/modals/Transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import InputBalance from '../InputBalance.js';
import MarkError from '../MarkError.js';
import MarkWarning from '../MarkWarning.js';
import Modal from '../Modal/index.js';
import PayWithAsset from '../PayWithAsset/index.js';
import PayWithAsset from '../PayWithAsset.js';
import { styled } from '../styled.js';
import Toggle from '../Toggle.js';
import { useTranslation } from '../translate.js';
Expand Down
6 changes: 1 addition & 5 deletions packages/react-hooks/src/ctx/PayWithAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ export const PayWithAssetCtx = React.createContext<PayWithAsset>(EMPTY_STATE);
export function PayWithAssetCtxRoot ({ children }: Props): React.ReactElement<Props> {
const { isApiReady } = useApi();

if (!isApiReady) {
return <>{children}</>;
}

return <PayWithAssetProvider>{children}</PayWithAssetProvider>;
return isApiReady ? <PayWithAssetProvider>{children}</PayWithAssetProvider> : <>{children}</>;
}

function PayWithAssetProvider ({ children }: Props): React.ReactElement<Props> {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-signer/src/TxSigned.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ async function signAndSend (queueSetTxStatus: QueueTxMessageSetStatus, currentIt
await fakeSignForChopsticks(api, tx, pairOrAddress as string);
}

console.info('sending', tx.toHex());

queueSetTxStatus(currentItem.id, 'sending');

const unsubscribe = await tx.send(handleTxResults('signAndSend', queueSetTxStatus, currentItem, (): void => {
Expand Down

0 comments on commit 22d1b20

Please sign in to comment.