Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cdee2813f |
@@ -110,18 +110,18 @@ export const notificationTypes = [
|
|||||||
const stringGetter = useStringGetter();
|
const stringGetter = useStringGetter();
|
||||||
const { transferNotifications } = useLocalNotifications();
|
const { transferNotifications } = useLocalNotifications();
|
||||||
|
|
||||||
const getTitleStringKey = useCallback((type: 'deposit' | 'withdraw', finished: boolean) => {
|
const getTitleStringKey = useCallback((type: 'deposit' | 'withdrawal', finished: boolean) => {
|
||||||
if (type === 'deposit' && !finished) return STRING_KEYS.DEPOSIT_IN_PROGRESS;
|
if (type === 'deposit' && !finished) return STRING_KEYS.DEPOSIT_IN_PROGRESS;
|
||||||
if (type === 'deposit' && finished) return STRING_KEYS.DEPOSIT;
|
if (type === 'deposit' && finished) return STRING_KEYS.DEPOSIT;
|
||||||
if (type === 'withdraw' && !finished) return STRING_KEYS.WITHDRAW_IN_PROGRESS;
|
if (type === 'withdrawal' && !finished) return STRING_KEYS.WITHDRAW_IN_PROGRESS;
|
||||||
return STRING_KEYS.WITHDRAW;
|
return STRING_KEYS.WITHDRAW;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
for (const transfer of transferNotifications) {
|
for (const transfer of transferNotifications) {
|
||||||
const { toChainId, status, txHash, toAmount } = transfer;
|
const { fromChainId, status, txHash, toAmount } = transfer;
|
||||||
const finished = Boolean(status) && status?.squidTransactionStatus !== 'ongoing';
|
const finished = Boolean(status) && status?.squidTransactionStatus !== 'ongoing';
|
||||||
const type = toChainId === TESTNET_CHAIN_ID ? 'deposit' : 'withdraw';
|
const type = fromChainId === TESTNET_CHAIN_ID ? 'withdrawal' : 'deposit';
|
||||||
// @ts-ignore status.errors is not in the type definition but can be returned
|
// @ts-ignore status.errors is not in the type definition but can be returned
|
||||||
const error = status?.errors?.length ? status?.errors[0] : status?.error;
|
const error = status?.errors?.length ? status?.errors[0] : status?.error;
|
||||||
|
|
||||||
@@ -154,6 +154,7 @@ export const notificationTypes = [
|
|||||||
description: description,
|
description: description,
|
||||||
customContent: (
|
customContent: (
|
||||||
<TransferStatusToast
|
<TransferStatusToast
|
||||||
|
type={type}
|
||||||
toAmount={transfer.toAmount}
|
toAmount={transfer.toAmount}
|
||||||
triggeredAt={transfer.triggeredAt}
|
triggeredAt={transfer.triggeredAt}
|
||||||
status={transfer.status}
|
status={transfer.status}
|
||||||
@@ -162,7 +163,7 @@ export const notificationTypes = [
|
|||||||
customMenuContent: !finished && (
|
customMenuContent: !finished && (
|
||||||
<div>
|
<div>
|
||||||
{description}
|
{description}
|
||||||
<TransferStatusSteps status={transfer.status} />
|
<TransferStatusSteps status={transfer.status} type={type} />
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
toastSensitivity: 'foreground',
|
toastSensitivity: 'foreground',
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useCallback, useState, useMemo } from 'react';
|
import { useCallback, useState, useMemo } from 'react';
|
||||||
import styled, { type AnyStyledComponent } from 'styled-components';
|
import styled, { type AnyStyledComponent } from 'styled-components';
|
||||||
import { TESTNET_CHAIN_ID } from '@dydxprotocol/v4-client-js';
|
|
||||||
import { Root, Trigger, Content } from '@radix-ui/react-collapsible';
|
import { Root, Trigger, Content } from '@radix-ui/react-collapsible';
|
||||||
import { StatusResponse } from '@0xsquid/sdk';
|
import { StatusResponse } from '@0xsquid/sdk';
|
||||||
|
|
||||||
@@ -21,12 +20,14 @@ import { LoadingDots } from '@/components/Loading/LoadingDots';
|
|||||||
import { layoutMixins } from '@/styles/layoutMixins';
|
import { layoutMixins } from '@/styles/layoutMixins';
|
||||||
|
|
||||||
type ElementProps = {
|
type ElementProps = {
|
||||||
|
type: 'withdrawal' | 'deposit';
|
||||||
toAmount?: number;
|
toAmount?: number;
|
||||||
triggeredAt?: number;
|
triggeredAt?: number;
|
||||||
status?: StatusResponse;
|
status?: StatusResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TransferStatusToast = ({
|
export const TransferStatusToast = ({
|
||||||
|
type,
|
||||||
toAmount,
|
toAmount,
|
||||||
triggeredAt = Date.now(),
|
triggeredAt = Date.now(),
|
||||||
status,
|
status,
|
||||||
@@ -38,11 +39,6 @@ export const TransferStatusToast = ({
|
|||||||
// @ts-ignore status.errors is not in the type definition but can be returned
|
// @ts-ignore status.errors is not in the type definition but can be returned
|
||||||
const error = status?.errors?.length ? status?.errors[0] : status?.error;
|
const error = status?.errors?.length ? status?.errors[0] : status?.error;
|
||||||
|
|
||||||
const type = useMemo(
|
|
||||||
() => (status?.toChain?.chainData?.chainId === TESTNET_CHAIN_ID ? 'deposit' : 'withdrawal'),
|
|
||||||
[status]
|
|
||||||
);
|
|
||||||
|
|
||||||
const updateSecondsLeft = useCallback(() => {
|
const updateSecondsLeft = useCallback(() => {
|
||||||
const fromChainEta = (status?.fromChain?.chainData?.estimatedRouteDuration || 0) * 1000;
|
const fromChainEta = (status?.fromChain?.chainData?.estimatedRouteDuration || 0) * 1000;
|
||||||
const toChainEta = (status?.toChain?.chainData?.estimatedRouteDuration || 0) * 1000;
|
const toChainEta = (status?.toChain?.chainData?.estimatedRouteDuration || 0) * 1000;
|
||||||
@@ -69,7 +65,7 @@ export const TransferStatusToast = ({
|
|||||||
side="bottom"
|
side="bottom"
|
||||||
slotReceipt={
|
slotReceipt={
|
||||||
<Styled.Receipt>
|
<Styled.Receipt>
|
||||||
<TransferStatusSteps status={status} />
|
<TransferStatusSteps status={status} type={type} />
|
||||||
</Styled.Receipt>
|
</Styled.Receipt>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import styled, { css, keyframes, type AnyStyledComponent } from 'styled-components';
|
import styled, { css, keyframes, type AnyStyledComponent } from 'styled-components';
|
||||||
import { StatusResponse } from '@0xsquid/sdk';
|
import { StatusResponse } from '@0xsquid/sdk';
|
||||||
import { TESTNET_CHAIN_ID } from '@dydxprotocol/v4-client-js';
|
|
||||||
|
|
||||||
import { useStringGetter } from '@/hooks';
|
import { useStringGetter } from '@/hooks';
|
||||||
|
|
||||||
@@ -15,6 +14,7 @@ import { STRING_KEYS } from '@/constants/localization';
|
|||||||
|
|
||||||
type ElementProps = {
|
type ElementProps = {
|
||||||
status?: StatusResponse;
|
status?: StatusResponse;
|
||||||
|
type: 'withdrawal' | 'deposit';
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TransferStatusStep {
|
enum TransferStatusStep {
|
||||||
@@ -24,14 +24,13 @@ enum TransferStatusStep {
|
|||||||
Complete,
|
Complete,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TransferStatusSteps = ({ status }: ElementProps) => {
|
export const TransferStatusSteps = ({ status, type }: ElementProps) => {
|
||||||
const stringGetter = useStringGetter();
|
const stringGetter = useStringGetter();
|
||||||
|
|
||||||
const { currentStep, steps, type } = useMemo(() => {
|
const { currentStep, steps } = useMemo(() => {
|
||||||
const routeStatus = status?.routeStatus;
|
const routeStatus = status?.routeStatus;
|
||||||
const fromChain = status?.fromChain?.chainData?.chainId;
|
const fromChain = status?.fromChain?.chainData?.chainId;
|
||||||
const toChain = status?.toChain?.chainData?.chainId;
|
const toChain = status?.toChain?.chainData?.chainId;
|
||||||
const type = toChain === TESTNET_CHAIN_ID ? 'deposit' : 'withdrawal';
|
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
{
|
{
|
||||||
@@ -74,6 +73,10 @@ export const TransferStatusSteps = ({ status }: ElementProps) => {
|
|||||||
currentStep = TransferStatusStep.FromChain;
|
currentStep = TransferStatusStep.FromChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status?.squidTransactionStatus === 'success') {
|
||||||
|
currentStep = TransferStatusStep.Complete;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentStep,
|
currentStep,
|
||||||
steps,
|
steps,
|
||||||
|
|||||||
Reference in New Issue
Block a user