Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24de450ff2 | ||
|
|
7da64c2183 | ||
|
|
cd30c9c7d9 | ||
|
|
414e38afec | ||
|
|
e93850484b |
@@ -215,10 +215,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"validators": [
|
"validators": [
|
||||||
"http://validator.v4dev4.dydx.exchange"
|
"https://validator.v4dev4.dydx.exchange"
|
||||||
],
|
],
|
||||||
"0xsquid": "https://testnet.api.0xsquid.com",
|
"0xsquid": "https://testnet.api.0xsquid.com",
|
||||||
"nobleValidator": "https://noble-testnet-rpc.polkachu.com/"
|
"nobleValidator": "https://noble-testnet-rpc.polkachu.com/",
|
||||||
|
"faucet": "https://faucet.v4dev4.dydx.exchange"
|
||||||
},
|
},
|
||||||
"links": {
|
"links": {
|
||||||
"tos": "https://dydx.exchange/v4-terms",
|
"tos": "https://dydx.exchange/v4-terms",
|
||||||
@@ -473,7 +474,7 @@
|
|||||||
"apps": {
|
"apps": {
|
||||||
"ios": {
|
"ios": {
|
||||||
"minimalVersion": "1.0",
|
"minimalVersion": "1.0",
|
||||||
"build":40000,
|
"build": 40000,
|
||||||
"url": "https://apps.apple.com/app/dydx/id1564787350"
|
"url": "https://apps.apple.com/app/dydx/id1564787350"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,5 @@ export const DetachedScrollableSection = styled.section`
|
|||||||
|
|
||||||
export const AttachedExpandingSection = styled.section`
|
export const AttachedExpandingSection = styled.section`
|
||||||
${layoutMixins.contentSectionAttached}
|
${layoutMixins.contentSectionAttached}
|
||||||
${layoutMixins.expandingColumnWithHeader}
|
|
||||||
gap: var(--border-width);
|
gap: var(--border-width);
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -33,17 +33,20 @@ import {
|
|||||||
|
|
||||||
import { useAsyncList } from 'react-stately';
|
import { useAsyncList } from 'react-stately';
|
||||||
|
|
||||||
import { useBreakpoints } from '@/hooks';
|
import { useBreakpoints, useStringGetter } from '@/hooks';
|
||||||
import { MediaQueryKeys } from '@/hooks/useBreakpoints';
|
import { MediaQueryKeys } from '@/hooks/useBreakpoints';
|
||||||
|
|
||||||
import { Checkbox } from '@/components/Checkbox';
|
|
||||||
|
|
||||||
import { breakpoints } from '@/styles';
|
import { breakpoints } from '@/styles';
|
||||||
import { layoutMixins } from '@/styles/layoutMixins';
|
import { layoutMixins } from '@/styles/layoutMixins';
|
||||||
|
import { CaretIcon } from '@/icons';
|
||||||
|
|
||||||
|
import { STRING_KEYS } from '@/constants/localization';
|
||||||
|
|
||||||
|
import { MustBigNumber } from '@/lib/numbers';
|
||||||
|
|
||||||
import { Icon, IconName } from './Icon';
|
import { Icon, IconName } from './Icon';
|
||||||
import { Tag } from './Tag';
|
import { Tag } from './Tag';
|
||||||
import { MustBigNumber } from '@/lib/numbers';
|
import { Button } from './Button';
|
||||||
|
|
||||||
export { TableCell } from './Table/TableCell';
|
export { TableCell } from './Table/TableCell';
|
||||||
export { TableColumnHeader } from './Table/TableColumnHeader';
|
export { TableColumnHeader } from './Table/TableColumnHeader';
|
||||||
@@ -65,7 +68,7 @@ export type TableItem<TableRowData> = {
|
|||||||
onSelect?: (key: TableRowData) => void;
|
onSelect?: (key: TableRowData) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ColumnDef<TableRowData extends object> = {
|
type ColumnDef<TableRowData extends object> = {
|
||||||
columnKey: string;
|
columnKey: string;
|
||||||
label: React.ReactNode;
|
label: React.ReactNode;
|
||||||
tag?: React.ReactNode;
|
tag?: React.ReactNode;
|
||||||
@@ -80,7 +83,7 @@ export type ColumnDef<TableRowData extends object> = {
|
|||||||
width?: ColumnSize;
|
width?: ColumnSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ElementProps<TableRowData extends object | CustomRowConfig, TableRowKey extends Key> = {
|
export type ElementProps<TableRowData extends object | CustomRowConfig, TableRowKey extends Key> = {
|
||||||
label?: string;
|
label?: string;
|
||||||
columns: ColumnDef<TableRowData>[];
|
columns: ColumnDef<TableRowData>[];
|
||||||
data: TableRowData[];
|
data: TableRowData[];
|
||||||
@@ -92,6 +95,7 @@ type ElementProps<TableRowData extends object | CustomRowConfig, TableRowKey ext
|
|||||||
selectionBehavior?: 'replace' | 'toggle';
|
selectionBehavior?: 'replace' | 'toggle';
|
||||||
onRowAction?: (key: TableRowKey, row: TableRowData) => void;
|
onRowAction?: (key: TableRowKey, row: TableRowData) => void;
|
||||||
slotEmpty?: React.ReactNode;
|
slotEmpty?: React.ReactNode;
|
||||||
|
initialNumRowsToShow?: number;
|
||||||
// collection: TableCollection<string>;
|
// collection: TableCollection<string>;
|
||||||
// children: React.ReactNode;
|
// children: React.ReactNode;
|
||||||
};
|
};
|
||||||
@@ -121,6 +125,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
selectionMode = 'single',
|
selectionMode = 'single',
|
||||||
selectionBehavior = 'toggle',
|
selectionBehavior = 'toggle',
|
||||||
slotEmpty,
|
slotEmpty,
|
||||||
|
initialNumRowsToShow = data.length,
|
||||||
// shouldRowRender,
|
// shouldRowRender,
|
||||||
|
|
||||||
// collection,
|
// collection,
|
||||||
@@ -136,6 +141,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
style,
|
style,
|
||||||
}: ElementProps<TableRowData, TableRowKey> & StyleProps) => {
|
}: ElementProps<TableRowData, TableRowKey> & StyleProps) => {
|
||||||
const [selectedKeys, setSelectedKeys] = useState(new Set<TableRowKey>());
|
const [selectedKeys, setSelectedKeys] = useState(new Set<TableRowKey>());
|
||||||
|
const [numRowsToShow, setNumRowsToShow] = useState(initialNumRowsToShow);
|
||||||
|
|
||||||
const currentBreakpoints = useBreakpoints();
|
const currentBreakpoints = useBreakpoints();
|
||||||
const shownColumns = columns.filter(
|
const shownColumns = columns.filter(
|
||||||
@@ -209,6 +215,12 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
onRowAction &&
|
onRowAction &&
|
||||||
((key: TableRowKey) => onRowAction(key, data.find((row) => getRowKey(row) === key)!))
|
((key: TableRowKey) => onRowAction(key, data.find((row) => getRowKey(row) === key)!))
|
||||||
}
|
}
|
||||||
|
numColumns={shownColumns.length}
|
||||||
|
onViewMoreClick={
|
||||||
|
numRowsToShow !== undefined && numRowsToShow < data.length
|
||||||
|
? () => setNumRowsToShow(data.length)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
// shouldRowRender={shouldRowRender}
|
// shouldRowRender={shouldRowRender}
|
||||||
hideHeader={hideHeader}
|
hideHeader={hideHeader}
|
||||||
withGradientCardRows={withGradientCardRows}
|
withGradientCardRows={withGradientCardRows}
|
||||||
@@ -233,7 +245,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
)}
|
)}
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
|
|
||||||
<TableBody items={list.items}>
|
<TableBody items={list.items.slice(0, numRowsToShow)}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<Row key={getRowKey(item)}>
|
<Row key={getRowKey(item)}>
|
||||||
{(columnKey) => (
|
{(columnKey) => (
|
||||||
@@ -267,6 +279,8 @@ const TableRoot = <TableRowData extends object | CustomRowConfig, TableRowKey ex
|
|||||||
onRowAction?: (key: TableRowKey) => void;
|
onRowAction?: (key: TableRowKey) => void;
|
||||||
// shouldRowRender?: (prevRowData: object, currentRowData: object) => boolean;
|
// shouldRowRender?: (prevRowData: object, currentRowData: object) => boolean;
|
||||||
children: CollectionChildren<TableRowData>;
|
children: CollectionChildren<TableRowData>;
|
||||||
|
numColumns: number;
|
||||||
|
onViewMoreClick?: () => void;
|
||||||
|
|
||||||
hideHeader?: boolean;
|
hideHeader?: boolean;
|
||||||
withGradientCardRows?: boolean;
|
withGradientCardRows?: boolean;
|
||||||
@@ -276,7 +290,7 @@ const TableRoot = <TableRowData extends object | CustomRowConfig, TableRowKey ex
|
|||||||
withScrollSnapColumns?: boolean;
|
withScrollSnapColumns?: boolean;
|
||||||
withScrollSnapRows?: boolean;
|
withScrollSnapRows?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const { selectionMode, selectionBehavior } = props;
|
const { selectionMode, selectionBehavior, numColumns, onViewMoreClick } = props;
|
||||||
|
|
||||||
const state = useTableState<TableRowData>({
|
const state = useTableState<TableRowData>({
|
||||||
...props,
|
...props,
|
||||||
@@ -337,6 +351,7 @@ const TableRoot = <TableRowData extends object | CustomRowConfig, TableRowKey ex
|
|||||||
<TableBodyRowGroup
|
<TableBodyRowGroup
|
||||||
withGradientCardRows={props.withGradientCardRows}
|
withGradientCardRows={props.withGradientCardRows}
|
||||||
withInnerBorders={props.withInnerBorders}
|
withInnerBorders={props.withInnerBorders}
|
||||||
|
withOuterBorder={props.withOuterBorder}
|
||||||
>
|
>
|
||||||
{/* {Array.from(collection.getChildren!(collection.body.key), (row) => */}
|
{/* {Array.from(collection.getChildren!(collection.body.key), (row) => */}
|
||||||
{[...collection.body.childNodes].map((row) =>
|
{[...collection.body.childNodes].map((row) =>
|
||||||
@@ -382,6 +397,9 @@ const TableRoot = <TableRowData extends object | CustomRowConfig, TableRowKey ex
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
{onViewMoreClick ? (
|
||||||
|
<ViewMoreRow colSpan={numColumns} onClick={onViewMoreClick} />
|
||||||
|
) : undefined}
|
||||||
</TableBodyRowGroup>
|
</TableBodyRowGroup>
|
||||||
</Styled.Table>
|
</Styled.Table>
|
||||||
);
|
);
|
||||||
@@ -415,6 +433,7 @@ const TableBodyRowGroup = ({
|
|||||||
children,
|
children,
|
||||||
withGradientCardRows,
|
withGradientCardRows,
|
||||||
withInnerBorders,
|
withInnerBorders,
|
||||||
|
withOuterBorder,
|
||||||
}: { children: React.ReactNode } & StyleProps) => {
|
}: { children: React.ReactNode } & StyleProps) => {
|
||||||
const { rowGroupProps } = useTableRowGroup();
|
const { rowGroupProps } = useTableRowGroup();
|
||||||
|
|
||||||
@@ -423,6 +442,7 @@ const TableBodyRowGroup = ({
|
|||||||
{...rowGroupProps}
|
{...rowGroupProps}
|
||||||
withGradientCardRows={withGradientCardRows}
|
withGradientCardRows={withGradientCardRows}
|
||||||
withInnerBorders={withInnerBorders}
|
withInnerBorders={withInnerBorders}
|
||||||
|
withOuterBorder={withOuterBorder}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Styled.Tbody>
|
</Styled.Tbody>
|
||||||
@@ -489,6 +509,23 @@ const TableColumnHeader = <TableRowData extends object>({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ViewMoreRow = ({ colSpan, onClick }: { colSpan: number; onClick: () => void }) => {
|
||||||
|
const stringGetter = useStringGetter();
|
||||||
|
return (
|
||||||
|
<Styled.Tr key="viewmore">
|
||||||
|
<Styled.Td
|
||||||
|
colSpan={colSpan}
|
||||||
|
onMouseDown={(e: MouseEvent) => e.preventDefault()}
|
||||||
|
onPointerDown={(e: MouseEvent) => e.preventDefault()}
|
||||||
|
>
|
||||||
|
<Styled.ViewMoreButton slotRight={<CaretIcon />} onClick={onClick}>
|
||||||
|
{stringGetter({ key: STRING_KEYS.VIEW_MORE })}
|
||||||
|
</Styled.ViewMoreButton>
|
||||||
|
</Styled.Td>
|
||||||
|
</Styled.Tr>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const TableRow = <TableRowData extends object>({
|
export const TableRow = <TableRowData extends object>({
|
||||||
item,
|
item,
|
||||||
children,
|
children,
|
||||||
@@ -660,7 +697,7 @@ Styled.Empty = styled.div<{ withOuterBorder: boolean }>`
|
|||||||
|
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
padding: 2rem;
|
padding: 4rem;
|
||||||
gap: 0.75em;
|
gap: 0.75em;
|
||||||
|
|
||||||
color: var(--color-text-0);
|
color: var(--color-text-0);
|
||||||
@@ -868,6 +905,18 @@ Styled.Tbody = styled.tbody<StyleProps>`
|
|||||||
--stickyArea2-paddingLeft: var(--border-width);
|
--stickyArea2-paddingLeft: var(--border-width);
|
||||||
--stickyArea2-paddingRight: var(--border-width);
|
--stickyArea2-paddingRight: var(--border-width);
|
||||||
|
|
||||||
|
tr:first-of-type {
|
||||||
|
box-shadow: 0 calc(var(--border-width)) 0 0 var(--border-color);
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
|
||||||
|
${({ withOuterBorder }) =>
|
||||||
|
withOuterBorder &&
|
||||||
|
css`
|
||||||
|
tr:last-of-type:not(:only-of-type) {
|
||||||
|
box-shadow: 0 calc(-1 * var(--border-width)) 0 0 var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
tr:first-of-type {
|
tr:first-of-type {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
@@ -922,3 +971,15 @@ Styled.Row = styled.div`
|
|||||||
${layoutMixins.inlineRow}
|
${layoutMixins.inlineRow}
|
||||||
padding: var(--tableCell-padding);
|
padding: var(--tableCell-padding);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
Styled.ViewMoreButton = styled(Button)`
|
||||||
|
--button-backgroundColor: var(--color-layer-2);
|
||||||
|
--button-textColor: var(--color-text-1);
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 0.675rem;
|
||||||
|
margin-left: 0.5ch;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useCallback, useEffect, useState, useMemo } from 'react';
|
import { useCallback, useEffect, useState, useMemo } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
|
|
||||||
|
import { EvmDerivedAddresses } from '@/constants/account';
|
||||||
import { LocalStorageKey } from '@/constants/localStorage';
|
import { LocalStorageKey } from '@/constants/localStorage';
|
||||||
import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks';
|
import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks';
|
||||||
|
|
||||||
@@ -104,11 +105,17 @@ export const useWalletConnection = () => {
|
|||||||
[walletConnectConfig, walletType, walletConnectionType]
|
[walletConnectConfig, walletType, walletConnectionType]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { connectAsync: connectWagmi } = useConnectWagmi({ connector: wagmiConnector })
|
const { connectAsync: connectWagmi } = useConnectWagmi({ connector: wagmiConnector });
|
||||||
const { suggestAndConnect: connectGraz } = useConnectGraz();
|
const { suggestAndConnect: connectGraz } = useConnectGraz();
|
||||||
|
const [evmDerivedAddresses] = useLocalStorage({
|
||||||
|
key: LocalStorageKey.EvmDerivedAddresses,
|
||||||
|
defaultValue: {} as EvmDerivedAddresses,
|
||||||
|
});
|
||||||
|
|
||||||
const connectWallet = useCallback(
|
const connectWallet = useCallback(
|
||||||
async ({ walletType }: { walletType: WalletType }) => {
|
async ({ walletType, forceConnect }: { walletType?: WalletType; forceConnect?: boolean }) => {
|
||||||
|
if (!walletType) return { walletType, walletConnectionType };
|
||||||
|
|
||||||
const walletConnection = getWalletConnection({ walletType });
|
const walletConnection = getWalletConnection({ walletType });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -132,7 +139,11 @@ export const useWalletConnection = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isConnectedWagmi) {
|
const isAccountConnected = Boolean(
|
||||||
|
evmAddress && evmDerivedAddresses[evmAddress]?.encryptedSignature
|
||||||
|
);
|
||||||
|
// if account connected (via remember me), do not show wagmi popup until forceConnect
|
||||||
|
if (!isConnectedWagmi && (forceConnect || !isAccountConnected)) {
|
||||||
await connectWagmi({
|
await connectWagmi({
|
||||||
connector: resolveWagmiConnector({
|
connector: resolveWagmiConnector({
|
||||||
walletType,
|
walletType,
|
||||||
@@ -228,6 +239,12 @@ export const useWalletConnection = () => {
|
|||||||
evmAddressWagmi,
|
evmAddressWagmi,
|
||||||
signerWagmi,
|
signerWagmi,
|
||||||
publicClientWagmi,
|
publicClientWagmi,
|
||||||
|
isConnectedWagmi,
|
||||||
|
connectWallet: () =>
|
||||||
|
connectWallet({
|
||||||
|
walletType: selectedWalletType,
|
||||||
|
forceConnect: true,
|
||||||
|
}),
|
||||||
|
|
||||||
// Wallet connection (Cosmos)
|
// Wallet connection (Cosmos)
|
||||||
dydxAddress,
|
dydxAddress,
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
|||||||
this.store = undefined;
|
this.store = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isNobleClientConnected(): boolean {
|
||||||
|
return this.nobleClient?.isConnected ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
setStore(store: RootStore): void {
|
setStore(store: RootStore): void {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-5
@@ -171,6 +171,15 @@ class AbacusStateManager {
|
|||||||
this.setTransferValue({ value: null, field: TransferInputField.usdcSize });
|
this.setTransferValue({ value: null, field: TransferInputField.usdcSize });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resetInputState = () => {
|
||||||
|
this.clearTransferInputValues();
|
||||||
|
this.setTransferValue({
|
||||||
|
field: TransferInputField.type,
|
||||||
|
value: null,
|
||||||
|
});
|
||||||
|
this.clearTradeInputValues();
|
||||||
|
};
|
||||||
|
|
||||||
// ------ Set Data ------ //
|
// ------ Set Data ------ //
|
||||||
setStore = (store: RootStore) => {
|
setStore = (store: RootStore) => {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
@@ -262,11 +271,7 @@ class AbacusStateManager {
|
|||||||
) => this.stateManager.cancelOrder(orderId, callback);
|
) => this.stateManager.cancelOrder(orderId, callback);
|
||||||
|
|
||||||
cctpWithdraw = (
|
cctpWithdraw = (
|
||||||
callback: (
|
callback: (success: boolean, parsingError: Nullable<ParsingError>, data: string) => void
|
||||||
success: boolean,
|
|
||||||
parsingError: Nullable<ParsingError>,
|
|
||||||
data: string,
|
|
||||||
) => void
|
|
||||||
): void => this.stateManager.commitCCTPWithdraw(callback);
|
): void => this.stateManager.commitCCTPWithdraw(callback);
|
||||||
|
|
||||||
// ------ Utils ------ //
|
// ------ Utils ------ //
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export const GenerateKeys = ({
|
|||||||
if (message) {
|
if (message) {
|
||||||
log('GenerateKeys/switchNetwork', error, { walletErrorType });
|
log('GenerateKeys/switchNetwork', error, { walletErrorType });
|
||||||
setError(message);
|
setError(message);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import type { EvmAddress } from '@/constants/wallets';
|
|||||||
import { useAccounts, useDebounce, useStringGetter, useSelectedNetwork } from '@/hooks';
|
import { useAccounts, useDebounce, useStringGetter, useSelectedNetwork } from '@/hooks';
|
||||||
import { useAccountBalance, CHAIN_DEFAULT_TOKEN_ADDRESS } from '@/hooks/useAccountBalance';
|
import { useAccountBalance, CHAIN_DEFAULT_TOKEN_ADDRESS } from '@/hooks/useAccountBalance';
|
||||||
import { useLocalNotifications } from '@/hooks/useLocalNotifications';
|
import { useLocalNotifications } from '@/hooks/useLocalNotifications';
|
||||||
|
import { useWalletConnection } from '@/hooks/useWalletConnection';
|
||||||
|
|
||||||
import { layoutMixins } from '@/styles/layoutMixins';
|
import { layoutMixins } from '@/styles/layoutMixins';
|
||||||
import { formMixins } from '@/styles/formMixins';
|
import { formMixins } from '@/styles/formMixins';
|
||||||
@@ -120,11 +121,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
abacusStateManager.clearTransferInputValues();
|
abacusStateManager.resetInputState();
|
||||||
abacusStateManager.setTransferValue({
|
|
||||||
field: TransferInputField.type,
|
|
||||||
value: null,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -235,6 +232,10 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
|||||||
throw new Error('Missing request payload');
|
throw new Error('Missing request payload');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCctp && !abacusStateManager.chainTransactions.isNobleClientConnected) {
|
||||||
|
throw new Error('Noble RPC endpoint unaccessible');
|
||||||
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
await validateTokenApproval();
|
await validateTokenApproval();
|
||||||
@@ -364,6 +365,8 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
|||||||
return <LoadingSpace id="DepositForm" />;
|
return <LoadingSpace id="DepositForm" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [requireUserActionInWallet, setRequireUserActionInWallet] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Styled.Form onSubmit={onSubmit}>
|
<Styled.Form onSubmit={onSubmit}>
|
||||||
<ChainSelectMenu selectedChain={chainIdStr || undefined} onSelectChain={onSelectChain} />
|
<ChainSelectMenu selectedChain={chainIdStr || undefined} onSelectChain={onSelectChain} />
|
||||||
@@ -382,7 +385,11 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
|||||||
/>
|
/>
|
||||||
</Styled.WithDetailsReceipt>
|
</Styled.WithDetailsReceipt>
|
||||||
{errorMessage && <AlertMessage type={AlertType.Error}>{errorMessage}</AlertMessage>}
|
{errorMessage && <AlertMessage type={AlertType.Error}>{errorMessage}</AlertMessage>}
|
||||||
|
{requireUserActionInWallet && (
|
||||||
|
<AlertMessage type={AlertType.Warning}>
|
||||||
|
{stringGetter({ key: STRING_KEYS.CHECK_WALLET_FOR_REQUEST })}
|
||||||
|
</AlertMessage>
|
||||||
|
)}
|
||||||
<Styled.Footer>
|
<Styled.Footer>
|
||||||
<DepositButtonAndReceipt
|
<DepositButtonAndReceipt
|
||||||
isDisabled={isDisabled}
|
isDisabled={isDisabled}
|
||||||
@@ -391,6 +398,8 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
|||||||
setSlippage={onSetSlippage}
|
setSlippage={onSetSlippage}
|
||||||
slippage={slippage}
|
slippage={slippage}
|
||||||
sourceToken={sourceToken || undefined}
|
sourceToken={sourceToken || undefined}
|
||||||
|
setRequireUserActionInWallet={setRequireUserActionInWallet}
|
||||||
|
setError={setError}
|
||||||
/>
|
/>
|
||||||
</Styled.Footer>
|
</Styled.Footer>
|
||||||
</Styled.Form>
|
</Styled.Form>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { type Dispatch, type ReactNode, type SetStateAction, useState, useMemo } from 'react';
|
import { type Dispatch, type SetStateAction, useState, type ReactNode, useEffect } from 'react';
|
||||||
import styled, { type AnyStyledComponent } from 'styled-components';
|
import styled, { type AnyStyledComponent } from 'styled-components';
|
||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import type { RouteData } from '@0xsquid/sdk';
|
import type { RouteData } from '@0xsquid/sdk';
|
||||||
import { formatUnits } from 'viem';
|
|
||||||
|
|
||||||
import { ButtonAction, ButtonShape, ButtonSize, ButtonType } from '@/constants/buttons';
|
import { ButtonAction, ButtonShape, ButtonSize, ButtonType } from '@/constants/buttons';
|
||||||
|
|
||||||
@@ -12,6 +11,7 @@ import { NumberSign, TOKEN_DECIMALS } from '@/constants/numbers';
|
|||||||
|
|
||||||
import { useStringGetter, useTokenConfigs } from '@/hooks';
|
import { useStringGetter, useTokenConfigs } from '@/hooks';
|
||||||
import { useMatchingEvmNetwork } from '@/hooks/useMatchingEvmNetwork';
|
import { useMatchingEvmNetwork } from '@/hooks/useMatchingEvmNetwork';
|
||||||
|
import { useWalletConnection } from '@/hooks/useWalletConnection';
|
||||||
|
|
||||||
import { layoutMixins } from '@/styles/layoutMixins';
|
import { layoutMixins } from '@/styles/layoutMixins';
|
||||||
|
|
||||||
@@ -39,7 +39,8 @@ type ElementProps = {
|
|||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
|
|
||||||
chainId?: string | number;
|
chainId?: string | number;
|
||||||
setError?: Dispatch<SetStateAction<Error | undefined>>;
|
setError?: Dispatch<SetStateAction<Error | null>>;
|
||||||
|
setRequireUserActionInWallet: (val: boolean) => void;
|
||||||
slippage: number;
|
slippage: number;
|
||||||
slotError?: ReactNode;
|
slotError?: ReactNode;
|
||||||
setSlippage: (slippage: number) => void;
|
setSlippage: (slippage: number) => void;
|
||||||
@@ -57,6 +58,7 @@ export const DepositButtonAndReceipt = ({
|
|||||||
isDisabled,
|
isDisabled,
|
||||||
isLoading,
|
isLoading,
|
||||||
slotError,
|
slotError,
|
||||||
|
setRequireUserActionInWallet,
|
||||||
}: ElementProps) => {
|
}: ElementProps) => {
|
||||||
const [showFeeBreakdown, setShowFeeBreakdown] = useState(false);
|
const [showFeeBreakdown, setShowFeeBreakdown] = useState(false);
|
||||||
const [isEditingSlippage, setIsEditingSlipapge] = useState(false);
|
const [isEditingSlippage, setIsEditingSlipapge] = useState(false);
|
||||||
@@ -64,6 +66,24 @@ export const DepositButtonAndReceipt = ({
|
|||||||
|
|
||||||
const canAccountTrade = useSelector(calculateCanAccountTrade, shallowEqual);
|
const canAccountTrade = useSelector(calculateCanAccountTrade, shallowEqual);
|
||||||
|
|
||||||
|
const { connectWallet, isConnectedWagmi } = useWalletConnection();
|
||||||
|
|
||||||
|
const connectWagmi = async () => {
|
||||||
|
try {
|
||||||
|
setRequireUserActionInWallet(false);
|
||||||
|
await connectWallet();
|
||||||
|
setRequireUserActionInWallet(false);
|
||||||
|
} catch (e) {
|
||||||
|
setRequireUserActionInWallet(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isConnectedWagmi && canAccountTrade) {
|
||||||
|
connectWagmi();
|
||||||
|
}
|
||||||
|
}, [isConnectedWagmi, canAccountTrade]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
matchNetwork: switchNetwork,
|
matchNetwork: switchNetwork,
|
||||||
isSwitchingNetwork,
|
isSwitchingNetwork,
|
||||||
@@ -80,7 +100,7 @@ export const DepositButtonAndReceipt = ({
|
|||||||
useSelector(getSubaccountBuyingPower, shallowEqual) || {};
|
useSelector(getSubaccountBuyingPower, shallowEqual) || {};
|
||||||
|
|
||||||
const { isCctp, summary, requestPayload } = useSelector(getTransferInputs, shallowEqual) || {};
|
const { isCctp, summary, requestPayload } = useSelector(getTransferInputs, shallowEqual) || {};
|
||||||
const { usdcDecimals, usdcLabel } = useTokenConfigs();
|
const { usdcLabel } = useTokenConfigs();
|
||||||
|
|
||||||
const feeSubitems: DetailsItem[] = [];
|
const feeSubitems: DetailsItem[] = [];
|
||||||
|
|
||||||
@@ -116,7 +136,9 @@ export const DepositButtonAndReceipt = ({
|
|||||||
{stringGetter({ key: STRING_KEYS.EXPECTED_DEPOSIT_AMOUNT })} <Tag>{usdcLabel}</Tag>
|
{stringGetter({ key: STRING_KEYS.EXPECTED_DEPOSIT_AMOUNT })} <Tag>{usdcLabel}</Tag>
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
value: <Output type={OutputType.Fiat} fractionDigits={TOKEN_DECIMALS} value={summary?.toAmount} />,
|
value: (
|
||||||
|
<Output type={OutputType.Fiat} fractionDigits={TOKEN_DECIMALS} value={summary?.toAmount} />
|
||||||
|
),
|
||||||
subitems: [
|
subitems: [
|
||||||
{
|
{
|
||||||
key: 'minimum-deposit-amount',
|
key: 'minimum-deposit-amount',
|
||||||
@@ -126,7 +148,11 @@ export const DepositButtonAndReceipt = ({
|
|||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
value: (
|
value: (
|
||||||
<Output type={OutputType.Fiat} fractionDigits={TOKEN_DECIMALS} value={summary?.toAmountMin} />
|
<Output
|
||||||
|
type={OutputType.Fiat}
|
||||||
|
fractionDigits={TOKEN_DECIMALS}
|
||||||
|
value={summary?.toAmountMin}
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
tooltip: 'minimum-deposit-amount',
|
tooltip: 'minimum-deposit-amount',
|
||||||
},
|
},
|
||||||
@@ -253,6 +279,8 @@ export const DepositButtonAndReceipt = ({
|
|||||||
>
|
>
|
||||||
{!canAccountTrade ? (
|
{!canAccountTrade ? (
|
||||||
<OnboardingTriggerButton size={ButtonSize.Base} />
|
<OnboardingTriggerButton size={ButtonSize.Base} />
|
||||||
|
) : !isConnectedWagmi ? (
|
||||||
|
<Button action={ButtonAction.Primary} onClick={connectWallet} state={{ isLoading: true }} />
|
||||||
) : !isMatchingNetwork ? (
|
) : !isMatchingNetwork ? (
|
||||||
<Button
|
<Button
|
||||||
action={ButtonAction.Primary}
|
action={ButtonAction.Primary}
|
||||||
|
|||||||
@@ -101,11 +101,7 @@ export const WithdrawForm = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
abacusStateManager.clearTransferInputValues();
|
abacusStateManager.resetInputState();
|
||||||
abacusStateManager.setTransferValue({
|
|
||||||
field: TransferInputField.type,
|
|
||||||
value: null,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -148,6 +144,10 @@ export const WithdrawForm = () => {
|
|||||||
throw new Error('Invalid request payload');
|
throw new Error('Invalid request payload');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCctp && !abacusStateManager.chainTransactions.isNobleClientConnected) {
|
||||||
|
throw new Error('Noble RPC endpoint unaccessible');
|
||||||
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setError(undefined);
|
setError(undefined);
|
||||||
|
|
||||||
|
|||||||
@@ -118,11 +118,7 @@ export const TransferForm = ({
|
|||||||
onChangeAsset(selectedAsset);
|
onChangeAsset(selectedAsset);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
abacusStateManager.clearTransferInputValues();
|
abacusStateManager.resetInputState();
|
||||||
abacusStateManager.setTransferValue({
|
|
||||||
field: TransferInputField.type,
|
|
||||||
value: null,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ import { openDialog } from '@/state/dialogs';
|
|||||||
|
|
||||||
import { MustBigNumber } from '@/lib/numbers';
|
import { MustBigNumber } from '@/lib/numbers';
|
||||||
import { getHydratedTradingData } from '@/lib/orders';
|
import { getHydratedTradingData } from '@/lib/orders';
|
||||||
import { tableMixins } from '@/styles/tableMixins';
|
|
||||||
import { breakpoints } from '@/styles';
|
|
||||||
|
|
||||||
const MOBILE_FILLS_PER_PAGE = 50;
|
const MOBILE_FILLS_PER_PAGE = 50;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user