From 6ee04beb00e91cae07f35e4e4e6e71d5a2680093 Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 3 Mar 2021 15:45:24 -0500 Subject: [PATCH 1/4] Added list of locked funds accounts in the front page --- .../src/hooks/useLockedFundsAccounts.tsx | 95 +++++++++++++++++++ packages/bridge/src/utils/assets.ts | 21 ++++ packages/bridge/src/utils/ids.ts | 5 + packages/bridge/src/views/home/index.tsx | 63 +++++++----- packages/bridge/src/views/home/itemStyle.less | 3 +- .../src/components/EtherscanLink/index.tsx | 39 ++++++++ 6 files changed, 202 insertions(+), 24 deletions(-) create mode 100644 packages/bridge/src/hooks/useLockedFundsAccounts.tsx create mode 100644 packages/bridge/src/utils/assets.ts create mode 100644 packages/bridge/src/utils/ids.ts create mode 100644 packages/common/src/components/EtherscanLink/index.tsx diff --git a/packages/bridge/src/hooks/useLockedFundsAccounts.tsx b/packages/bridge/src/hooks/useLockedFundsAccounts.tsx new file mode 100644 index 0000000..d2aadb9 --- /dev/null +++ b/packages/bridge/src/hooks/useLockedFundsAccounts.tsx @@ -0,0 +1,95 @@ +import {useEffect, useState} from "react"; +import {contexts} from "@oyster/common"; +import * as BufferLayout from 'buffer-layout' +import {WORMHOLE_PROGRAM_ID} from "../utils/ids"; +import BN from "bn.js"; +import {getAssetAmountInUSD, getAssetName, getAssetTokenSymbol} from "../utils/assets"; + +const { useConnection } = contexts.Connection; + +interface ParsedData { + amount: number, + rawAmount: string, + parsedAssetAddress: string, + parsedAccount: any, + assetDecimals: number, + tokenName: string, + tokenSymbol: string, + sourceAddress: string, + targetAddress: string, + amountInUSD: number, +} + +export const useLockedFundsAccounts = () => { + const connection = useConnection(); + + const [lockedSolanaAccounts, setLockedSolanaAccounts] = useState([]); + const [loading, setLoading] = useState(true); + useEffect(() => { + const queryTxs = async () => { + setLoading(true); + const programAccounts = await connection.getProgramAccounts( + WORMHOLE_PROGRAM_ID + ); + const dataLayout = BufferLayout.struct([ + BufferLayout.blob(32, 'amount'), + BufferLayout.u8('toChain'), + BufferLayout.blob(32, 'sourceAddress'), + BufferLayout.blob(32, 'targetAddress'), + BufferLayout.blob(32, 'assetAddress'), + BufferLayout.u8('assetChain'), + BufferLayout.u8('assetDecimals'), + BufferLayout.seq(BufferLayout.u8(), 1), // 4 byte alignment because a u32 is following + BufferLayout.u32('nonce'), + BufferLayout.blob(1001, 'vaa'), + BufferLayout.seq(BufferLayout.u8(), 3), // 4 byte alignment because a u32 is following + BufferLayout.u32('vaaTime'), + BufferLayout.u32('lockupTime'), + BufferLayout.u8('pokeCounter'), + BufferLayout.blob(32, 'signatureAccount'), + BufferLayout.u8('initialized'), + ]); + const filteredParsedAccounts: ParsedData[] = []; + programAccounts.map(acc => { + try { + const parsedAccount = dataLayout.decode(acc.account.data) + + if ((parsedAccount.assetChain === 1 || parsedAccount.assetChain ===2 ) && + (parsedAccount.toChain === 1 || parsedAccount.toChain === 2)) { + const dec = new BN(10).pow(new BN(parsedAccount.assetDecimals)); + const rawAmount = new BN(parsedAccount.amount, 2, "le") + const amount = rawAmount.div(dec).toNumber(); + const parsedAssetAddress: string = new Buffer(parsedAccount.assetAddress.slice(12)).toString("hex") + const parsedData: ParsedData = { + amount: amount, + rawAmount: rawAmount.toString(), + parsedAssetAddress: parsedAssetAddress, + parsedAccount: parsedAccount, + assetDecimals: parsedAccount.assetDecimals, + sourceAddress: new Buffer(parsedAccount.sourceAddress.slice(12)).toString("hex"), + targetAddress: new Buffer(parsedAccount.targetAddress.slice(12)).toString("hex"), + tokenName: getAssetName(parsedAssetAddress, parsedAccount.assetChain), + tokenSymbol: getAssetTokenSymbol(parsedAssetAddress, parsedAccount.assetChain), + amountInUSD: getAssetAmountInUSD(amount, parsedAssetAddress, parsedAccount.assetChain), + }; + filteredParsedAccounts.push(parsedData) + } + } catch (error){ + return + } + }); + return filteredParsedAccounts; + } + Promise.all([queryTxs()]).then((all) => { + setLoading(false); + setLockedSolanaAccounts(all[0]) + }); + }, []); + return { + loading, + lockedSolanaAccounts, + total: lockedSolanaAccounts.reduce((acc, val) => { + return acc + val.amountInUSD; + }, 0) + }; +} \ No newline at end of file diff --git a/packages/bridge/src/utils/assets.ts b/packages/bridge/src/utils/assets.ts new file mode 100644 index 0000000..1a661d2 --- /dev/null +++ b/packages/bridge/src/utils/assets.ts @@ -0,0 +1,21 @@ +export const getAssetName = ( + parsedAssetAddress: string, + assetChain: number, +) => { + return parsedAssetAddress.slice(0, 5); +}; + +export const getAssetTokenSymbol = ( + parsedAssetAddress: string, + assetChain: number, +) => { + return parsedAssetAddress.slice(0, 5); +}; + +export const getAssetAmountInUSD = ( + amount: number, + parsedAssetAddress: string, + assetChain: number, +) => { + return amount; +}; diff --git a/packages/bridge/src/utils/ids.ts b/packages/bridge/src/utils/ids.ts new file mode 100644 index 0000000..4211530 --- /dev/null +++ b/packages/bridge/src/utils/ids.ts @@ -0,0 +1,5 @@ +import { PublicKey } from '@solana/web3.js'; + +export const WORMHOLE_PROGRAM_ID = new PublicKey( + 'WormT3McKhFJ2RkiGpdw9GKvNCrB2aB54gb2uV9MfQC', +); diff --git a/packages/bridge/src/views/home/index.tsx b/packages/bridge/src/views/home/index.tsx index fdc5168..46472d9 100644 --- a/packages/bridge/src/views/home/index.tsx +++ b/packages/bridge/src/views/home/index.tsx @@ -1,14 +1,16 @@ import { MintInfo } from '@solana/spl-token'; import { Table, Tag, Space, Card, Col, Row, Statistic, Button } from 'antd'; -import React, { useEffect, useState } from 'react'; +import React, {useEffect, useMemo, useState} from 'react'; import { GUTTER, LABELS } from '../../constants'; -import { contexts, ParsedAccount, utils } from '@oyster/common'; +import {contexts, ExplorerLink, ParsedAccount, utils} from '@oyster/common'; import { useMarkets } from '../../contexts/market'; import { LendingReserveItem } from './item'; import './itemStyle.less'; import { Totals } from '../../models/totals'; import { Link } from 'react-router-dom'; +import {useLockedFundsAccounts} from "../../hooks/useLockedFundsAccounts"; +import {EtherscanLink} from "@oyster/common/dist/lib/components/EtherscanLink"; const { fromLamports, getTokenName, wadToLamports } = utils; const { cache } = contexts.Accounts; const { useConnectionConfig } = contexts.Connection; @@ -16,6 +18,7 @@ const { useConnectionConfig } = contexts.Connection; export const HomeView = () => { const { marketEmitter, midPriceInUSD } = useMarkets(); const { tokenMap } = useConnectionConfig(); + const {loading: loadingLockedAccounts, lockedSolanaAccounts, total: totalLocked } = useLockedFundsAccounts(); const [totals, setTotals] = useState({ marketSize: 0, numberOfAssets: 0, @@ -76,36 +79,50 @@ export const HomeView = () => { }; }, [marketEmitter, midPriceInUSD, setTotals, tokenMap]); - const dataSource = [ - { - key: '1', - name: 'Mike', - age: 32, - address: '10 Downing Street', - }, - { - key: '2', - name: 'John', - age: 42, - address: '10 Downing Street', - }, - ]; + const dataSource = useMemo(() => { + if (loadingLockedAccounts) return []; + console.log(lockedSolanaAccounts) + return lockedSolanaAccounts.map((acc, index) => { + return { + key: index.toString(), + symbol: acc.tokenSymbol, + name: acc.tokenName, + amount: acc.amountInUSD, + sourceAddress: acc.parsedAccount.assetChain === 1 ? + : + , + targetAddress: acc.parsedAccount.toChain === 1 ? + : + , + } + }) + }, [loadingLockedAccounts, lockedSolanaAccounts]) const columns = [ + { + title: 'Symbol', + dataIndex: 'symbol', + key: 'symbol', + }, { title: 'Name', dataIndex: 'name', key: 'name', }, { - title: 'Age', - dataIndex: 'age', - key: 'age', + title: 'Amount', + dataIndex: 'amount', + key: 'amount', }, { - title: 'Address', - dataIndex: 'address', - key: 'address', + title: 'Source Address', + dataIndex: 'sourceAddress', + key: 'sourceAddress', + }, + { + title: 'Target Address', + dataIndex: 'targetAddress', + key: 'targetAddress', }, ]; @@ -127,7 +144,7 @@ export const HomeView = () => { diff --git a/packages/bridge/src/views/home/itemStyle.less b/packages/bridge/src/views/home/itemStyle.less index eea3fcf..388fcd2 100644 --- a/packages/bridge/src/views/home/itemStyle.less +++ b/packages/bridge/src/views/home/itemStyle.less @@ -33,4 +33,5 @@ .home-info-row { margin-bottom: 10px; -} \ No newline at end of file + min-height: 45vh; +} diff --git a/packages/common/src/components/EtherscanLink/index.tsx b/packages/common/src/components/EtherscanLink/index.tsx new file mode 100644 index 0000000..321febb --- /dev/null +++ b/packages/common/src/components/EtherscanLink/index.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { Typography } from 'antd'; +import { shortenAddress } from '../../utils/utils'; + +export const EtherscanLink = (props: { + address: string ; + type: string; + code?: boolean; + style?: React.CSSProperties; + length?: number; +}) => { + const { type, code } = props; + + const address = props.address; + + if (!address) { + return null; + } + + const length = props.length ?? 9; + + return ( + + {code ? ( + + {shortenAddress(address, length)} + + ) : ( + shortenAddress(address, length) + )} + + ); +}; From bbedbae8c6f20fc11a6804cf3f9b0852eec014b8 Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 3 Mar 2021 15:45:24 -0500 Subject: [PATCH 2/4] Added list of locked funds accounts in the front page --- .../src/hooks/useLockedFundsAccounts.tsx | 95 +++++++++++++++++++ packages/bridge/src/utils/assets.ts | 21 ++++ packages/bridge/src/utils/ids.ts | 5 + packages/bridge/src/views/home/index.tsx | 63 +++++++----- packages/bridge/src/views/home/itemStyle.less | 3 +- .../src/components/EtherscanLink/index.tsx | 39 ++++++++ 6 files changed, 202 insertions(+), 24 deletions(-) create mode 100644 packages/bridge/src/hooks/useLockedFundsAccounts.tsx create mode 100644 packages/bridge/src/utils/assets.ts create mode 100644 packages/bridge/src/utils/ids.ts create mode 100644 packages/common/src/components/EtherscanLink/index.tsx diff --git a/packages/bridge/src/hooks/useLockedFundsAccounts.tsx b/packages/bridge/src/hooks/useLockedFundsAccounts.tsx new file mode 100644 index 0000000..d2aadb9 --- /dev/null +++ b/packages/bridge/src/hooks/useLockedFundsAccounts.tsx @@ -0,0 +1,95 @@ +import {useEffect, useState} from "react"; +import {contexts} from "@oyster/common"; +import * as BufferLayout from 'buffer-layout' +import {WORMHOLE_PROGRAM_ID} from "../utils/ids"; +import BN from "bn.js"; +import {getAssetAmountInUSD, getAssetName, getAssetTokenSymbol} from "../utils/assets"; + +const { useConnection } = contexts.Connection; + +interface ParsedData { + amount: number, + rawAmount: string, + parsedAssetAddress: string, + parsedAccount: any, + assetDecimals: number, + tokenName: string, + tokenSymbol: string, + sourceAddress: string, + targetAddress: string, + amountInUSD: number, +} + +export const useLockedFundsAccounts = () => { + const connection = useConnection(); + + const [lockedSolanaAccounts, setLockedSolanaAccounts] = useState([]); + const [loading, setLoading] = useState(true); + useEffect(() => { + const queryTxs = async () => { + setLoading(true); + const programAccounts = await connection.getProgramAccounts( + WORMHOLE_PROGRAM_ID + ); + const dataLayout = BufferLayout.struct([ + BufferLayout.blob(32, 'amount'), + BufferLayout.u8('toChain'), + BufferLayout.blob(32, 'sourceAddress'), + BufferLayout.blob(32, 'targetAddress'), + BufferLayout.blob(32, 'assetAddress'), + BufferLayout.u8('assetChain'), + BufferLayout.u8('assetDecimals'), + BufferLayout.seq(BufferLayout.u8(), 1), // 4 byte alignment because a u32 is following + BufferLayout.u32('nonce'), + BufferLayout.blob(1001, 'vaa'), + BufferLayout.seq(BufferLayout.u8(), 3), // 4 byte alignment because a u32 is following + BufferLayout.u32('vaaTime'), + BufferLayout.u32('lockupTime'), + BufferLayout.u8('pokeCounter'), + BufferLayout.blob(32, 'signatureAccount'), + BufferLayout.u8('initialized'), + ]); + const filteredParsedAccounts: ParsedData[] = []; + programAccounts.map(acc => { + try { + const parsedAccount = dataLayout.decode(acc.account.data) + + if ((parsedAccount.assetChain === 1 || parsedAccount.assetChain ===2 ) && + (parsedAccount.toChain === 1 || parsedAccount.toChain === 2)) { + const dec = new BN(10).pow(new BN(parsedAccount.assetDecimals)); + const rawAmount = new BN(parsedAccount.amount, 2, "le") + const amount = rawAmount.div(dec).toNumber(); + const parsedAssetAddress: string = new Buffer(parsedAccount.assetAddress.slice(12)).toString("hex") + const parsedData: ParsedData = { + amount: amount, + rawAmount: rawAmount.toString(), + parsedAssetAddress: parsedAssetAddress, + parsedAccount: parsedAccount, + assetDecimals: parsedAccount.assetDecimals, + sourceAddress: new Buffer(parsedAccount.sourceAddress.slice(12)).toString("hex"), + targetAddress: new Buffer(parsedAccount.targetAddress.slice(12)).toString("hex"), + tokenName: getAssetName(parsedAssetAddress, parsedAccount.assetChain), + tokenSymbol: getAssetTokenSymbol(parsedAssetAddress, parsedAccount.assetChain), + amountInUSD: getAssetAmountInUSD(amount, parsedAssetAddress, parsedAccount.assetChain), + }; + filteredParsedAccounts.push(parsedData) + } + } catch (error){ + return + } + }); + return filteredParsedAccounts; + } + Promise.all([queryTxs()]).then((all) => { + setLoading(false); + setLockedSolanaAccounts(all[0]) + }); + }, []); + return { + loading, + lockedSolanaAccounts, + total: lockedSolanaAccounts.reduce((acc, val) => { + return acc + val.amountInUSD; + }, 0) + }; +} \ No newline at end of file diff --git a/packages/bridge/src/utils/assets.ts b/packages/bridge/src/utils/assets.ts new file mode 100644 index 0000000..1a661d2 --- /dev/null +++ b/packages/bridge/src/utils/assets.ts @@ -0,0 +1,21 @@ +export const getAssetName = ( + parsedAssetAddress: string, + assetChain: number, +) => { + return parsedAssetAddress.slice(0, 5); +}; + +export const getAssetTokenSymbol = ( + parsedAssetAddress: string, + assetChain: number, +) => { + return parsedAssetAddress.slice(0, 5); +}; + +export const getAssetAmountInUSD = ( + amount: number, + parsedAssetAddress: string, + assetChain: number, +) => { + return amount; +}; diff --git a/packages/bridge/src/utils/ids.ts b/packages/bridge/src/utils/ids.ts new file mode 100644 index 0000000..4211530 --- /dev/null +++ b/packages/bridge/src/utils/ids.ts @@ -0,0 +1,5 @@ +import { PublicKey } from '@solana/web3.js'; + +export const WORMHOLE_PROGRAM_ID = new PublicKey( + 'WormT3McKhFJ2RkiGpdw9GKvNCrB2aB54gb2uV9MfQC', +); diff --git a/packages/bridge/src/views/home/index.tsx b/packages/bridge/src/views/home/index.tsx index fdc5168..46472d9 100644 --- a/packages/bridge/src/views/home/index.tsx +++ b/packages/bridge/src/views/home/index.tsx @@ -1,14 +1,16 @@ import { MintInfo } from '@solana/spl-token'; import { Table, Tag, Space, Card, Col, Row, Statistic, Button } from 'antd'; -import React, { useEffect, useState } from 'react'; +import React, {useEffect, useMemo, useState} from 'react'; import { GUTTER, LABELS } from '../../constants'; -import { contexts, ParsedAccount, utils } from '@oyster/common'; +import {contexts, ExplorerLink, ParsedAccount, utils} from '@oyster/common'; import { useMarkets } from '../../contexts/market'; import { LendingReserveItem } from './item'; import './itemStyle.less'; import { Totals } from '../../models/totals'; import { Link } from 'react-router-dom'; +import {useLockedFundsAccounts} from "../../hooks/useLockedFundsAccounts"; +import {EtherscanLink} from "@oyster/common/dist/lib/components/EtherscanLink"; const { fromLamports, getTokenName, wadToLamports } = utils; const { cache } = contexts.Accounts; const { useConnectionConfig } = contexts.Connection; @@ -16,6 +18,7 @@ const { useConnectionConfig } = contexts.Connection; export const HomeView = () => { const { marketEmitter, midPriceInUSD } = useMarkets(); const { tokenMap } = useConnectionConfig(); + const {loading: loadingLockedAccounts, lockedSolanaAccounts, total: totalLocked } = useLockedFundsAccounts(); const [totals, setTotals] = useState({ marketSize: 0, numberOfAssets: 0, @@ -76,36 +79,50 @@ export const HomeView = () => { }; }, [marketEmitter, midPriceInUSD, setTotals, tokenMap]); - const dataSource = [ - { - key: '1', - name: 'Mike', - age: 32, - address: '10 Downing Street', - }, - { - key: '2', - name: 'John', - age: 42, - address: '10 Downing Street', - }, - ]; + const dataSource = useMemo(() => { + if (loadingLockedAccounts) return []; + console.log(lockedSolanaAccounts) + return lockedSolanaAccounts.map((acc, index) => { + return { + key: index.toString(), + symbol: acc.tokenSymbol, + name: acc.tokenName, + amount: acc.amountInUSD, + sourceAddress: acc.parsedAccount.assetChain === 1 ? + : + , + targetAddress: acc.parsedAccount.toChain === 1 ? + : + , + } + }) + }, [loadingLockedAccounts, lockedSolanaAccounts]) const columns = [ + { + title: 'Symbol', + dataIndex: 'symbol', + key: 'symbol', + }, { title: 'Name', dataIndex: 'name', key: 'name', }, { - title: 'Age', - dataIndex: 'age', - key: 'age', + title: 'Amount', + dataIndex: 'amount', + key: 'amount', }, { - title: 'Address', - dataIndex: 'address', - key: 'address', + title: 'Source Address', + dataIndex: 'sourceAddress', + key: 'sourceAddress', + }, + { + title: 'Target Address', + dataIndex: 'targetAddress', + key: 'targetAddress', }, ]; @@ -127,7 +144,7 @@ export const HomeView = () => { diff --git a/packages/bridge/src/views/home/itemStyle.less b/packages/bridge/src/views/home/itemStyle.less index eea3fcf..388fcd2 100644 --- a/packages/bridge/src/views/home/itemStyle.less +++ b/packages/bridge/src/views/home/itemStyle.less @@ -33,4 +33,5 @@ .home-info-row { margin-bottom: 10px; -} \ No newline at end of file + min-height: 45vh; +} diff --git a/packages/common/src/components/EtherscanLink/index.tsx b/packages/common/src/components/EtherscanLink/index.tsx new file mode 100644 index 0000000..321febb --- /dev/null +++ b/packages/common/src/components/EtherscanLink/index.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { Typography } from 'antd'; +import { shortenAddress } from '../../utils/utils'; + +export const EtherscanLink = (props: { + address: string ; + type: string; + code?: boolean; + style?: React.CSSProperties; + length?: number; +}) => { + const { type, code } = props; + + const address = props.address; + + if (!address) { + return null; + } + + const length = props.length ?? 9; + + return ( + + {code ? ( + + {shortenAddress(address, length)} + + ) : ( + shortenAddress(address, length) + )} + + ); +}; From 31526061b6daa21d64499a6632dff1ced159f6dc Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 3 Mar 2021 16:03:26 -0500 Subject: [PATCH 3/4] style --- packages/bridge/src/App.less | 4 ---- packages/bridge/src/views/home/index.tsx | 1 - 2 files changed, 5 deletions(-) diff --git a/packages/bridge/src/App.less b/packages/bridge/src/App.less index e24f0a1..275cb5e 100644 --- a/packages/bridge/src/App.less +++ b/packages/bridge/src/App.less @@ -152,10 +152,6 @@ em { display: none; } -.ant-table-container table > thead > tr th { - text-align: center; -} - .ant-notification { a { color: blue; diff --git a/packages/bridge/src/views/home/index.tsx b/packages/bridge/src/views/home/index.tsx index 46472d9..ad347a3 100644 --- a/packages/bridge/src/views/home/index.tsx +++ b/packages/bridge/src/views/home/index.tsx @@ -81,7 +81,6 @@ export const HomeView = () => { const dataSource = useMemo(() => { if (loadingLockedAccounts) return []; - console.log(lockedSolanaAccounts) return lockedSolanaAccounts.map((acc, index) => { return { key: index.toString(), From bc75c4e0235c3cd894ee23e5b7622cca0dbb1c0a Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 3 Mar 2021 16:12:35 -0500 Subject: [PATCH 4/4] added enum to chain types --- packages/bridge/src/hooks/useLockedFundsAccounts.tsx | 8 ++++---- packages/bridge/src/utils/assets.ts | 5 +++++ packages/bridge/src/views/home/index.tsx | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/bridge/src/hooks/useLockedFundsAccounts.tsx b/packages/bridge/src/hooks/useLockedFundsAccounts.tsx index d2aadb9..6d33e4c 100644 --- a/packages/bridge/src/hooks/useLockedFundsAccounts.tsx +++ b/packages/bridge/src/hooks/useLockedFundsAccounts.tsx @@ -3,7 +3,7 @@ import {contexts} from "@oyster/common"; import * as BufferLayout from 'buffer-layout' import {WORMHOLE_PROGRAM_ID} from "../utils/ids"; import BN from "bn.js"; -import {getAssetAmountInUSD, getAssetName, getAssetTokenSymbol} from "../utils/assets"; +import {ASSET_CHAIN, getAssetAmountInUSD, getAssetName, getAssetTokenSymbol} from "../utils/assets"; const { useConnection } = contexts.Connection; @@ -53,9 +53,9 @@ export const useLockedFundsAccounts = () => { programAccounts.map(acc => { try { const parsedAccount = dataLayout.decode(acc.account.data) - - if ((parsedAccount.assetChain === 1 || parsedAccount.assetChain ===2 ) && - (parsedAccount.toChain === 1 || parsedAccount.toChain === 2)) { + const chains = [ASSET_CHAIN.Solana, ASSET_CHAIN.Ethereum] + if (chains.indexOf(parsedAccount.assetChain) >= 0 && + chains.indexOf(parsedAccount.toChain) >= 0) { const dec = new BN(10).pow(new BN(parsedAccount.assetDecimals)); const rawAmount = new BN(parsedAccount.amount, 2, "le") const amount = rawAmount.div(dec).toNumber(); diff --git a/packages/bridge/src/utils/assets.ts b/packages/bridge/src/utils/assets.ts index 1a661d2..5c303bb 100644 --- a/packages/bridge/src/utils/assets.ts +++ b/packages/bridge/src/utils/assets.ts @@ -19,3 +19,8 @@ export const getAssetAmountInUSD = ( ) => { return amount; }; + +export enum ASSET_CHAIN { + Solana = 1, + Ethereum = 2, +} diff --git a/packages/bridge/src/views/home/index.tsx b/packages/bridge/src/views/home/index.tsx index ad347a3..65ad95c 100644 --- a/packages/bridge/src/views/home/index.tsx +++ b/packages/bridge/src/views/home/index.tsx @@ -11,6 +11,7 @@ import { Totals } from '../../models/totals'; import { Link } from 'react-router-dom'; import {useLockedFundsAccounts} from "../../hooks/useLockedFundsAccounts"; import {EtherscanLink} from "@oyster/common/dist/lib/components/EtherscanLink"; +import {ASSET_CHAIN} from "../../utils/assets"; const { fromLamports, getTokenName, wadToLamports } = utils; const { cache } = contexts.Accounts; const { useConnectionConfig } = contexts.Connection; @@ -87,10 +88,10 @@ export const HomeView = () => { symbol: acc.tokenSymbol, name: acc.tokenName, amount: acc.amountInUSD, - sourceAddress: acc.parsedAccount.assetChain === 1 ? + sourceAddress: acc.parsedAccount.assetChain === ASSET_CHAIN.Solana ? : , - targetAddress: acc.parsedAccount.toChain === 1 ? + targetAddress: acc.parsedAccount.toChain === ASSET_CHAIN.Solana ? : , }