diff --git a/front/src/components/ScheduleTable.tsx b/front/src/components/ScheduleTable.tsx index afaedab..95a375a 100644 --- a/front/src/components/ScheduleTable.tsx +++ b/front/src/components/ScheduleTable.tsx @@ -6,15 +6,17 @@ import CheckBox from './CheckBox'; import useSchedule from '@/services/useSchedule'; import { MasToken, supportedTokens } from '../const/assets'; import ScheduleHistory from '@/components/ScheduleHistory'; +import { getTokenInfo } from '@/utils/assets'; interface ScheduleTableProps { schedules: Schedule[]; } -const CopyableAddress: React.FC<{ address: string; label: string }> = ({ - address, - label, -}) => ( +const CopyableAddress: React.FC<{ + address: string; + label: string; + value: string; +}> = ({ value, address, label }) => ( = ({ toast.success(`${label} copied to clipboard`); }} > - {truncateAddress(address)} + {value} ); @@ -47,7 +49,7 @@ const TableHeader: React.FC = () => ( ].map((header, index) => ( {header} @@ -75,55 +77,59 @@ const TableRow: React.FC = ({ return ( - + - {schedule.id.toString()} - - + {schedule.id.toString()} + + - + {schedule.isVesting ? 'Vesting' : 'Tips'} - + {isMas ? ( 'MAS' ) : ( )} - - + + - + - + {formattedAmount.preview} - - {schedule.interval.toString()} - - + {schedule.interval.toString()} + {schedule.occurrences.toString()} - - {schedule.remaining.toString()} - - - {schedule.tolerance.toString()} - - + {schedule.remaining.toString()} + {schedule.tolerance.toString()} + @@ -172,7 +178,7 @@ const ScheduleTable: React.FC = ({ schedules }) => { )} - +
{schedules.map((schedule) => ( diff --git a/front/src/store/store.ts b/front/src/store/store.ts index f7fc453..e3e106f 100644 --- a/front/src/store/store.ts +++ b/front/src/store/store.ts @@ -1,11 +1,11 @@ import { EventPoller, Provider, SCEvent } from '@massalabs/massa-web3'; import { schedulerAddress } from '../const/contracts'; import { Schedule } from '../serializable/Schedule'; -import { supportedTokens } from '../const/assets'; import { truncateAddress } from '@/utils/address'; import { useAccountStore, formatAmount, toast } from '@massalabs/react-ui-kit'; import { useSchedulerStore } from './scheduler'; import { useTokenStore } from './token'; +import { getTokenInfo } from '@/utils/assets'; export async function initApp() { const { connectedAccount } = useAccountStore.getState(); @@ -80,12 +80,3 @@ function handleTransferEvents(data: SCEvent[], schedules: Schedule[]) { } } } - -function getTokenInfo(tokenAddress: string | null) { - if (!tokenAddress) return { decimals: 9, symbol: 'MAS' }; - - const token = supportedTokens.find((t) => t.address === tokenAddress); - return token - ? { decimals: token.decimals, symbol: token.symbol } - : { decimals: 9, symbol: 'MAS' }; -} diff --git a/front/src/utils/assets.ts b/front/src/utils/assets.ts new file mode 100644 index 0000000..11d98f2 --- /dev/null +++ b/front/src/utils/assets.ts @@ -0,0 +1,21 @@ +import { MasToken, supportedTokens } from '@/const/assets'; + +export function getTokenInfo(tokenAddress: string | null) { + if (!tokenAddress) return MasToken; + + const token = supportedTokens.find((t) => t.address === tokenAddress); + + if (!token) { + return { + name: 'Unknown', + address: tokenAddress, + symbol: 'Unknown', + decimals: 18, + balance: 0n, + allowance: 0n, + chainId: 0, + }; + } + + return token; +}