Skip to content

Commit

Permalink
Fix the issue with displaying updated text
Browse files Browse the repository at this point in the history
  • Loading branch information
VegeBun-csj committed Jul 28, 2024
1 parent 3fd576a commit 6e29391
Show file tree
Hide file tree
Showing 32 changed files with 205 additions and 407 deletions.
6 changes: 2 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ const Content = () => {
items={[
{
value: MigrateTabs.Migrate,
label: stringGetter({ key: STRING_KEYS.MIGRATE }),
label: "Migrate",
forceMount: true,
content: <MigratePage />,
},
{
value: MigrateTabs.PendingMigrations,
label: stringGetter({
key: STRING_KEYS.PENDING_MIGRATIONS,
}),
label: 'Pending Migrations',
forceMount: true,
content: <PendingMigrationsPage />,
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const CopyButton = ({
onClick={onCopy}
>
<Icon iconName={IconName.Copy} />
{children ?? stringGetter({ key: copied ? STRING_KEYS.COPIED : STRING_KEYS.COPY })}
{children ?? (copied ? 'Copied' : 'Copy')}
</Button>
);
};
Expand Down
20 changes: 9 additions & 11 deletions src/components/TimeoutButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ export const TimeoutButton = ({

const secondsLeft = Math.max(0, (timeoutDeadline - now) / 1000);

const getWaitSecondsMessage = (secondsLeft: number) => {
const seconds = Math.ceil(secondsLeft);
return seconds === 1
? `Wait for ${seconds} second`
: `Wait for ${seconds} seconds`;
};
const waitSecondsMessage = secondsLeft ? getWaitSecondsMessage(secondsLeft) : children;

return (
<Button
{...otherProps}
Expand All @@ -34,17 +42,7 @@ export const TimeoutButton = ({
(otherProps?.state as ButtonStateConfig)?.isDisabled,
}}
>
{secondsLeft
? stringGetter({
key:
Math.ceil(secondsLeft) === 1
? STRING_KEYS.WAIT_SECONDS_SINGULAR
: STRING_KEYS.WAIT_SECONDS,
params: {
SECONDS: String(Math.ceil(secondsLeft)),
},
})
: children}
{waitSecondsMessage}
</Button>
);
};
18 changes: 17 additions & 1 deletion src/constants/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export enum SupportedLocales {
export const DORA_KEYS = {
"DORA_CHAIN_SETTLEMENT": 'Dora vota-ash Chain settlement',
"DORA_EXPLORER" : 'Dora vota explorer',

"VOTA_CHAIN" : 'vota-ash Chain',
"ETHEREUM": 'Ethereum'
}

export const DORA_LONG_SENTENCE = {
Expand All @@ -36,6 +37,21 @@ export const DORA_LONG_SENTENCE = {
"PENDING_MIGRATIONS_DESCRIPTION_I": 'This table lists all ongoing DORA token migrations from Ethereum to the Dora vota-ash Chain. It refreshes periodically or upon a manual page reload.',
"PENDING_MIGRATIONS_DESCRIPTION_II": 'Once a pending migration is listed, the migration will be completed within ~48 hours. Once the migration has been settled, it will be removed from this table during the next automatic update or when the page is manually refreshed.',
"PENDING_MIGRATIONS_DESCRIPTION_III": 'However, you can see all your migration records (including those that are pending or have been settled) in the "Mine" option. Please note that if the migration is pending, the Transaction Hash will display as 0x0000...00000. If your migration is settled, it will display the link of transaction hash of the successful migration on the Dora vota-ash network.',
"MIGRATION_FAQ_DYDX_CHAIN_PORTAL": "What is the dYdX Chain Portal?",
"MIGRATION_FAQ_DYDX_CHAIN_PORTAL_ANSWER": "The dYdX Community elected to migrate Ethereum-based DYDX to dYdX Chain (vote {HERE}). This portal assists Ethereum-based DYDX holders to engage with the Ethereum smart contract to migrate their DYDX tokens from Ethereum to dYdX Chain.",
"MIGRATION_FAQ_GAS_FEES_ANSWER": "Yes, holders who engage with the portal will have to pay gas costs on Ethereum. Users will not have to pay gas costs on dYdX Chain.",
"MIGRATION_FAQ_GAS_FEES": "Do I have to pay gas fees?",
"MIGRATION_FAQ_HOW_LONG_ANSWER": "Once Ethereum-based DYDX is successfully sent to the Ethereum smart contract, a holder will receive wethDYDX immediately. dYdX Chain validators will acknowledge the Ethereum tx after it is finalized (which takes roughly 20 minutes). After dYdX Chain validators acknowledge the Ethereum tx, dYdX Chain DYDX settlement will be delayed for 86400 blocks, which translates into roughly 38.5 hours. After the 86400 block delay, dYdX Chain validators will send the dYdX Chain address the specified amount of DYDX.",
"MIGRATION_FAQ_HOW_LONG": "How long should the migration take?",
"MIGRATION_FAQ_HOW_TO_TRACK_ANSWER": "Once your Ethereum tx has been finalized (which takes roughly 20 minutes), you can track your pending dYdX Chain migration in Pending Migrations tab. You can filter the table by pasting a dYdX Chain address to see all of its pending migrations. Once the pending migration has settled to the dYdX Chain Address, the pending migration will no longer be shown in the table.",
"MIGRATION_FAQ_HOW_TO_TRACK": "How can I track the status of my migration?",
"MIGRATION_FAQ_WHAT_ADDRESS_ANSWER": "Users who interact with the portal can send dYdX Chain DYDX tokens to any dYdX Chain address. User’s can send tokens directly to their dYdX Chain address that is automatically created from their Ethereum address’s signature.",
"MIGRATION_FAQ_WHAT_ADDRESS": "What address can I send dYdX Chain DYDX to?",
"MIGRATION_FAQ_WHAT_TOKENS_ANSWER": "Holders who successfully engage with the portal will receive wethDYDX on Ethereum and DYDX on dYdX Chain.",
"MIGRATION_FAQ_WHAT_TOKENS": "What tokens will I receive?",
"MIGRATION_FAQ_WRAPPED_TOKENS_ANSWER": "wethDYDX are minted 1:1 to any users who successfully send Ethereum-based DYDX to the smart contract. wethDYDX have the same v3 governance rights as Ethereum-based DYDX, and are transferable. wethDYDX cannot be bridged to v4.",
"MIGRATION_FAQ_WRAPPED_TOKENS": "What are wrapped Ethereum DYDX tokens (“wethDYDX”)?",
"MIGRATION_BLOCKED_MESSAGE_DESTINATION": "Because the destination address appears to be a resident of, or using this user interface from, a jurisdiction that violates our terms of use, or has engaged in activity that violates our terms of use, the destination address has been blocked and this transaction cannot be completed.",
}

export const EN_LOCALE_DATA = {
Expand Down
8 changes: 4 additions & 4 deletions src/constants/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const WALLET_CONNECT_EXPLORER_RECOMMENDED_IDS = Object.values(
export const wallets: Record<WalletType, WalletConfig> = {
[WalletType.OtherWallet]: {
type: WalletType.OtherWallet,
stringKey: STRING_KEYS.OTHER_WALLET,
stringKey: "Other",
icon: GenericWalletIcon,
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
matchesInjectedEip1193: (provider) =>
Expand All @@ -105,22 +105,22 @@ export const wallets: Record<WalletType, WalletConfig> = {
},
[WalletType.CoinbaseWallet]: {
type: WalletType.CoinbaseWallet,
stringKey: STRING_KEYS.COINBASE_WALLET,
stringKey: "Coinbase Wallet",
icon: CoinbaseIcon,
connectionTypes: [WalletConnectionType.CoinbaseWalletSdk, WalletConnectionType.InjectedEip1193],
matchesInjectedEip1193: (provider) => provider.isCoinbaseWallet,
},
[WalletType.MetaMask]: {
type: WalletType.MetaMask,
stringKey: STRING_KEYS.METAMASK,
stringKey: "MetaMask",
icon: MetaMaskIcon,
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
matchesInjectedEip1193: isMetaMask,
walletconnect2Id: WALLET_CONNECT_EXPLORER_RECOMMENDED_WALLETS.Metamask,
},
[WalletType.WalletConnect2]: {
type: WalletType.WalletConnect2,
stringKey: STRING_KEYS.WALLET_CONNECT_2,
stringKey: "WalletConnect",
icon: WalletConnectIcon,
connectionTypes: [WalletConnectionType.WalletConnect2],
},
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useDydxClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const useDydxClientContext = () => {
// ------ Client Initialization ------ //
const [compositeClient, setCompositeClient] = useState<CompositeClient>();

useEffect(() => {
/* useEffect(() => {
(async () => {
try {
const initializedClient = await CompositeClient.connect(
Expand Down Expand Up @@ -54,7 +54,7 @@ const useDydxClientContext = () => {
console.error(error);
}
})();
}, []);
}, []); */

// ------ Wallet Methods ------ //
const getWalletFromEvmSignature = async ({ signature }: { signature: string }) => {
Expand Down
6 changes: 2 additions & 4 deletions src/hooks/useMigrateToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useContext, createContext, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import BigNumber from 'bignumber.js';

import { STRING_KEYS } from '@/constants/localization';
import { STRING_KEYS, DORA_LONG_SENTENCE } from '@/constants/localization';

import {
MigrateFormSteps,
Expand Down Expand Up @@ -145,9 +145,7 @@ const useMigrateTokenContext = () => {
return;
} else if (screenResults?.[destinationAddress!]) {
setErrorMsg(
stringGetter({
key: STRING_KEYS.MIGRATION_BLOCKED_MESSAGE_DESTINATION,
})
DORA_LONG_SENTENCE.MIGRATION_BLOCKED_MESSAGE_DESTINATION
);
return;
}
Expand Down
18 changes: 12 additions & 6 deletions src/hooks/usePendingMigrationsData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const usePendingMigrationsData = ({
);
const [addressSearchFilter, setAddressSearchFilter] = useState<string>('');

const [PendingMigrations, setPendingMigrations] = useState<PendingMigrationData[]>([]);
// const [PendingMigrations, setPendingMigrations] = useState<PendingMigrationData[]>([]);
const [filteredPendingMigrations, setFilteredPendingMigrations] = useState<
PendingMigrationData[]
>([]);
Expand Down Expand Up @@ -76,11 +76,16 @@ export const usePendingMigrationsData = ({
enabled: unprocessedCount > 0,
queryKey: ['pollPendingMigrations', unprocessedCount],
queryFn: async () => {
// 直接返回 unprocessedRecordsData
console.log(`查询未处理的数据。。。。。。。。`)
return unprocessedRecordsData;
},
select: (data) => {
if (!data) return [];
// let [size, records] = data
if (!data) {
console.log('Data is undefined or null');
return [];
}
console.log(`data is ${data}`);
if (Array.isArray(data) && data.length === 2) {
const [size, records] = data;
return records.map((record, idx) => ({
Expand All @@ -89,16 +94,17 @@ export const usePendingMigrationsData = ({
'dora',
fromHex(record.vota.startsWith('0x') ? record.vota.slice(2) : record.vota)
),
amount: BigNumber(record.amount).shiftedBy(-18)?.toFixed() ?? '0',
amount: BigNumber(record.amount).shiftedBy(-18).toFixed(),
txHash: ethers.hexlify(record.txHash),
})) as PendingMigrationData[];
}
console.log(`data is ${data}`);
console.log(`data is not in expected format: ${data}`);
return [];
},
refetchInterval: interval,
staleTime: interval,
});

console.log(pendingMigrations);
console.log(`fetch error is ${fetchPendingMigrationsError}`)

Expand Down
10 changes: 5 additions & 5 deletions src/lib/timeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ export const getStringsForTimeInterval = (timeInterval: Duration) => {

if (months > 0) {
timeString = Math.round(months).toString();
unitStringKey = STRING_KEYS.MONTHS_ABBREVIATED;
unitStringKey = "M";
} else if (weeks > 0) {
timeString = Math.round(weeks + days / 7).toString();
unitStringKey = STRING_KEYS.WEEKS_ABBREVIATED;
unitStringKey = "w";
} else if (days > 0) {
timeString = Math.round(days + hours / 24).toString();
unitStringKey = STRING_KEYS.DAYS_ABBREVIATED;
unitStringKey = "d";
} else if (hours > 0) {
timeString = Math.round(hours + minutes / 60).toString();
unitStringKey = STRING_KEYS.HOURS_ABBREVIATED;
unitStringKey = "h";
} else {
timeString = Math.ceil(minutes).toString();
unitStringKey = STRING_KEYS.MINUTES_ABBREVIATED;
unitStringKey = "m";
}

return {
Expand Down
7 changes: 1 addition & 6 deletions src/lib/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ export const parseWalletError = ({
break;
}
default: {
message = stringGetter({
key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE,
params: {
ERROR_MESSAGE: error.message || stringGetter({ key: STRING_KEYS.UNKNOWN_ERROR }),
},
});
message = `Something went wrong: ${error.message || 'Unknown error'}`;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/views/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export const Header = () => {
items: [
{
value: 'MIGRATE',
label: stringGetter({ key: STRING_KEYS.MIGRATE }),
label: 'Migrate',
active: true,
href: '/',
},
{
value: 'MORE',
label: stringGetter({ key: STRING_KEYS.MORE }),
label: 'More',
subitems: RELEVANT_LINKS.map((linkItem) => ({
value: linkItem.value,
slotBefore: linkItem.iconName ? <Icon iconName={linkItem.iconName} /> : undefined,
Expand Down
69 changes: 20 additions & 49 deletions src/views/HelpPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled, { AnyStyledComponent } from 'styled-components';

import { STRING_KEYS } from '@/constants/localization';
import { STRING_KEYS, DORA_LONG_SENTENCE } from '@/constants/localization';
import { AppRoute } from '@/constants/routes';

import breakpoints from '@/styles/breakpoints';
Expand All @@ -19,80 +19,51 @@ export const HelpPanel = () => {
<Styled.HelpCard
slotHeader={
<Styled.Header>
<h3>{stringGetter({ key: STRING_KEYS.MIGRATION_HELP })}</h3>
<Link withIcon href="https://www.dydx.foundation/how-to-bridge/">
{stringGetter({ key: STRING_KEYS.LEARN_MORE })}
<h3>Migration help</h3>
<Link withIcon href="https://docs.dorafactory.org/docs">
Learn More
</Link>
</Styled.Header>
}
>
<Accordion
items={[
{
header: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_DYDX_CHAIN_PORTAL,
}),
content: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_DYDX_CHAIN_PORTAL_ANSWER,
params: {
HERE: (
<Styled.Link withIcon href="https://dydx.community/dashboard/proposal/15">
{stringGetter({ key: STRING_KEYS.HERE })}
</Styled.Link>
),
},
}),
header: DORA_LONG_SENTENCE.MIGRATION_FAQ_DYDX_CHAIN_PORTAL,
content: DORA_LONG_SENTENCE.MIGRATION_FAQ_DYDX_CHAIN_PORTAL_ANSWER,
},
{
header: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_WHAT_TOKENS,
}),
header: DORA_LONG_SENTENCE.MIGRATION_FAQ_WHAT_TOKENS,
content: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_WHAT_TOKENS_ANSWER,
key: DORA_LONG_SENTENCE.MIGRATION_FAQ_WHAT_TOKENS_ANSWER,
}),
},
{
header: stringGetter({ key: STRING_KEYS.MIGRATION_FAQ_HOW_LONG }),
content: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_HOW_LONG_ANSWER,
}),
header: DORA_LONG_SENTENCE.MIGRATION_FAQ_HOW_LONG,
content: DORA_LONG_SENTENCE.MIGRATION_FAQ_HOW_LONG_ANSWER,
},
{
header: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_HOW_TO_TRACK,
}),
content: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_HOW_TO_TRACK_ANSWER,
}),
header: DORA_LONG_SENTENCE.MIGRATION_FAQ_HOW_TO_TRACK,
content: DORA_LONG_SENTENCE.MIGRATION_FAQ_HOW_TO_TRACK_ANSWER,
},
{
header: stringGetter({ key: STRING_KEYS.MIGRATION_FAQ_GAS_FEES }),
content: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_GAS_FEES_ANSWER,
}),
header: DORA_LONG_SENTENCE.MIGRATION_FAQ_GAS_FEES,
content: DORA_LONG_SENTENCE.MIGRATION_FAQ_GAS_FEES_ANSWER,
},
{
header: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_WHAT_ADDRESS,
}),
content: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_WHAT_ADDRESS_ANSWER,
}),
header: DORA_LONG_SENTENCE.MIGRATION_FAQ_WHAT_ADDRESS,
content: DORA_LONG_SENTENCE.MIGRATION_FAQ_WHAT_ADDRESS_ANSWER,
},
{
header: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_WRAPPED_TOKENS,
}),
content: stringGetter({
key: STRING_KEYS.MIGRATION_FAQ_WRAPPED_TOKENS_ANSWER,
}),
header: DORA_LONG_SENTENCE.MIGRATION_FAQ_WRAPPED_TOKENS,
content: DORA_LONG_SENTENCE.MIGRATION_FAQ_WRAPPED_TOKENS_ANSWER,
},
]}
/>
</Styled.HelpCard>

<Styled.TermsLink href={`/#${AppRoute.Terms}`} withIcon>
{stringGetter({ key: STRING_KEYS.TERMS_OF_USE })}
Terms of Use
</Styled.TermsLink>
</Styled.Container>
);
Expand All @@ -102,7 +73,7 @@ const Styled: Record<string, AnyStyledComponent> = {};

Styled.Container = styled.div`
text-align: center;
@media ${breakpoints.notTablet} {
width: max-content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const FinalizingCountdownTimer = ({

return (
<Styled.Tag>
{stringGetter({ key: STRING_KEYS.FINALIZING })}
Finalizing
{secondsRemaining > 0 ? ` ${minutes}:${seconds}` : '...'}
</Styled.Tag>
);
Expand Down
Loading

0 comments on commit 6e29391

Please sign in to comment.