address comments
This commit is contained in:
@@ -474,6 +474,7 @@ export const APP_STRING_KEYS = {
|
||||
LEAVING_WEBSITE: 'LEGAL.LEAVING_WEBSITE',
|
||||
|
||||
// Deposit Modal
|
||||
BRIDGE_FEE: 'DEPOSIT_MODAL.BRIDGE_FEE',
|
||||
ENABLE_FOR_THIS_DEPOSIT: 'DEPOSIT_MODAL.ENABLE_FOR_THIS_DEPOSIT',
|
||||
ENABLE_SYMBOL_ON_DYDX: 'DEPOSIT_MODAL.ENABLE_SYMBOL_ON_DYDX',
|
||||
ENABLE_SYMBOL: 'DEPOSIT_MODAL.ENABLE_SYMBOL',
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { useCallback, useContext, createContext, useEffect, useState, useMemo } from 'react';
|
||||
|
||||
import { useSelector, useDispatch, shallowEqual } from 'react-redux';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { AES, enc } from 'crypto-js';
|
||||
import { LocalWallet, USDC_DENOM, type Subaccount } from '@dydxprotocol/v4-client';
|
||||
|
||||
import { SubAccountHistoricalPNLs, TransferType } from '@/constants/abacus';
|
||||
import { OnboardingGuard, OnboardingState, type EvmDerivedAddresses } from '@/constants/account';
|
||||
import { LocalStorageKey, LOCAL_STORAGE_VERSIONS } from '@/constants/localStorage';
|
||||
import { DydxAddress, EthereumAddress, PrivateInformation } from '@/constants/wallets';
|
||||
@@ -12,10 +11,7 @@ import { DydxAddress, EthereumAddress, PrivateInformation } from '@/constants/wa
|
||||
import {
|
||||
setOnboardingState,
|
||||
setOnboardingGuard,
|
||||
setSubaccount,
|
||||
setHistoricalPnl,
|
||||
} from '@/state/account';
|
||||
import { getTransferInputs } from '@/state/inputsSelectors';
|
||||
|
||||
import abacusStateManager from '@/lib/abacus';
|
||||
import { log } from '@/lib/telemetry';
|
||||
@@ -37,7 +33,6 @@ export const useAccounts = () => useContext(AccountsContext)!;
|
||||
|
||||
const useAccountsContext = () => {
|
||||
const dispatch = useDispatch();
|
||||
const { type: transferType } = useSelector(getTransferInputs, shallowEqual) || {};
|
||||
|
||||
// Wallet connection
|
||||
const {
|
||||
@@ -65,7 +60,7 @@ const useAccountsContext = () => {
|
||||
forgetEvmSignature(previousEvmAddress);
|
||||
}
|
||||
|
||||
if (evmAddress) abacusStateManager.setEvmAddress(evmAddress);
|
||||
if (evmAddress) abacusStateManager.setTransfersSourceAddress(evmAddress);
|
||||
|
||||
setPreviousEvmAddress(evmAddress);
|
||||
}, [evmAddress]);
|
||||
@@ -227,12 +222,8 @@ const useAccountsContext = () => {
|
||||
// abacus
|
||||
// TODO: useAbacus({ dydxAddress })
|
||||
useEffect(() => {
|
||||
if (dydxAddress) {
|
||||
abacusStateManager.setAccount(dydxAddress);
|
||||
} else if (transferType?.rawValue !== TransferType.deposit.rawValue) {
|
||||
// we don't want to disconnect the account if we switch network during the deposit form
|
||||
abacusStateManager.disconnectAccount();
|
||||
}
|
||||
if (dydxAddress) abacusStateManager.setAccount(dydxAddress);
|
||||
else abacusStateManager.attemptDisconnectAccount();
|
||||
}, [dydxAddress]);
|
||||
|
||||
// clear subaccounts when no dydxAddress is set
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { ethers } from 'ethers';
|
||||
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { Squid, type GetRoute, type RouteResponse, ChainData, ChainType } from '@0xsquid/sdk';
|
||||
import { Squid } from '@0xsquid/sdk';
|
||||
import { USDC_DENOM } from '@dydxprotocol/v4-client';
|
||||
|
||||
import { DydxV4Network, isDydxV4Network } from '@/constants/networks';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useDispatch } from 'react-redux';
|
||||
import type { Nullable } from '@dydxprotocol/abacus';
|
||||
import Long from 'long';
|
||||
import type { IndexedTx } from '@cosmjs/stargate';
|
||||
import { EncodeObject, type Coin } from '@cosmjs/proto-signing';
|
||||
import type { EncodeObject, Coin } from '@cosmjs/proto-signing';
|
||||
import { Method } from '@cosmjs/tendermint-rpc';
|
||||
|
||||
import {
|
||||
|
||||
+12
-1
@@ -18,6 +18,7 @@ import {
|
||||
IOImplementations,
|
||||
UIImplementations,
|
||||
CoroutineTimer,
|
||||
TransferType,
|
||||
} from '@/constants/abacus';
|
||||
|
||||
import { DEFAULT_MARKETID } from '@/constants/markets';
|
||||
@@ -26,6 +27,7 @@ import { type DydxNetwork } from '@/constants/networks';
|
||||
import type { RootStore } from '@/state/_store';
|
||||
|
||||
import { getInputTradeOptions } from '@/state/inputsSelectors';
|
||||
import { getTransferInputs } from '@/state/inputsSelectors';
|
||||
|
||||
import AbacusRest from './rest';
|
||||
import AbacusWebsocket from './websocket';
|
||||
@@ -90,6 +92,15 @@ class AbacusStateManager {
|
||||
disconnectAccount = () => {
|
||||
this.stateManager.accountAddress = null;
|
||||
};
|
||||
|
||||
attemptDisconnectAccount = () => {
|
||||
const state = this.store?.getState();
|
||||
const { type: transferType }= (state && getTransferInputs(state)) || {};
|
||||
// we don't want to disconnect the account if we switch network during the deposit form
|
||||
if (transferType?.rawValue !== TransferType.deposit.rawValue) {
|
||||
this.disconnectAccount();
|
||||
}
|
||||
}
|
||||
|
||||
// ------ Input Values ------ //
|
||||
clearTradeInputValues = ({ shouldResetSize }: { shouldResetSize?: boolean } = {}) => {
|
||||
@@ -147,7 +158,7 @@ class AbacusStateManager {
|
||||
this.stateManager.accountAddress = walletAddress;
|
||||
};
|
||||
|
||||
setEvmAddress = (evmAddress: string) => {
|
||||
setTransfersSourceAddress = (evmAddress: string) => {
|
||||
this.stateManager.sourceAddress = evmAddress;
|
||||
};
|
||||
|
||||
|
||||
@@ -38,10 +38,6 @@ export const WAGMI_SUPPORTED_CHAINS: Chain[] = [
|
||||
optimismGoerli,
|
||||
];
|
||||
|
||||
export const WAGMI_SUPPORTED_CHAIN_MAP = Object.fromEntries(
|
||||
WAGMI_SUPPORTED_CHAINS.map((supportedChain) => [supportedChain.id, supportedChain])
|
||||
);
|
||||
|
||||
const { chains, publicClient, webSocketPublicClient } = configureChains(WAGMI_SUPPORTED_CHAINS, [
|
||||
alchemyProvider({ apiKey: import.meta.env.VITE_ALCHEMY_API_KEY }),
|
||||
jsonRpcProvider({
|
||||
|
||||
@@ -479,6 +479,7 @@
|
||||
"LEAVING_WEBSITE": "Leaving website"
|
||||
},
|
||||
"DEPOSIT_MODAL": {
|
||||
"BRIDGE_FEE": "Bridge Fee",
|
||||
"ENABLE_FOR_THIS_DEPOSIT": "Enable for this deposit",
|
||||
"ENABLE_SYMBOL_ON_DYDX": "Enable {SYMBOL} on dYdX",
|
||||
"ENABLE_SYMBOL": "Enable {SYMBOL}",
|
||||
|
||||
@@ -7,13 +7,12 @@ import { ethers } from 'ethers';
|
||||
|
||||
import {
|
||||
TransferInputField,
|
||||
TransferInputChainResource,
|
||||
TransferInputTokenResource,
|
||||
TransferType,
|
||||
} from '@/constants/abacus';
|
||||
import { AlertType } from '@/constants/alerts';
|
||||
import { ButtonSize } from '@/constants/buttons';
|
||||
import { StringGetterFunction, STRING_KEYS } from '@/constants/localization';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { NumberSign } from '@/constants/numbers';
|
||||
|
||||
import { useAccounts, useDebounce, useStringGetter } from '@/hooks';
|
||||
|
||||
@@ -78,7 +78,7 @@ export const WithdrawButtonAndReceipt = ({
|
||||
if (typeof summary?.bridgeFee === 'number') {
|
||||
feeSubitems.push({
|
||||
key: 'bridge-fees',
|
||||
label: <span>Bridge Fee</span>,
|
||||
label: <span>{stringGetter({ key: STRING_KEYS.BRIDGE_FEE })}</span>,
|
||||
value: <Output type={OutputType.Fiat} value={summary?.bridgeFee} />,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user