Skip to content

Commit

Permalink
fix: pool create error
Browse files Browse the repository at this point in the history
  • Loading branch information
junjieit committed Oct 25, 2024
1 parent 1f7d016 commit 4b895ec
Show file tree
Hide file tree
Showing 26 changed files with 766 additions and 457 deletions.
2 changes: 1 addition & 1 deletion packages/dodoex-widgets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dodoex/widgets",
"version": "3.0.0-taiko.23",
"version": "3.0.0-taiko.24",
"description": "DODO Widgets",
"source": "src/index.tsx",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ export function TokenCard({
const { gotoBuyToken } = useUserOptions();
let showBuyTokenBtn = gotoBuyToken && balance && amt && balance.lt(amt);

const showInputNumber = !!onInputChange || !!inputReadonlyTooltip;

return (
<Box
sx={{
minHeight: 133,
minHeight: showInputNumber ? 133 : 'auto',
padding: theme.spacing(20, 20, 24),
borderRadius: 12,
overflow: 'hidden',
Expand Down Expand Up @@ -234,60 +236,61 @@ export function TokenCard({
/>
</Box>

{readOnly && inputReadonlyTooltip ? (
<TooltipToast title={inputReadonlyTooltip} arrow={false}>
<Box>
<NumberInput
value={amt}
readOnly
withClear
sx={{
mt: 12,
...inputSx,
}}
/>
</Box>
</TooltipToast>
) : (
<NumberInput
value={amt}
onFocus={onInputFocus}
onChange={
onInputChange
? (v) => {
onInputChange(v);
setPercentage(0);
}
: undefined
}
readOnly={readOnly}
withClear
suffix={
showBuyTokenBtn ? (
<Button
variant={Button.Variant.tag}
backgroundColor={theme.palette.background.paperDarkContrast}
{showInputNumber &&
(readOnly && inputReadonlyTooltip ? (
<TooltipToast title={inputReadonlyTooltip} arrow={false}>
<Box>
<NumberInput
value={amt}
readOnly
withClear
sx={{
fontSize: 12,
}}
onClick={(evt) => {
evt.stopPropagation();
gotoBuyToken?.({
token: token as TokenInfo,
account: account as string,
});
mt: 12,
...inputSx,
}}
>
<Trans>Buy</Trans>
</Button>
) : undefined
}
typography={inputTypography}
sx={{
mt: 12,
}}
/>
)}
/>
</Box>
</TooltipToast>
) : (
<NumberInput
value={amt}
onFocus={onInputFocus}
onChange={
onInputChange
? (v) => {
onInputChange(v);
setPercentage(0);
}
: undefined
}
readOnly={readOnly}
withClear
suffix={
showBuyTokenBtn ? (
<Button
variant={Button.Variant.tag}
backgroundColor={theme.palette.background.paperDarkContrast}
sx={{
fontSize: 12,
}}
onClick={(evt) => {
evt.stopPropagation();
gotoBuyToken?.({
token: token as TokenInfo,
account: account as string,
});
}}
>
<Trans>Buy</Trans>
</Button>
) : undefined
}
typography={inputTypography}
sx={{
mt: 12,
}}
/>
))}

{!readOnly && showPercentage ? (
<PercentageSelectButtonGroup
Expand Down
4 changes: 2 additions & 2 deletions packages/dodoex-widgets/src/components/Widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ function InitStatus(props: PropsWithChildren<WidgetProps>) {
const { widgetRef } = useUserOptions();

if (props.noUI) {
return <LangProvider locale={props.locale}>{props.children}</LangProvider>;
return <LangProvider {...props}>{props.children}</LangProvider>;
}

return (
<LangProvider locale={props.locale}>
<LangProvider {...props}>
<Box
sx={{
width,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { useUserOptions } from '../../components/UserOptionsProvider';

export function useWalletInfo() {
const { account, chainId } = useWeb3React();
const defaultChainId = useUserOptions((state) => state.defaultChainId);
const { onlyChainId, defaultChainId } = useUserOptions();

return {
account,
chainId: (chainId || defaultChainId || 1) as ChainId,
chainId: (chainId || onlyChainId || defaultChainId || 1) as ChainId,
connectedChainId: chainId,
defaultChainId,
onlyChainId,
};
}
2 changes: 1 addition & 1 deletion packages/dodoex-widgets/src/hooks/Swap/useExecuteSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function useExecuteSwap() {
},
);
},
[account, chainId],
[account, submission],
);

return execute;
Expand Down
9 changes: 7 additions & 2 deletions packages/dodoex-widgets/src/hooks/Token/useTokenList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import useTokenListFetchBalance from './useTokenListFetchBalance';

jest.mock('../../components/UserOptionsProvider', () => ({
useUserOptions: jest.fn((fn) => {
return fn({
if (typeof fn === 'function') {
return fn({
defaultChainId: 1,
});
}
return {
defaultChainId: 1,
});
};
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ jest.mock('@tanstack/react-query', () => ({

jest.mock('../../components/UserOptionsProvider', () => ({
useUserOptions: jest.fn((fn) => {
return fn({
if (typeof fn === 'function') {
return fn({
defaultChainId: 1,
});
}
return {
defaultChainId: 1,
});
};
}),
}));

Expand Down
2 changes: 1 addition & 1 deletion packages/dodoex-widgets/src/locales/en-US.js

Large diffs are not rendered by default.

Loading

0 comments on commit 4b895ec

Please sign in to comment.