diff --git a/src/components/Wallet/Tabs/Tabs.js b/src/components/Wallet/Tabs/Tabs.js index a71403a8..f29b3be5 100644 --- a/src/components/Wallet/Tabs/Tabs.js +++ b/src/components/Wallet/Tabs/Tabs.js @@ -22,10 +22,6 @@ export default function({activeTab, setActiveTab, isBecomeValidator, address}) {
Transactions
-
setActiveTab(1)}> - -
Royalty Transactions
-
{dataRes?.data && dataRes?.data?.length > 0 && (
setActiveTab(6)}>
CW-20 Token Txns
@@ -34,7 +30,6 @@ export default function({activeTab, setActiveTab, isBecomeValidator, address}) { {isBecomeValidator && (
setActiveTab(3)}> - {/*
{isBecomeValidator ? "Your Delegators" : "Become A Validator"}
*/}
Your Delegators
)} @@ -46,10 +41,6 @@ export default function({activeTab, setActiveTab, isBecomeValidator, address}) {
Contact
-
setActiveTab(5)}> - -
AI Executor
-
); } diff --git a/src/containers/Ibc/Ibc.js b/src/containers/Ibc/Ibc.js deleted file mode 100644 index fde5001e..00000000 --- a/src/containers/Ibc/Ibc.js +++ /dev/null @@ -1,141 +0,0 @@ -import React, {useState, useRef, useEffect} from "react"; -import {useHistory} from "react-router-dom"; -import {useTheme} from "@material-ui/core/styles"; -import useMediaQuery from "@material-ui/core/useMediaQuery"; -import Container from "@material-ui/core/Container"; -import cn from "classnames/bind"; -import {useGet} from "restful-react"; -import consts from "src/constants/consts"; -import {_} from "src/lib/scripts"; -import TogglePageBar from "src/components/common/TogglePageBar"; -import TitleWrapper from "src/components/common/TitleWrapper"; -import PageTitle from "src/components/common/PageTitle"; -import ChainBox from "src/components/common/ChainBox"; -import Pagination from "src/components/common/Pagination"; -import AssetsIbcTable from "src/components/Ibc/AssetsIbcTable/AssetsIbcTable"; -import AssetsIbcTableSkeleton from "src/components/Ibc/AssetsIbcTable/AssetsIbcTableSkeleton"; -import AssetsIbcCardList from "src/components/Ibc/AssetsIbcCardList/AssetsIbcCardList"; -import AssetsIbcCardListSkeleton from "src/components/Ibc/AssetsIbcCardList/AssetsIbcCardListSkeleton"; -import FilterSection from "src/components/Ibc/FilterSection"; -import styles from "./Ibc.module.scss"; -const cx = cn.bind(styles); - -const IbcAssets = props => { - const theme = useTheme(); - const isLargeScreen = useMediaQuery(theme.breakpoints.up("lg")); - const history = useHistory(); - const [keyword, setKeyword] = useState(""); - const [chainValue, setChainValue] = useState(0); - const [assetSearch, setAssetSearch] = useState(0); - const [list, setList] = useState([]); - const getPaginationPath = (pathname, page) => { - return pathname + "?page=" + page; - }; - - const [total, setTotal] = useState(-1); - const searchParams = new URLSearchParams(props.location.search); - let page = parseFloat(searchParams.get("page")); - let isPageValid = true; - if (!Number.isInteger(page) || page < 1 || (total !== -1 && page > Math.ceil(total / consts.REQUEST.LIMIT))) { - page = 1; - isPageValid = false; - } - - const [showLoading, setShowLoading] = useState(true); - const [loadCompleted, setLoadCompleted] = useState(false); - let timerID = useRef(null); - - const basePath = `${consts.API_BASE}${consts.API.IBC_TOKENS}`; - const {data, loading, error} = useGet({ - path: basePath, - }); - - useEffect(() => { - if (data?.length > 0) { - let sumChainValue = data != null && data.reduce((acc, cur) => acc + cur?.prices?.TotalValue, 0); - setChainValue(sumChainValue); - setList(data); - } - }, [data]); - - useEffect(() => { - let listFilter = []; - if (!keyword && !assetSearch) { - listFilter = data; - } else { - if (keyword && !assetSearch) { - listFilter = data && data.filter(ele => ele.symbol.indexOf(keyword) !== -1); - } else if (!keyword && assetSearch) { - assetSearch === 0 ? (listFilter = data) : (listFilter = data && data.filter(ele => (assetSearch === 1 ? !ele.channelId : ele.channelId))); - } else { - listFilter = data && data.filter(ele => (assetSearch === 1 ? !ele.channelId : ele.channelId && ele.symbol.indexOf(keyword) !== -1)); - } - } - setList(listFilter); - }, [keyword, assetSearch]); - - let titleSection; - let filterSection; - let tableSection; - let paginationSection; - - titleSection = isLargeScreen ? ( - - - - - - - ) : ( - - ); - - if (!data || !list || (loading && showLoading)) { - filterSection = ( -
- -
-
- ); - tableSection = isLargeScreen ? : ; - } else { - filterSection = ( -
- { - setKeyword(e.target.value); - }} - /> -
- ); - tableSection = isLargeScreen ? : ; - } - - const onPageChange = page => { - setShowLoading(true); - history.push(getPaginationPath(props.location.pathname, page)); - }; - const totalItems = _.isNil(data?.result?.count) ? 0 : Math.ceil(parseInt(data.result.count)); - const totalPages = Math.ceil(data?.length / consts.REQUEST.LIMIT); - if (total !== totalItems) { - setTotal(totalItems); - } - paginationSection = totalPages > 0 && onPageChange(page)} />; - - return ( - <> - {titleSection} - - {filterSection} - {tableSection} - {paginationSection} - - - ); -}; - -export default IbcAssets; diff --git a/src/containers/Ibc/Ibc.module.scss b/src/containers/Ibc/Ibc.module.scss deleted file mode 100644 index 3a2ea6e6..00000000 --- a/src/containers/Ibc/Ibc.module.scss +++ /dev/null @@ -1,39 +0,0 @@ -@import "src/styles/utils"; - -.ibc-assets { - margin-bottom: 24px; - margin-top: 30px; - - @include media(" import("src/containers/Executors")); -const OracleRequests = lazy(() => import(`src/containers/OracleRequests`)); -const cx = cn.bind(styles); - -let tabsOracle = ["AI Request", "AI Executors"]; -export default function() { - const [status, setStatus] = useState("AI Request"); - let filterSection; - let tableOracle; - let filterData = tabsOracle.map(value => { - const filterItem = { - label: value, - value: value, - }; - return filterItem; - }); - - filterSection = ( - - { - setStatus(value); - }} - /> - - ); - - switch (status) { - case "AI Request": - tableOracle = ; - break; - case "AI Executors": - tableOracle = ; - break; - default: - tableOracle = <> ; - break; - } - - return ( - <> - {filterSection} - {tableOracle} - - ); -} diff --git a/src/containers/OracleAI/OracleAI.module.scss b/src/containers/OracleAI/OracleAI.module.scss deleted file mode 100644 index 8dcb410a..00000000 --- a/src/containers/OracleAI/OracleAI.module.scss +++ /dev/null @@ -1,12 +0,0 @@ -.oracle { - margin-top: 0; - margin-bottom: 30px; - - @media (min-width: 1279px) { - margin-top: 30px; - } - - .filter-section { - margin-top: 0; - } -} diff --git a/src/containers/OracleAI/index.js b/src/containers/OracleAI/index.js deleted file mode 100644 index 506133eb..00000000 --- a/src/containers/OracleAI/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import OracleAI from "./OracleAI"; - -export default OracleAI; diff --git a/src/containers/PriceFeeds/PriceFeeds.js b/src/containers/PriceFeeds/PriceFeeds.js deleted file mode 100644 index 6a18d936..00000000 --- a/src/containers/PriceFeeds/PriceFeeds.js +++ /dev/null @@ -1,146 +0,0 @@ -// @ts-nocheck -import React, {useEffect, useState, useRef} from "react"; -import cn from "classnames/bind"; -import {useTheme} from "@material-ui/core/styles"; -import useMediaQuery from "@material-ui/core/useMediaQuery"; -import Container from "@material-ui/core/Container"; -import TitleWrapper from "src/components/common/TitleWrapper"; -import PageTitle from "src/components/common/PageTitle"; -import StatusBox from "src/components/common/StatusBox"; -import PriceFeedsGridView from "src/components/PriceFeeds/PriceFeedsGridView"; -import PriceFeedsGridViewSkeleton from "src/components/PriceFeeds/PriceFeedsGridView/PriceFeedsGridViewSkeleton"; -import TogglePageBar from "src/components/common/TogglePageBar"; -import FilterSection from "src/components/PriceFeeds/FilterSection"; -import styles from "./PriceFeeds.module.scss"; -import NoResult from "src/components/common/NoResult"; -import {pricePair} from "src/constants/priceFeed"; -import {getPriceBSCTestnet} from "./bsc-testnet"; -import {getPricePolygon} from "./polygon"; -import {getPriceFeedMainnet} from "./mainnet"; -import {priceFeedNetworks} from "src/constants/priceFeed"; - -const cx = cn.bind(styles); - -const PriceFeeds = ({}) => { - const theme = useTheme(); - const isLargeScreen = useMediaQuery(theme.breakpoints.up("lg")); - const [keyword, setKeyword] = useState(""); - const [network, setNetwork] = useState(priceFeedNetworks.MAINNET); - const [isLoading, setIsLoading] = useState(false); - const networkRef = useRef(priceFeedNetworks.MAINNET); - - const [data, setData] = useState({ - data: [], - }); - const [renewPriceFeed, setRenewPriceFeed] = useState(0); - - let titleSection; - if (isLargeScreen) { - titleSection = ( - - - - - - - ); - } else { - titleSection = ; - } - - const handleChangeNetwork = n => { - networkRef.current = n; - setNetwork(n); - }; - - const filterSection = ; - - useEffect(() => { - const getPriceFeedORAI = async () => { - try { - setIsLoading(true); - const data = await getPriceFeedMainnet(); - networkRef.current === priceFeedNetworks.MAINNET && setData(data); - setIsLoading(false); - } catch (e) { - console.log("error", e); - networkRef.current === priceFeedNetworks.MAINNET && setData(null); - setIsLoading(false); - } - }; - - const getPriceFeedBSC = async () => { - try { - setIsLoading(true); - const data = await getPriceBSCTestnet(pricePair); - networkRef.current === priceFeedNetworks.BSC_TESTNET && setData(data); - setIsLoading(false); - } catch (e) { - console.log("error", e); - networkRef.current === priceFeedNetworks.BSC_TESTNET && setData(null); - setIsLoading(false); - } - }; - - const getPriceFeedPolygon = async () => { - try { - setIsLoading(true); - const data = await getPricePolygon(pricePair); - networkRef.current === priceFeedNetworks.POLYGON && setData(data); - setIsLoading(false); - } catch (e) { - console.log("error", e); - networkRef.current === priceFeedNetworks.POLYGON && setData(null); - setIsLoading(false); - } - }; - - if (network === priceFeedNetworks.BSC_TESTNET) { - getPriceFeedBSC(); - } else if (network === priceFeedNetworks.POLYGON) { - getPriceFeedPolygon(); - } else { - getPriceFeedORAI(); - } - }, [renewPriceFeed, network]); - - useEffect(() => { - let i = 0; - - const renewPriceInterval = setInterval(() => { - i && setRenewPriceFeed(v => v + 1); - i++; - }, 1000 * 60 * 2); - - return () => { - clearInterval(renewPriceInterval); - }; - }, []); - - const renderData = () => { - if (!data) { - return ; - } - - if (isLoading) { - return ; - } - - return ; - }; - - return ( - <> - {titleSection} - - {filterSection} - {renderData()} - - - ); -}; - -PriceFeeds.propTypes = {}; -PriceFeeds.defaultProps = {}; - -export default PriceFeeds; diff --git a/src/containers/PriceFeeds/PriceFeeds.module.scss b/src/containers/PriceFeeds/PriceFeeds.module.scss deleted file mode 100644 index 47ce32cf..00000000 --- a/src/containers/PriceFeeds/PriceFeeds.module.scss +++ /dev/null @@ -1,10 +0,0 @@ -@import "src/styles/utils"; - -.price-feeds { - margin-top: 0; - margin-bottom: 50px; - - @include media(">=large") { - margin-top: 30px; - } -} diff --git a/src/containers/PriceFeeds/abj.js b/src/containers/PriceFeeds/abj.js deleted file mode 100644 index 4ebe1bec..00000000 --- a/src/containers/PriceFeeds/abj.js +++ /dev/null @@ -1,303 +0,0 @@ -export const abiBsc = [ - {inputs: [], stateMutability: "nonpayable", type: "constructor"}, - { - anonymous: false, - inputs: [ - {indexed: true, internalType: "address", name: "previousOwner", type: "address"}, - {indexed: true, internalType: "address", name: "newOwner", type: "address"}, - ], - name: "OwnershipTransferred", - type: "event", - }, - {anonymous: false, inputs: [{indexed: false, internalType: "uint256", name: "blockNumber", type: "uint256"}], name: "PriceDataUpdate", type: "event"}, - {inputs: [], name: "DOMAIN_SEPARATOR", outputs: [{internalType: "bytes32", name: "", type: "bytes32"}], stateMutability: "view", type: "function"}, - {inputs: [], name: "EIP712DOMAIN_TYPEHASH", outputs: [{internalType: "bytes32", name: "", type: "bytes32"}], stateMutability: "view", type: "function"}, - {inputs: [], name: "NAME", outputs: [{internalType: "string", name: "", type: "string"}], stateMutability: "view", type: "function"}, - {inputs: [], name: "UPDATE_PRICE_TYPEHASH", outputs: [{internalType: "bytes32", name: "", type: "bytes32"}], stateMutability: "view", type: "function"}, - { - inputs: [{internalType: "string[]", name: "_symbols", type: "string[]"}], - name: "addAssetSupport", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{internalType: "address", name: "", type: "address"}], - name: "dataSubmitter", - outputs: [{internalType: "bool", name: "", type: "bool"}], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - {internalType: "string", name: "_base", type: "string"}, - {internalType: "string", name: "_quote", type: "string"}, - ], - name: "getPrice", - outputs: [ - { - components: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "lastUpdatedBase", type: "uint64"}, - {internalType: "uint64", name: "lastUpdatedQuote", type: "uint64"}, - ], - internalType: "struct IOraiBase.ResponsePriceData", - name: "", - type: "tuple", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{internalType: "string", name: "_symbol", type: "string"}], - name: "getPrice", - outputs: [ - { - components: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "resolveTime", type: "uint64"}, - ], - internalType: "struct IOraiBase.PriceData", - name: "", - type: "tuple", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - {internalType: "string[]", name: "_bases", type: "string[]"}, - {internalType: "string[]", name: "_quotes", type: "string[]"}, - ], - name: "getPriceBulk", - outputs: [ - { - components: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "lastUpdatedBase", type: "uint64"}, - {internalType: "uint64", name: "lastUpdatedQuote", type: "uint64"}, - ], - internalType: "struct IOraiBase.ResponsePriceData[]", - name: "", - type: "tuple[]", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{internalType: "string[]", name: "_bases", type: "string[]"}], - name: "getPriceBulk", - outputs: [ - { - components: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "resolveTime", type: "uint64"}, - ], - internalType: "struct IOraiBase.PriceData[]", - name: "", - type: "tuple[]", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{internalType: "address", name: "", type: "address"}], - name: "nonces", - outputs: [{internalType: "uint256", name: "", type: "uint256"}], - stateMutability: "view", - type: "function", - }, - {inputs: [], name: "owner", outputs: [{internalType: "address", name: "", type: "address"}], stateMutability: "view", type: "function"}, - { - inputs: [{internalType: "uint16", name: "", type: "uint16"}], - name: "rPrices", - outputs: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "resolveTime", type: "uint64"}, - ], - stateMutability: "view", - type: "function", - }, - {inputs: [], name: "renounceOwnership", outputs: [], stateMutability: "nonpayable", type: "function"}, - { - inputs: [ - {internalType: "address", name: "_submitter", type: "address"}, - {internalType: "bool", name: "approval", type: "bool"}, - ], - name: "setDataSubmitter", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{internalType: "string", name: "", type: "string"}], - name: "supportedAsset", - outputs: [{internalType: "uint16", name: "", type: "uint16"}], - stateMutability: "view", - type: "function", - }, - { - inputs: [{internalType: "uint256", name: "", type: "uint256"}], - name: "symbols", - outputs: [{internalType: "string", name: "", type: "string"}], - stateMutability: "view", - type: "function", - }, - { - inputs: [{internalType: "address", name: "newOwner", type: "address"}], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - {internalType: "uint16[]", name: "_symbolIds", type: "uint16[]"}, - {internalType: "uint128[]", name: "_rates", type: "uint128[]"}, - {internalType: "uint64[]", name: "_resolveTimes", type: "uint64[]"}, - ], - name: "updatePrice", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - {internalType: "uint16[]", name: "_symbolIds", type: "uint16[]"}, - {internalType: "uint128[]", name: "_rates", type: "uint128[]"}, - {internalType: "uint64[]", name: "_resolveTimes", type: "uint64[]"}, - {internalType: "uint256", name: "deadline", type: "uint256"}, - {internalType: "uint256", name: "nonce", type: "uint256"}, - {internalType: "uint8", name: "v", type: "uint8"}, - {internalType: "bytes32", name: "r", type: "bytes32"}, - {internalType: "bytes32", name: "s", type: "bytes32"}, - ], - name: "updatePricePermit", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - {internalType: "bytes32", name: "hash", type: "bytes32"}, - {internalType: "uint256", name: "nonce", type: "uint256"}, - {internalType: "uint8", name: "v", type: "uint8"}, - {internalType: "bytes32", name: "r", type: "bytes32"}, - {internalType: "bytes32", name: "s", type: "bytes32"}, - ], - name: "verify", - outputs: [{internalType: "address", name: "sender", type: "address"}], - stateMutability: "nonpayable", - type: "function", - }, -]; - -export const abiPolygon = [ - {inputs: [{internalType: "contract IOraiBase", name: "_oracle", type: "address"}], stateMutability: "nonpayable", type: "constructor"}, - { - anonymous: false, - inputs: [ - {indexed: true, internalType: "address", name: "previousOwner", type: "address"}, - {indexed: true, internalType: "address", name: "newOwner", type: "address"}, - ], - name: "OwnershipTransferred", - type: "event", - }, - { - inputs: [ - {internalType: "string", name: "_base", type: "string"}, - {internalType: "string", name: "_quote", type: "string"}, - ], - name: "getPrice", - outputs: [ - { - components: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "lastUpdatedBase", type: "uint64"}, - {internalType: "uint64", name: "lastUpdatedQuote", type: "uint64"}, - ], - internalType: "struct IOraiBase.ResponsePriceData", - name: "", - type: "tuple", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{internalType: "string", name: "_base", type: "string"}], - name: "getPrice", - outputs: [ - { - components: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "resolveTime", type: "uint64"}, - ], - internalType: "struct IOraiBase.PriceData", - name: "", - type: "tuple", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - {internalType: "string[]", name: "_bases", type: "string[]"}, - {internalType: "string[]", name: "_quotes", type: "string[]"}, - ], - name: "getPriceBulk", - outputs: [ - { - components: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "lastUpdatedBase", type: "uint64"}, - {internalType: "uint64", name: "lastUpdatedQuote", type: "uint64"}, - ], - internalType: "struct IOraiBase.ResponsePriceData[]", - name: "", - type: "tuple[]", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{internalType: "string[]", name: "_bases", type: "string[]"}], - name: "getPriceBulk", - outputs: [ - { - components: [ - {internalType: "uint128", name: "rate", type: "uint128"}, - {internalType: "uint64", name: "resolveTime", type: "uint64"}, - ], - internalType: "struct IOraiBase.PriceData[]", - name: "", - type: "tuple[]", - }, - ], - stateMutability: "view", - type: "function", - }, - {inputs: [], name: "oracle", outputs: [{internalType: "contract IOraiBase", name: "", type: "address"}], stateMutability: "view", type: "function"}, - {inputs: [], name: "owner", outputs: [{internalType: "address", name: "", type: "address"}], stateMutability: "view", type: "function"}, - {inputs: [], name: "renounceOwnership", outputs: [], stateMutability: "nonpayable", type: "function"}, - { - inputs: [{internalType: "contract IOraiBase", name: "_oracle", type: "address"}], - name: "setOracle", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{internalType: "address", name: "newOwner", type: "address"}], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, -]; diff --git a/src/containers/PriceFeeds/bsc-testnet.js b/src/containers/PriceFeeds/bsc-testnet.js deleted file mode 100644 index 9b249ac3..00000000 --- a/src/containers/PriceFeeds/bsc-testnet.js +++ /dev/null @@ -1,41 +0,0 @@ -import Web3 from "web3"; -import BigNumber from "bignumber.js"; -import _ from "lodash"; - -import {abiBsc} from "./abj"; - -const web3 = new Web3("https://data-seed-prebsc-1-s1.binance.org:8545"); -const contract = new web3.eth.Contract(abiBsc, "0x13f54d67fa23ab3caaef681553cd996f7e9d6237"); - -async function getPriceBSCTestnet(listPair) { - let lastUpdate = new Date().toString(); - const listPairResult = _.cloneDeep(listPair); - const listCoin = listPair.map(v => v.name); - const priceArr = await contract.methods["getPriceBulk"](listCoin).call({ - from: "0x0000000000000000000000000000000000000000", - latest: true, - }); - - console.log(priceArr, "== ==== === ="); - - for (let i = 0; i < listCoin.length; i++) { - if (!priceArr[i][0]) { - continue; - } - listPairResult[i].price = parseFloat( - new BigNumber(priceArr[i][0]) - .dividedBy(Math.pow(10, 18)) - .toFixed(9) - .toString() - ); - listPairResult[i].status = "Active"; - lastUpdate = new Date(parseInt(priceArr[i]["resolveTime"]) * 1000).toString(); - } - - return { - data: listPairResult, - lastUpdate, - }; -} - -export {getPriceBSCTestnet}; diff --git a/src/containers/PriceFeeds/index.js b/src/containers/PriceFeeds/index.js deleted file mode 100644 index c15271f7..00000000 --- a/src/containers/PriceFeeds/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import PriceFeeds from "./PriceFeeds"; - -export default PriceFeeds; diff --git a/src/containers/PriceFeeds/mainnet.js b/src/containers/PriceFeeds/mainnet.js deleted file mode 100644 index e9a9d47e..00000000 --- a/src/containers/PriceFeeds/mainnet.js +++ /dev/null @@ -1,59 +0,0 @@ -import axios from "axios"; -import config from "src/config"; -import { Buffer } from "buffer"; - -import consts from "src/constants/consts"; - -export const getAiOracleRequests = async () => { - const qData = { get_requests_by_service: { service: "orchai_price", limit: 10, order: 2 } }; - const encodeData = Buffer.from(JSON.stringify(qData)).toString("base64"); - - const endpoint = `${consts.LCD_API_BASE}${consts.LCD_API.WASM}/${config.AIORACLE_CONTRACT_ADDR}/smart/${encodeData}`; - const { data: fullRequestData } = await axios.get(endpoint); - - if (fullRequestData?.data?.length > 0) { - for (let stageData of fullRequestData.data) { - // only collect data from the latest stage that has merkle root. - if (stageData.merkle_root) { - return stageData.stage; - } - } - } -}; - -export const getRequestMerkleRootInfor = async stage => { - // url: events=wasm._contract_address='contract_address'&events=wasm.current_stage='stage'&events=wasm.action='register_merkle_root' - const { data: transactionInfor } = await axios.get( - `${consts.LCD_API_BASE}${consts.LCD_API.AI_REQUEST_DATA}` + - `?events=wasm._contract_address=${encodeURIComponent("'" + config.AIORACLE_CONTRACT_ADDR + "'")}` + - `&events=wasm.current_stage=${encodeURIComponent("'" + stage + "'")}` + - "&events=wasm.action='register_merkle_root'" - ); - - return [transactionInfor?.tx_responses[0].height, transactionInfor?.tx_responses[0].txhash]; -}; - -export const getPriceFeedMainnet = async () => { - // collect request id - const stage = await getAiOracleRequests(); - const [merkleRootHeight, merkleRootTxHash] = await getRequestMerkleRootInfor(stage); - if (stage) { - const { data: fullRequestData } = await axios.get( - `${config.AIORACLE_BACKEND}/report/reports?request_id=${parseInt(stage)}&contract_addr=${config.AIORACLE_CONTRACT_ADDR}` - ); - - if (fullRequestData?.data?.data.length > 0) { - let aggregatedResult = []; - aggregatedResult = fullRequestData.data.data.map(item => JSON.parse(atob(item.report.data))); - - // collect block data to display last updated info - const { data: blockData } = await axios.get(`${consts.API_BASE}/blocks?&limit=1&before=${parseInt(merkleRootHeight) + 1}`); - - return { - priceData: aggregatedResult[0], - lastUpdate: blockData?.data[0]?.timestamp, - requestData: [stage, merkleRootHeight, merkleRootTxHash], // only need request id to query the transaction hash of it - }; - } - } -}; diff --git a/src/containers/PriceFeeds/polygon.js b/src/containers/PriceFeeds/polygon.js deleted file mode 100644 index 42afb2ce..00000000 --- a/src/containers/PriceFeeds/polygon.js +++ /dev/null @@ -1,41 +0,0 @@ -import Web3 from "web3"; -import BigNumber from "bignumber.js"; -import _ from "lodash"; - -import {abiPolygon} from "./abj"; - -const web3 = new Web3("https://rpc-mumbai.matic.today"); -const contract = new web3.eth.Contract(abiPolygon, "0x95Fc3900DF04103abd466F276ff8DF98508af708"); - -async function getPricePolygon(listPair) { - let lastUpdate = new Date().toString(); - const listPairResult = _.cloneDeep(listPair); - const listCoin = listPair.map(v => v.name); - const priceArr = await contract.methods["getPriceBulk"](listCoin).call({ - from: "0x0000000000000000000000000000000000000000", - latest: true, - }); - - console.log(priceArr, "== ==== === ="); - - for (let i = 0; i < listCoin.length; i++) { - if (!priceArr[i][0]) { - continue; - } - listPairResult[i].price = parseFloat( - new BigNumber(priceArr[i][0]) - .dividedBy(Math.pow(10, 18)) - .toFixed(9) - .toString() - ); - listPairResult[i].status = "Active"; - lastUpdate = new Date(parseInt(priceArr[i]["resolveTime"]) * 1000).toString(); - } - - return { - data: listPairResult, - lastUpdate, - }; -} - -export {getPricePolygon}; diff --git a/src/containers/Relayers/Channel.module.scss b/src/containers/Relayers/Channel.module.scss deleted file mode 100644 index fa17d9de..00000000 --- a/src/containers/Relayers/Channel.module.scss +++ /dev/null @@ -1,81 +0,0 @@ -.channel-list-wrapper { - padding: 10px; - - .body-list { - border: 1px solid #e6e6e6; - margin-top: 10px; - padding: 5px 0; - color: var(--common-textColor); - border-radius: 8px; - align-items: center; - display: flex; - } - - .body-list.mobile { - border: 1px solid #e6e6e6; - padding: 10px; - } - - .channel-name { - background: var(--common-backGroundColorGray); - border-radius: 8px; - padding: 8px; - } - - .line-wrapper { - width: 100px; - height: 2px; - margin: 18px -40px; - z-index: 1; - } - - .line-wrapper.mobile { - width: 64px; - height: 2px; - margin: -34px -26px; - z-index: 1; - } - - .dot { - border-radius: 50%; - display: inline-block; - width: 10px; - height: 10px; - } - - .flexCenter { - display: flex; - align-items: center; - justify-content: space-between; - } - - .channel-name.partners { - display: flex; - align-items: center; - - .dot { - margin-right: 10px; - } - } - - .pagination { - display: flex; - flex-direction: row-reverse; - margin-top: 15px; - } - - .logo-icon { - color: var(--common-textColor); - height: 24px; - width: 24px; - } -} - -:global(.ant-collapse-icon-position-right > .ant-collapse-item > .ant-collapse-header .ant-collapse-arrow) { - top: 50%; - color: var(--common-textColor); -} - -.fontSize12 { - font-size: 10px; -} diff --git a/src/containers/Relayers/ChannelList.js b/src/containers/Relayers/ChannelList.js deleted file mode 100644 index a8d83193..00000000 --- a/src/containers/Relayers/ChannelList.js +++ /dev/null @@ -1,205 +0,0 @@ -import React, {useMemo, useState} from "react"; -import cn from "classnames/bind"; -import moment from "moment"; -import Row from "antd/lib/row"; -import Col from "antd/lib/col"; -import Space from "antd/lib/space"; -import Avatar from "antd/lib/avatar/avatar"; -import {useHistory} from "react-router-dom"; -import {useTheme} from "@material-ui/core/styles"; -import useMediaQuery from "@material-ui/core/useMediaQuery"; - -// constant -import {STATUS_COLOR, STATE} from "./constants"; - -// components -import Pagination from "src/components/common/Pagination"; - -// logo -import OraiLogoLight from "src/assets/header/logo.svg"; -import OraiLogoDark from "src/assets/header/logo.svg"; - -import OraiIcon from "src/icons/OraiIcon"; - -// styles -import styles from "./Channel.module.scss"; - -const cx = cn.bind(styles); - -const dataLimit = 5; - -const ChannelList = ({channels, channelName, image}) => { - const theme = useTheme(); - const isLargeScreen = useMediaQuery(theme.breakpoints.up("lg")); - const [currentPage, setCurrentPage] = useState(1); - const history = useHistory(); - const totalPages = Math.ceil(channels?.length / dataLimit); - - const onChangePage = page => { - setCurrentPage(page); - }; - - const getPaginatedData = () => { - const startIndex = currentPage * dataLimit - dataLimit; - const endIndex = startIndex + dataLimit; - return channels.slice(startIndex, endIndex); - }; - - const listChannels = getPaginatedData(); - - const renderHeaderChannels = useMemo(() => { - return ( - - -
#
- - -
- - } /> - Oraichain - -
- - - -
- - - {channelName} - -
- - - - - -
Operating Period
- - -
24h Txs
- - -
Value
- -
- ); - }, [channelName]); - - const redirectRelayerDetail = (channelId, status) => { - if (status === STATE.STATE_CLOSED) return; - - return history.push(`/ibc/relayers/${channelId}`); - }; - - const renderChannels = useMemo(() => { - const renderChannelItem = (item, index) => { - var createdAt = moment(item?.channel?.created_at, "YYYY-MM-DD"); - const currentDate = moment().startOf("day"); - const operatingPeriod = moment.duration(currentDate.diff(createdAt)).asDays(); - - return ( - redirectRelayerDetail(item?.channel?.channel_id, item?.channel?.status)}> - -
{index + 1}
- - -
-
{item?.channel?.channel_id}
- -
- - -
- - -
- -
{item?.channel?.counterparty_channel_id}
-
- - - - - -
- {operatingPeriod} {operatingPeriod > 1 ? "Days" : "Day"} -
- - -
{item?.total_txs_within_24h}
- - -
$ {item?.total_value_within_24h?.toFixed(2)}
- - - ); - }; - - const renderChangeItemMobile = (item, index) => { - var createdAt = moment(item?.channel?.created_at, "YYYY-MM-DD"); - const currentDate = moment().startOf("day"); - const operatingPeriod = moment.duration(currentDate.diff(createdAt)).asDays(); - return ( - redirectRelayerDetail(item?.channel?.channel_id, item?.channel?.status)}> - -
-
-
-
Oraichain
-
{item?.channel?.channel_id}
-
- -
-
Operating Period
-
24h Txs
-
Value
-
- - - -
- - - -
-
- -
-
{channelName}
-
{item?.channel?.counterparty_channel_id}
-
-
-
- {operatingPeriod} {operatingPeriod > 1 ? "Days" : "Day"} -
-
{item?.total_txs_within_24h}
-
$ {item?.total_value_within_24h?.toFixed(2)}
-
- - - ); - }; - - return listChannels.map((item, index) => (isLargeScreen ? renderChannelItem(item, index) : renderChangeItemMobile(item, index))); - }, [listChannels, isLargeScreen]); - - return ( -
- {isLargeScreen && renderHeaderChannels} - {renderChannels} -
- {totalPages > 1 && onChangePage(page)} />} -
-
- ); -}; - -export default ChannelList; diff --git a/src/containers/Relayers/Relayers.module.scss b/src/containers/Relayers/Relayers.module.scss deleted file mode 100644 index b339e70d..00000000 --- a/src/containers/Relayers/Relayers.module.scss +++ /dev/null @@ -1,76 +0,0 @@ -@import "src/styles/utils"; - -.relayers { - .page-title { - margin-bottom: 10px; - - h1 { - text-transform: uppercase; - font-size: 24px; - font-weight: 500; - color: var(--common-textColor); - } - } - - .item-list { - margin-bottom: 10px; - border: unset; - box-shadow: 0 0.3rem 0.6rem 0 rgba(0, 0, 0, 0.16); - border-radius: 8px; - } - - .extra-list { - display: flex; - flex-direction: column; - align-items: center; - - &-info { - color: #89909b; - margin-top: 6px; - } - } - - .dot { - border-radius: 50%; - display: inline-block; - width: 10px; - height: 10px; - margin-right: 5px; - } - - .extra-list-tag { - border-radius: 160px; - font-weight: 500; - padding: 5px 10px; - display: flex; - align-items: center; - justify-content: space-between; - } - - :global(h4.ant-list-item-meta-title) { - font-size: 16px; - font-weight: 500; - text-transform: uppercase; - color: var(--common-textColor); - } - - :global(.ant-list-item-meta-description) { - color: var(--common-textColor); - } - - :global(.ant-collapse > .ant-collapse-item) { - border-bottom: unset; - } - - :global(.ant-collapse) { - background-color: var(--common-containerBackgroundColor); - } - - :global(.ant-collapse-content) { - background: var(--common-containerBackgroundColor); - } - - :global(.ant-collapse-content) { - color: var(--common-textColor); - } -} diff --git a/src/containers/Relayers/constants.js b/src/containers/Relayers/constants.js deleted file mode 100644 index 7442e7d5..00000000 --- a/src/containers/Relayers/constants.js +++ /dev/null @@ -1,13 +0,0 @@ -export const STATE = { - STATE_UNINITIALIZED_UNSPECIFIED: "STATE_UNINITIALIZED_UNSPECIFIED", - STATE_INIT: "STATE_INIT", - STATE_TRYOPEN: "STATE_TRYOPEN", - STATE_OPEN: "STATE_OPEN", - STATE_CLOSED: "STATE_CLOSED", -}; - -export const STATUS_COLOR = { - [STATE.STATE_OPEN]: "#37cc6e", - [STATE.STATE_CLOSED]: "#ff2745", - [STATE.STATE_INIT || STATE.STATE_TRYOPEN || STATE.STATE_UNINITIALIZED_UNSPECIFIED]: "#ffb323", -}; diff --git a/src/containers/Relayers/index.js b/src/containers/Relayers/index.js deleted file mode 100644 index d993250d..00000000 --- a/src/containers/Relayers/index.js +++ /dev/null @@ -1,96 +0,0 @@ -import React, { useMemo } from "react"; -import cn from "classnames/bind"; -import { useGet } from "restful-react"; -import List from "antd/lib/list"; -import Avatar from "antd/lib/avatar"; -import Collapse from "antd/lib/collapse"; -import Container from "@material-ui/core/Container"; -import useMediaQuery from "@material-ui/core/useMediaQuery"; -// components -import ChannelList from "./ChannelList"; -import { useTheme } from "@material-ui/core/styles"; -import TogglePageBar from "src/components/common/TogglePageBar"; -import PageTitle from "src/components/common/PageTitle"; -import TitleWrapper from "src/components/common/TitleWrapper"; - -// constants -import { STATUS_COLOR, STATE } from "./constants"; -import consts from "src/constants/consts"; - -// styles -import styles from "./Relayers.module.scss"; - -const cx = cn.bind(styles); -const { Panel } = Collapse; - -const Relayers = () => { - const theme = useTheme(); - const isLargeScreen = useMediaQuery(theme.breakpoints.up("lg")); - const { data } = useGet({ - path: consts.API.IBC_RELAYERS, - }); - - let titleSection; - titleSection = isLargeScreen ? ( - - - - {/* */} - - - ) : ( - - ); - - const dataSource = data && Object.keys(data)?.map(e => { - return { - chainId: e, - ...data[e], - } - }) - - const renderList = useMemo(() => { - const genHeader = item => { - const listStatus = item?.channels?.map(i => i?.channel?.status); - const atLeastOpenStatus = listStatus.some(item => item != STATE.STATE_CLOSED); - const listOpenStatus = item?.channels?.filter(i => i?.channel?.status == STATE.STATE_OPEN); - const colorStatus = atLeastOpenStatus ? STATUS_COLOR[STATE.STATE_OPEN] : STATUS_COLOR[STATE.STATE_CLOSED]; - const backgroundStatus = atLeastOpenStatus ? "rgba(55,204,110,.1)" : "rgba(255,39,69,.1)"; - return ( - - } title={item.name || item.chainId || "UNKNOWN"} description={item?.denom || item?.channels?.[0]?.channel?.channel_id || "unknown"} /> -
-
- -
{atLeastOpenStatus ? "Opened" : "Closed"}
-
-
Channel {`${listOpenStatus?.length}/${listStatus?.length}`}
-
-
- ); - }; - - const renderItem = item => { - return ( - - - - - - ); - }; - - return dataSource?.map(item => renderItem(item)); - }, [dataSource]); - - return ( - <> - {titleSection} - - {renderList} - - - ); -}; - -export default Relayers; diff --git a/src/containers/Router/Router.js b/src/containers/Router/Router.js index a5bcb186..8b30c6af 100644 --- a/src/containers/Router/Router.js +++ b/src/containers/Router/Router.js @@ -22,7 +22,6 @@ const Tx = lazy(() => import(`src/containers/Tx`)); const NotFound = lazy(() => import(`src/containers/NotFound`)); const Account = lazy(() => import(`src/containers/Account`)); const DataSources = lazy(() => import(`src/containers/DataSources`)); -const Ibc = lazy(() => import(`src/containers/Ibc`)); const DataSourcesDetail = lazy(() => import(`src/containers/DataSourcesDetail`)); const TestCases = lazy(() => import(`src/containers/TestCases`)); const OracleScripts = lazy(() => import(`src/containers/OracleScripts`)); @@ -37,15 +36,12 @@ const Requests = lazy(() => import(`src/containers/Requests`)); const RequestReportDetail = lazy(() => import(`src/containers/RequestReportDetail`)); const RequestDetails = lazy(() => import(`src/containers/RequestDetails`)); const Wallet = lazy(() => import(`src/containers/Wallet`)); -const PriceFeeds = lazy(() => import(`src/containers/PriceFeeds`)); const Randomness = lazy(() => import(`src/components/Randomness`)); const RandomnessDetail = lazy(() => import(`src/components/Randomness/RandomnessDetail`)); const OracleRequestDetail = lazy(() => import(`src/containers/OracleRequestDetail`)); const OracleReportDetail = lazy(() => import(`src/containers/OracleReportDetail`)); const ExportData = lazy(() => import(`src/containers/ExportData`)); -const Relayers = lazy(() => import(`src/containers/Relayers`)); const RelayerDetail = lazy(() => import(`src/containers/RelayerDetail`)); -const OracleAI = lazy(() => import(`src/containers/OracleAI`)); const WasmCodeDetail = lazy(() => import(`src/containers/WasmCode`)); export default function(props) { @@ -67,19 +63,15 @@ export default function(props) { - - - - @@ -88,7 +80,6 @@ export default function(props) { - } /> diff --git a/src/containers/Tabs/Tabs.css b/src/containers/Tabs/Tabs.css index 5d93825f..8f484e6b 100644 --- a/src/containers/Tabs/Tabs.css +++ b/src/containers/Tabs/Tabs.css @@ -87,9 +87,6 @@ .dropdown-trans { transform: translate(-103%, 333%) !important; } - .dropdown-ibc { - transform: translate(-103%, 430%) !important; - } .dropdown-validators { transform: translate(-103%, 185%) !important; } @@ -99,9 +96,6 @@ .dropdown-smart { transform: translate(-103%, 530%) !important; } - .dropdown-sub { - transform: translate(-103%, 233%) !important; - } } .dropdown-proposals .MuiButtonBase-root { diff --git a/src/containers/Tabs/Tabs.js b/src/containers/Tabs/Tabs.js index 0b3c55b6..5200b7ff 100644 --- a/src/containers/Tabs/Tabs.js +++ b/src/containers/Tabs/Tabs.js @@ -19,10 +19,7 @@ import DashBoardTabIcon from "src/icons/Tabs/DashBoardTabIcon"; import ProposalsTabIcon from "src/icons/Tabs/ProposalsTabIcon"; import PriceFeedsTabIcon from "src/icons/Tabs/PriceFeedsTabIcon"; import ValidatorsTabIcon from "src/icons/Tabs/ValidatorsTabIcon"; -import TestCaseTabIcon from "src/icons/Tabs/TestCaseTabIcon"; -import RequestsTabIcon from "src/icons/Tabs/RequestsTabIcon"; import TransactionsTabIcon from "src/icons/Tabs/TransactionsTabIcon"; -import IbcTabIcon from "src/icons/Tabs/IbcTabIcon"; import backIcon from "src/assets/header/back_ic.svg"; // functions and components @@ -48,16 +45,11 @@ const Tabs = memo(() => { const [openTransactions, setOpenTransactions] = React.useState(false); const [openProposals, setOpenProposals] = React.useState(false); const [openOracleScripts, setOpenOracleScripts] = React.useState(false); - const [openRequests, setOpenRequests] = React.useState(false); const [openOthers, setOpenOthers] = React.useState(false); - const [openIbc, setOpenIbc] = React.useState(false); const validatorsAnchorRef = React.useRef(null); const transactionsAnchorRef = React.useRef(null); const proposalsAnchorRef = React.useRef(null); const oracleScriptsAnchorRef = React.useRef(null); - const requestsAnchorRef = React.useRef(null); - const othersAnchorRef = React.useRef(null); - const ibcAnchorRef = React.useRef(null); const handleOpenValidators = () => { setOpenValidators(true); @@ -91,14 +83,6 @@ const Tabs = memo(() => { setOpenOracleScripts(false); }; - const handleOpenRequests = () => { - setOpenRequests(true); - }; - - const handleCloseRequests = () => { - setOpenRequests(false); - }; - const handleOpenOthers = () => { setOpenOthers(true); }; @@ -107,14 +91,6 @@ const Tabs = memo(() => { setOpenOthers(false); }; - const handleOpenIbc = () => { - setOpenIbc(true); - }; - - const handleCloseIbc = () => { - setOpenIbc(false); - }; - const renderTabDropdownComponent = ({classNameDropdown, childs, anchorRef, handleOpen, handleClose, open, name, route, img, index, dropdownClassName}) => (