address comments
This commit is contained in:
@@ -49,11 +49,11 @@ export enum EvmDerivedAccountStatus {
|
||||
Derived,
|
||||
}
|
||||
|
||||
import type { DydxAddress, EthereumAddress } from './wallets';
|
||||
import type { DydxAddress, EvmAddress } from './wallets';
|
||||
|
||||
export type EvmDerivedAddresses = {
|
||||
version?: string;
|
||||
[EthereumAddress: EthereumAddress]: {
|
||||
[EvmAddress: EvmAddress]: {
|
||||
encryptedSignature?: string;
|
||||
dydxAddress?: DydxAddress;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupportedLocales } from './localization';
|
||||
import type { DydxNetwork } from './networks';
|
||||
import type { OnboardingState, OnboardingSteps } from './account';
|
||||
import type { DydxAddress, WalletType, WalletConnectionType, EthereumAddress } from './wallets';
|
||||
import type { DydxAddress, WalletType, WalletConnectionType, EvmAddress } from './wallets';
|
||||
import type { DialogTypes } from './dialogs';
|
||||
import type { TradeTypes } from './trade';
|
||||
import type { AbacusApiStatus, HumanReadablePlaceOrderPayload } from './abacus';
|
||||
@@ -40,7 +40,7 @@ export type AnalyticsUserPropertyValue<T extends AnalyticsUserProperty> =
|
||||
: T extends AnalyticsUserProperty.WalletConnectionType
|
||||
? WalletConnectionType | undefined
|
||||
: T extends AnalyticsUserProperty.WalletAddress
|
||||
? EthereumAddress | DydxAddress | undefined
|
||||
? EvmAddress | DydxAddress | undefined
|
||||
: // Account
|
||||
T extends AnalyticsUserProperty.DydxAddress
|
||||
? DydxAddress | undefined
|
||||
|
||||
@@ -337,7 +337,7 @@ export const SIGN_TYPED_DATA = {
|
||||
|
||||
export type PrivateInformation = ReturnType<typeof onboarding.deriveHDKeyFromEthereumSignature>;
|
||||
|
||||
export type EthereumAddress = `0x${string}`;
|
||||
export type EvmAddress = `0x${string}`;
|
||||
export type DydxAddress = `dydx${string}`;
|
||||
|
||||
export const DYDX_CHAIN_INFO: Parameters<typeof suggestChain>[0] = {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { formatUnits } from 'viem';
|
||||
|
||||
import { CLIENT_NETWORK_CONFIGS } from '@/constants/networks';
|
||||
import { QUANTUM_MULTIPLIER } from '@/constants/numbers';
|
||||
import { EthereumAddress } from '@/constants/wallets';
|
||||
import { EvmAddress } from '@/constants/wallets';
|
||||
|
||||
import { convertBech32Address } from '@/lib/addressUtils';
|
||||
import { MustBigNumber } from '@/lib/numbers';
|
||||
@@ -59,7 +59,7 @@ export const useAccountBalance = ({
|
||||
token:
|
||||
addressOrDenom === CHAIN_DEFAULT_TOKEN_ADDRESS
|
||||
? undefined
|
||||
: (addressOrDenom as EthereumAddress),
|
||||
: (addressOrDenom as EvmAddress),
|
||||
watch: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { LocalWallet, USDC_DENOM, type Subaccount } from '@dydxprotocol/v4-clien
|
||||
|
||||
import { OnboardingGuard, OnboardingState, type EvmDerivedAddresses } from '@/constants/account';
|
||||
import { LocalStorageKey, LOCAL_STORAGE_VERSIONS } from '@/constants/localStorage';
|
||||
import { DydxAddress, EthereumAddress, PrivateInformation } from '@/constants/wallets';
|
||||
import { DydxAddress, EvmAddress, PrivateInformation } from '@/constants/wallets';
|
||||
|
||||
import {
|
||||
setOnboardingState,
|
||||
@@ -82,7 +82,7 @@ const useAccountsContext = () => {
|
||||
evmAddress,
|
||||
dydxAddress,
|
||||
}: {
|
||||
evmAddress: EthereumAddress;
|
||||
evmAddress: EvmAddress;
|
||||
dydxAddress?: DydxAddress;
|
||||
}) => {
|
||||
saveEvmDerivedAddresses({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createContext, useContext, useCallback, useEffect, useMemo } from 'react';
|
||||
import { useQuery } from 'react-query';
|
||||
import type { StatusResponse } from '@0xsquid/sdk';
|
||||
|
||||
import { LocalStorageKey } from '@/constants/localStorage';
|
||||
import { type TransferNotifcation } from '@/constants/notifications';
|
||||
@@ -8,8 +9,6 @@ import { useAccounts } from '@/hooks/useAccounts';
|
||||
import { useSquid } from '@/hooks/useSquid';
|
||||
import { useLocalStorage } from './useLocalStorage';
|
||||
|
||||
import { StatusResponse } from '@0xsquid/sdk';
|
||||
|
||||
const LocalNotificationsContext = createContext<
|
||||
ReturnType<typeof useLocalNotificationsContext> | undefined
|
||||
>(undefined);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { LocalStorageKey } from '@/constants/localStorage';
|
||||
|
||||
import {
|
||||
type DydxAddress,
|
||||
type EthereumAddress,
|
||||
type EvmAddress,
|
||||
WalletConnectionType,
|
||||
WalletType,
|
||||
wallets,
|
||||
@@ -38,7 +38,7 @@ export const useWalletConnection = () => {
|
||||
const stringGetter = useStringGetter();
|
||||
|
||||
// EVM wallet connection
|
||||
const [evmAddress, saveEvmAddress] = useLocalStorage<EthereumAddress | undefined>({
|
||||
const [evmAddress, saveEvmAddress] = useLocalStorage<EvmAddress | undefined>({
|
||||
key: LocalStorageKey.EvmAddress,
|
||||
defaultValue: undefined,
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@ import { AlertType } from '@/constants/alerts';
|
||||
import { ButtonSize } from '@/constants/buttons';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { NumberSign } from '@/constants/numbers';
|
||||
import type { EvmAddress } from '@/constants/wallets';
|
||||
|
||||
import { useAccounts, useDebounce, useStringGetter } from '@/hooks';
|
||||
import { useAccountBalance } from '@/hooks/useAccountBalance';
|
||||
@@ -36,6 +37,7 @@ import { getTransferInputs } from '@/state/inputsSelectors';
|
||||
|
||||
import abacusStateManager from '@/lib/abacus';
|
||||
import { MustBigNumber } from '@/lib/numbers';
|
||||
import { log } from '@/lib/telemetry';
|
||||
|
||||
import { ChainSelectMenu } from './ChainSelectMenu';
|
||||
import { TokenSelectMenu } from './TokenSelectMenu';
|
||||
@@ -177,10 +179,10 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
if (sourceToken?.address === NATIVE_TOKEN_ADDRESS) return;
|
||||
|
||||
const allowance = await publicClientWagmi.readContract({
|
||||
address: sourceToken.address as `0x${string}`,
|
||||
address: sourceToken.address as EvmAddress,
|
||||
abi: erc20,
|
||||
functionName: 'allowance',
|
||||
args: [evmAddress as `0x${string}`, requestPayload.targetAddress as `0x${string}`]
|
||||
args: [evmAddress as EvmAddress, requestPayload.targetAddress as EvmAddress]
|
||||
});
|
||||
|
||||
const sourceAmountBN = parseUnits(debouncedAmount, sourceToken.decimals);
|
||||
@@ -188,10 +190,10 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
if (sourceAmountBN > (allowance as bigint)) {
|
||||
const { request } = await publicClientWagmi.simulateContract({
|
||||
account: evmAddress,
|
||||
address: sourceToken.address as `0x${string}`,
|
||||
address: sourceToken.address as EvmAddress,
|
||||
abi: erc20,
|
||||
functionName: 'approve',
|
||||
args: [requestPayload.targetAddress as `0x${string}`, sourceAmountBN],
|
||||
args: [requestPayload.targetAddress as EvmAddress, sourceAmountBN],
|
||||
})
|
||||
|
||||
const approveTx = await signerWagmi.writeContract(request);
|
||||
@@ -225,8 +227,8 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
await validateTokenApproval();
|
||||
|
||||
let tx = {
|
||||
to: requestPayload.targetAddress as `0x${string}`,
|
||||
data: requestPayload.data as `0x${string}`,
|
||||
to: requestPayload.targetAddress as EvmAddress,
|
||||
data: requestPayload.data as EvmAddress,
|
||||
gasLimit: BigInt(requestPayload.gasLimit),
|
||||
value:
|
||||
requestPayload.routeType !== 'SEND' ? BigInt(requestPayload.value) : undefined,
|
||||
@@ -247,7 +249,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
setFromAmount('');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
log('DepositForm/onSubmit', error);
|
||||
setError(error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user