remove abacus transfer status
This commit is contained in:
@@ -22,7 +22,6 @@ import {
|
||||
setSubaccount,
|
||||
setTransfers,
|
||||
setWallet,
|
||||
setTransferStatuses,
|
||||
} from '@/state/account';
|
||||
|
||||
import { setApiState } from '@/state/app';
|
||||
@@ -70,14 +69,6 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol {
|
||||
dispatch(setInputs(updatedState.input));
|
||||
}
|
||||
|
||||
if (changes.has(Changes.transferStatuses) && updatedState.transferStatuses) {
|
||||
const transferStatuses: Record<string, TransferStatus> = {};
|
||||
updatedState.transferStatuses.forEach((transferStatus) => {
|
||||
transferStatuses[transferStatus.k] = transferStatus.v;
|
||||
});
|
||||
dispatch(setTransferStatuses(transferStatuses));
|
||||
}
|
||||
|
||||
if (changes.has(Changes.wallet)) {
|
||||
dispatch(setWallet(updatedState.wallet));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import type {
|
||||
SubaccountTransfers,
|
||||
HistoricalPnlPeriods,
|
||||
SubAccountHistoricalPNLs,
|
||||
TransferStatus,
|
||||
} from '@/constants/abacus';
|
||||
|
||||
import { OnboardingGuard, OnboardingState } from '@/constants/account';
|
||||
@@ -36,16 +35,6 @@ export type AccountState = {
|
||||
wallet?: Nullable<Wallet>;
|
||||
walletType?: WalletType;
|
||||
historicalPnlPeriod?: HistoricalPnlPeriods;
|
||||
squidTransfer?: Record<
|
||||
string,
|
||||
{
|
||||
hash: string;
|
||||
toChainId: string;
|
||||
fromChainId?: string;
|
||||
toAmount?: number;
|
||||
status?: TransferStatus;
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
const initialState: AccountState = {
|
||||
@@ -159,24 +148,6 @@ export const accountSlice = createSlice({
|
||||
viewedOrders: (state) => {
|
||||
state.hasUnseenOrderUpdates = false;
|
||||
},
|
||||
addSquidTransfer: (
|
||||
state,
|
||||
action: PayloadAction<{
|
||||
hash: string;
|
||||
toChainId: string;
|
||||
fromChainId?: string;
|
||||
toAmount?: number;
|
||||
}>
|
||||
) => {
|
||||
if (!state.squidTransfer) state.squidTransfer = {};
|
||||
state.squidTransfer[action.payload.hash] = { ...action.payload };
|
||||
},
|
||||
setTransferStatuses: (state, action: PayloadAction<Record<string, TransferStatus>>) => {
|
||||
Object.keys(action.payload).forEach((key) => {
|
||||
if (state.squidTransfer && state.squidTransfer[key])
|
||||
state.squidTransfer[key].status = action.payload[key];
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -194,6 +165,4 @@ export const {
|
||||
removeUncommittedOrderClientId,
|
||||
viewedFills,
|
||||
viewedOrders,
|
||||
addSquidTransfer,
|
||||
setTransferStatuses,
|
||||
} = accountSlice.actions;
|
||||
|
||||
@@ -319,8 +319,3 @@ export const getUserStats = (state: RootState) => ({
|
||||
makerVolume30D: state.account?.wallet?.user?.makerVolume30D,
|
||||
takerVolume30D: state.account?.wallet?.user?.takerVolume30D,
|
||||
});
|
||||
|
||||
/**
|
||||
* @returns Get the current squid transfers
|
||||
*/
|
||||
export const getSquidTransfers = (state: RootState) => state.account?.squidTransfer;
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
|
||||
|
||||
import type {
|
||||
InputError,
|
||||
Inputs,
|
||||
Nullable,
|
||||
TradeInputs,
|
||||
ClosePositionInputs,
|
||||
TransferInputs,
|
||||
} from '@/constants/abacus';
|
||||
|
||||
export interface InputsState {
|
||||
current?: Nullable<string>;
|
||||
inputErrors?: Nullable<InputError[]>;
|
||||
tradeInputs?: Nullable<TradeInputs>;
|
||||
closePositionInputs?: Nullable<ClosePositionInputs>;
|
||||
transferInputs?: Nullable<TransferInputs>;
|
||||
}
|
||||
|
||||
const initialState: InputsState = {
|
||||
current: undefined,
|
||||
inputErrors: undefined,
|
||||
tradeInputs: undefined,
|
||||
transferInputs: undefined,
|
||||
};
|
||||
|
||||
export const inputsSlice = createSlice({
|
||||
name: 'Inputs',
|
||||
initialState,
|
||||
reducers: {
|
||||
setInputs: (state, action: PayloadAction<Nullable<Inputs>>) => {
|
||||
const { current, errors, trade, closePosition, transfer } = action.payload || {};
|
||||
|
||||
return {
|
||||
...state,
|
||||
current: current?.rawValue,
|
||||
inputErrors: errors?.toArray(),
|
||||
tradeInputs: trade,
|
||||
closePositionInputs: closePosition,
|
||||
transferInputs: transfer,
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setInputs } = inputsSlice.actions;
|
||||
@@ -1,113 +0,0 @@
|
||||
import { shallowEqual, useSelector } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
import type { RootState } from './_store';
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns TradeInputs
|
||||
*/
|
||||
export const getInputTradeData = (state: RootState) => state.inputs.tradeInputs;
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns Size data in TradeInputs
|
||||
*/
|
||||
export const getInputTradeSizeData = (state: RootState) => state.inputs.tradeInputs?.size;
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns AbacusOrderSide in TradeInputs
|
||||
*/
|
||||
export const getTradeSide = (state: RootState) => state.inputs.tradeInputs?.side;
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns TradeInputs options (config for what TradeInputFields to render)
|
||||
*/
|
||||
export const getInputTradeOptions = (state: RootState) => state.inputs.tradeInputs?.options;
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns ValidationErrors of the current Input type (Trade or Transfer)
|
||||
*/
|
||||
export const getInputErrors = (state: RootState) => state.inputs.inputErrors;
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns trade or closePosition transfer, depending on which form was last edited.
|
||||
*/
|
||||
export const getCurrentInput = (state: RootState) => state.inputs.current;
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns input errors for Trade
|
||||
*/
|
||||
export const getTradeInputErrors = (state: RootState) => {
|
||||
const currentInput = state.inputs.current;
|
||||
return currentInput === 'trade' ? getInputErrors(state) : [];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns input errors for Transfer
|
||||
*/
|
||||
export const getTransferInputErrors = (state: RootState) => {
|
||||
const currentInput = state.inputs.current;
|
||||
return currentInput === 'transfer' ? getInputErrors(state) : [];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns TransferInputs
|
||||
*/
|
||||
export const getTransferInputs = (state: RootState) => state.inputs.transferInputs;
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* @returns ClosePositionInputs
|
||||
*/
|
||||
export const getInputClosePositionData = (state: RootState) => state.inputs.closePositionInputs;
|
||||
|
||||
/**
|
||||
* @returns Data needed for the TradeForm (price, size, summary, input render options, and errors/input validation)
|
||||
*/
|
||||
export const useTradeFormData = () => {
|
||||
return useSelector(
|
||||
createSelector(
|
||||
[getInputTradeData, getInputTradeOptions, getTradeInputErrors],
|
||||
(tradeData, tradeOptions, tradeErrors) => {
|
||||
const { price, size, summary } = tradeData || {};
|
||||
|
||||
const {
|
||||
needsLimitPrice,
|
||||
needsTrailingPercent,
|
||||
needsTriggerPrice,
|
||||
executionOptions,
|
||||
needsGoodUntil,
|
||||
needsPostOnly,
|
||||
needsReduceOnly,
|
||||
timeInForceOptions,
|
||||
} = tradeOptions || {};
|
||||
|
||||
return {
|
||||
price,
|
||||
size,
|
||||
summary,
|
||||
|
||||
needsLimitPrice,
|
||||
needsTrailingPercent,
|
||||
needsTriggerPrice,
|
||||
executionOptions,
|
||||
needsGoodUntil,
|
||||
needsPostOnly,
|
||||
needsReduceOnly,
|
||||
timeInForceOptions,
|
||||
|
||||
tradeErrors,
|
||||
};
|
||||
}
|
||||
),
|
||||
shallowEqual
|
||||
);
|
||||
};
|
||||
@@ -197,6 +197,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
toChainId: TESTNET_CHAIN_ID,
|
||||
fromChainId: chainIdStr || undefined,
|
||||
toAmount: summary?.usdcSize || undefined,
|
||||
triggeredAt: Date.now(),
|
||||
});
|
||||
abacusStateManager.clearTransferInputValues();
|
||||
setFromAmount('');
|
||||
|
||||
@@ -5,11 +5,7 @@ import type { NumberFormatValues } from 'react-number-format';
|
||||
import { shallowEqual, useSelector } from 'react-redux';
|
||||
import { TESTNET_CHAIN_ID } from '@dydxprotocol/v4-client';
|
||||
|
||||
import {
|
||||
TransferInputField,
|
||||
TransferInputTokenResource,
|
||||
TransferType,
|
||||
} from '@/constants/abacus';
|
||||
import { TransferInputField, TransferInputTokenResource, TransferType } from '@/constants/abacus';
|
||||
import { AlertType } from '@/constants/alerts';
|
||||
import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
@@ -135,17 +131,18 @@ export const WithdrawForm = () => {
|
||||
|
||||
setIsLoading(true);
|
||||
const txHash = await sendSquidWithdraw(debouncedAmountBN.toNumber(), requestPayload?.data);
|
||||
|
||||
|
||||
if (txHash?.hash) {
|
||||
const hash = `0x${Buffer.from(txHash.hash).toString('hex')}`;
|
||||
|
||||
|
||||
setTransactionHash(hash);
|
||||
|
||||
|
||||
addTransferNotification({
|
||||
txHash: hash,
|
||||
fromChainId: TESTNET_CHAIN_ID,
|
||||
toChainId: chainIdStr || undefined,
|
||||
toAmount: debouncedAmountBN.toNumber(),
|
||||
triggeredAt: Date.now(),
|
||||
});
|
||||
abacusStateManager.clearTransferInputValues();
|
||||
setWithdrawAmount('');
|
||||
@@ -304,17 +301,7 @@ export const WithdrawForm = () => {
|
||||
}
|
||||
/>
|
||||
</Styled.WithDetailsReceipt>
|
||||
{errorMessage ? (
|
||||
<AlertMessage type={AlertType.Error}>{errorMessage}</AlertMessage>
|
||||
) : (
|
||||
transactionHash && (
|
||||
<AlertMessage type={AlertType.Success}>
|
||||
<Styled.TransactionInfo>
|
||||
{stringGetter({ key: STRING_KEYS.WITHDRAW_IN_PROGRESS })}
|
||||
</Styled.TransactionInfo>
|
||||
</AlertMessage>
|
||||
)
|
||||
)}
|
||||
{errorMessage && <AlertMessage type={AlertType.Error}>{errorMessage}</AlertMessage>}
|
||||
<WithdrawButtonAndReceipt
|
||||
isDisabled={isDisabled}
|
||||
isLoading={isLoading}
|
||||
|
||||
Reference in New Issue
Block a user