Skip to content

Commit

Permalink
Merge pull request #1001 from oraichain/hotfix-mainnet-v0.50
Browse files Browse the repository at this point in the history
Hotfix mainnet v0.50
  • Loading branch information
haunv3 authored Nov 13, 2024
2 parents 34a8405 + 2e0caea commit 2323a45
Show file tree
Hide file tree
Showing 22 changed files with 1,318 additions and 219 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"analyze": "source-map-explorer 'build/static/js/*.js'",
"vendor": "node scripts/vendor.js",
"start": "cross-env GENERATE_SOURCEMAP=false react-app-rewired start",
"postinstall": "patch-package",
"postinstall": "patch-package && node script.js",
"build": "cross-env GENERATE_SOURCEMAP=false DISABLE_ESLINT_PLUGIN=true react-app-rewired build",
"delete-maps": "yarn run delete-references-to-map-files && yarn run delete-map-files",
"delete-map-files": "find ./build -name '*.map' -delete",
Expand All @@ -39,7 +39,7 @@
"@material-ui/lab": "^4.0.0-alpha.57",
"@material-ui/styles": "^4.9.0",
"@oraichain/cosmos-messages": "0.0.3",
"@oraichain/oraidex-common": "1.0.72",
"@oraichain/oraidex-common": "^1.1.3",
"@sentry/react": "^7.36.0",
"@sentry/tracing": "^7.36.0",
"@sentry/webpack-plugin": "^1.20.0",
Expand Down Expand Up @@ -134,6 +134,9 @@
"eslintConfig": {
"extends": "react-app"
},
"resolutions": {
"@injectivelabs/sdk-ts": "1.12.1"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
14 changes: 14 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require("fs");

const fix = dirPath => {
if (!fs.existsSync(dirPath)) return;
for (const dir of fs.readdirSync(dirPath)) {
const jsonFile = dirPath + dir + "/package.json";
const packageJson = JSON.parse(fs.readFileSync(jsonFile).toString());
packageJson.module = "dist/cjs/index.js";
fs.writeFileSync(jsonFile, JSON.stringify(packageJson, null, 2));
fix(dirPath + dir + "/" + dirPath);
}
};

fix("node_modules/@injectivelabs/");
2 changes: 2 additions & 0 deletions src/components/Account/AssetsTable/AssetsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const getHeaderRow = () => {

const AssetsTable = memo(({ data = [] }) => {
const priceTokens = useSelector(state => state.blockchain.priceTokens);

const getDataRows = data => {
if (!Array.isArray(data)) {
return [];
Expand All @@ -52,6 +53,7 @@ const AssetsTable = memo(({ data = [] }) => {
});

const tokenUsd = priceTokens[tokenInOraichain?.coinGeckoId] || 0;

if (!tokenInfo && item.validator_address.includes("erc20")) {
tokenInfo = {
name: "ERC20",
Expand Down
20 changes: 13 additions & 7 deletions src/components/Account/DelegationCard/DelegationCard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {memo, useState, useRef} from "react";
import {useGet} from "restful-react";
import React, { memo, useState, useRef } from "react";
import { useGet } from "restful-react";
import classNames from "classnames/bind";
import {useTheme} from "@material-ui/core/styles";
import { useTheme } from "@material-ui/core/styles";
import useMediaQuery from "@material-ui/core/useMediaQuery";
import consts from "src/constants/consts";
import DelegationTable from "src/components/Account/DelegationTable";
Expand All @@ -11,10 +11,11 @@ import DelegationCardListSkeleton from "src/components/Account/DelegationCardLis
import Pagination from "src/components/common/Pagination";
import NoResult from "src/components/common/NoResult";
import styles from "./DelegationCard.module.scss";
import { formatOrai } from "src/helpers/helper";

const cx = classNames.bind(styles);

const DelegationCard = memo(({account = ""}) => {
const DelegationCard = memo(({ account = "" }) => {
const theme = useTheme();
const isLargeScreen = useMediaQuery(theme.breakpoints.up("lg"));
const [pageId, setPageId] = useState(1);
Expand All @@ -25,7 +26,7 @@ const DelegationCard = memo(({account = ""}) => {
};

const path = `${consts.API.DELEGATIONS}/${account}`;
const {data, loading, error} = useGet({
const { data, loading, error } = useGet({
path: path,
});

Expand All @@ -45,8 +46,13 @@ const DelegationCard = memo(({account = ""}) => {
totalPagesRef.current = null;
}

if (Array.isArray(data?.data) && data.data.length > 0) {
tableSection = isLargeScreen ? <DelegationTable data={data.data} /> : <DelegationCardList data={data.data} />;
const delegateData =
Array.isArray(data?.data) && data.data.length > 0
? data?.data.filter(delegate => parseInt(delegate.amount) > 0 || parseFloat(formatOrai(delegate.reward)) >= parseFloat(formatOrai(1)))
: [];

if (delegateData.length > 0) {
tableSection = isLargeScreen ? <DelegationTable data={delegateData} /> : <DelegationCardList data={delegateData} />;
} else {
tableSection = <NoResult />;
}
Expand Down
46 changes: 23 additions & 23 deletions src/components/Dashboard/TransactionCardList/TransactionCardList.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
// @ts-nocheck
import React, {memo} from "react";
import {NavLink} from "react-router-dom";
import React, { memo } from "react";
import { NavLink } from "react-router-dom";
import classNames from "classnames/bind";
import consts from "src/constants/consts";
import {_, reduceString, setAgoTime} from "src/lib/scripts";
import {useSelector} from "react-redux";
import { _, reduceString, setAgoTime } from "src/lib/scripts";
import { useSelector } from "react-redux";
import styles from "./TransactionCardList.module.scss";

const getTxTypeNew = (type, rawLog = "[]", result = "") => {
const typeArr = type.split(".");
let typeMsg = typeArr[typeArr.length - 1];
if (typeMsg === "MsgExecuteContract" && result === "Success") {
let rawLogArr = JSON.parse(rawLog);
for (let event of rawLogArr[0].events) {
if (event["type"] === "wasm") {
for (let att of event["attributes"]) {
if (att["key"] === "action") {
let attValue = att["value"]
.split("_")
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join("");
typeMsg += "/" + attValue;
break;
}
}
// if (typeMsg === "MsgExecuteContract" && result === "Success") {
// let rawLogArr = JSON.parse(rawLog);
// for (let event of rawLogArr[0].events) {
// if (event["type"] === "wasm") {
// for (let att of event["attributes"]) {
// if (att["key"] === "action") {
// let attValue = att["value"]
// .split("_")
// .map(word => word.charAt(0).toUpperCase() + word.slice(1))
// .join("");
// typeMsg += "/" + attValue;
// break;
// }
// }

break;
}
}
}
// break;
// }
// }
// }

return typeMsg;
};

const TransactionCardList = memo(({data = [], account}) => {
const TransactionCardList = memo(({ data = [], account }) => {
const cx = classNames.bind(styles);
const status = useSelector(state => state.blockchain.status);

Expand Down
56 changes: 28 additions & 28 deletions src/components/Dashboard/TransactionTable/TransactionTable.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @ts-nocheck
/* eslint-disable react-hooks/exhaustive-deps */
import React, {memo, useMemo} from "react";
import {useSelector} from "react-redux";
import {NavLink} from "react-router-dom";
import React, { memo, useMemo } from "react";
import { useSelector } from "react-redux";
import { NavLink } from "react-router-dom";
import classNames from "classnames/bind";
import consts from "src/constants/consts";
import {_, reduceString, setAgoTime} from "src/lib/scripts";
import {tableThemes} from "src/constants/tableThemes";
import { _, reduceString, setAgoTime } from "src/lib/scripts";
import { tableThemes } from "src/constants/tableThemes";
import ThemedTable from "src/components/common/ThemedTable";
import styles from "./TransactionTable.module.scss";

Expand All @@ -15,25 +15,25 @@ const cx = classNames.bind(styles);
const getTxTypeNew = (type, rawLog = "[]", result = "") => {
const typeArr = type.split(".");
let typeMsg = typeArr[typeArr.length - 1];
if (typeMsg === "MsgExecuteContract" && result === "Success") {
let rawLogArr = JSON.parse(rawLog);
for (let event of rawLogArr[0].events) {
if (event["type"] === "wasm") {
for (let att of event["attributes"]) {
if (att["key"] === "action") {
let attValue = att["value"]
.split("_")
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join("");
typeMsg += "/" + attValue;
break;
}
}
// if (typeMsg === "MsgExecuteContract" && result === "Success") {
// let rawLogArr = JSON.parse(rawLog);
// for (let event of rawLogArr[0].events) {
// if (event["type"] === "wasm") {
// for (let att of event["attributes"]) {
// if (att["key"] === "action") {
// let attValue = att["value"]
// .split("_")
// .map(word => word.charAt(0).toUpperCase() + word.slice(1))
// .join("");
// typeMsg += "/" + attValue;
// break;
// }
// }

break;
}
}
}
// break;
// }
// }
// }

return typeMsg;
};
Expand All @@ -46,18 +46,18 @@ export const getHeaderRow = () => {
const headerCells = [txHashHeaderCell, typeHeaderCell, heightHeaderCell, timeHeaderCell];
const headerCellStyles = [
// change width to % to fixed location.
{width: "23.4%"}, // TxHash
{width: "46%"}, // Type
{width: "17.8%"}, // Height
{width: "12.8%"}, // Time
{ width: "23.4%" }, // TxHash
{ width: "46%" }, // Type
{ width: "17.8%" }, // Height
{ width: "12.8%" }, // Time
];
return {
headerCells,
headerCellStyles,
};
};

const TransactionTable = memo(({data = [], rowMotions = []}) => {
const TransactionTable = memo(({ data = [], rowMotions = [] }) => {
const getDataRows = data => {
if (!Array.isArray(data)) {
return [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React, {memo, useMemo, useState} from "react";
import {NavLink} from "react-router-dom";
import {useSelector, useDispatch} from "react-redux";
import React, { memo, useMemo, useState } from "react";
import { NavLink } from "react-router-dom";
import { useSelector, useDispatch } from "react-redux";
import classNames from "classnames/bind";
import consts from "src/constants/consts";
import {_} from "src/lib/scripts";
import {formatOrai} from "src/helpers/helper";
import {tableThemes} from "src/constants/tableThemes";
import {logoBrand} from "src/constants/logoBrand";
import { _ } from "src/lib/scripts";
import { formatOrai } from "src/helpers/helper";
import { tableThemes } from "src/constants/tableThemes";
import { logoBrand } from "src/constants/logoBrand";
import ThemedTable from "src/components/common/ThemedTable";

import giftIcon from "src/assets/wallet/gift.svg";
Expand All @@ -17,7 +17,7 @@ import styles from "./ClaimTable.module.scss";

const cx = classNames.bind(styles);

const BtnComponent = ({handleClick, buttonName}) => {
const BtnComponent = ({ handleClick, buttonName }) => {
return (
<div className={cx("claim-data-cell", "align-center", "claim-btn")}>
<button className={cx("button")} onClick={handleClick}>
Expand All @@ -28,8 +28,8 @@ const BtnComponent = ({handleClick, buttonName}) => {
);
};

const ClaimTable = memo(({data, totalStaked, totalRewards}) => {
const {address, account} = useSelector(state => state.wallet);
const ClaimTable = memo(({ data, totalStaked, totalRewards }) => {
const { address, account } = useSelector(state => state.wallet);
// const dispatch = useDispatch();

// const handleClickClaimAll = (validatorAddress, claimableRewards) => {
Expand Down Expand Up @@ -89,12 +89,12 @@ const ClaimTable = memo(({data, totalStaked, totalRewards}) => {
delegatedData={data}
validatorAddress={data[0]?.validator_address}
withdrawable={totalRewards}
BtnComponent={({handleClick}) => <BtnComponent handleClick={handleClick} buttonName={"Claim All"} />}
BtnComponent={({ handleClick }) => <BtnComponent handleClick={handleClick} buttonName={"Claim All"} />}
/>
</div>
);
const headerCells = [validatorHeaderCell, stakedHeaderCell, claimableRewardsHeaderCell, claimHeaderCell];
const headerCellStyles = [{width: "auto"}, {width: "auto"}, {width: "auto"}, {width: "140px"}];
const headerCellStyles = [{ width: "auto" }, { width: "auto" }, { width: "auto" }, { width: "140px" }];
return {
headerCells,
headerCellStyles,
Expand Down Expand Up @@ -149,7 +149,7 @@ const ClaimTable = memo(({data, totalStaked, totalRewards}) => {

return data.map((item, index) => {
// const validatorIcon = logoBrand.find(logoBrandItem => item?.validator === logoBrandItem.operatorAddress)?.logo ?? aiIcon;
const logoItem = logoBrand.find(it => it.operatorAddress === item?.validator_address) || {customLogo: null};
const logoItem = logoBrand.find(it => it.operatorAddress === item?.validator_address) || { customLogo: null };
const logoURL = item.moniker_image ? item.moniker_image : logoItem.logo ? logoItem.logo : false;
const logoName = item.validator || "";
const validatorDataCell = item?.validator ? (
Expand Down Expand Up @@ -180,7 +180,7 @@ const ClaimTable = memo(({data, totalStaked, totalRewards}) => {
<ClaimRwBtn
validatorAddress={item?.validator_address}
withdrawable={item.claimable_rewards}
BtnComponent={({handleClick}) => BtnComponent({handleClick, buttonName: "Claim"})}
BtnComponent={({ handleClick }) => BtnComponent({ handleClick, buttonName: "Claim" })}
validatorName={item.validator}
/>
);
Expand Down
20 changes: 13 additions & 7 deletions src/components/DelegatedValidator/DelegatedClaim/DelegatedClaim.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-nocheck
import React from "react";
import {useGet} from "restful-react";
import { useGet } from "restful-react";
import cn from "classnames/bind";
import {useTheme} from "@material-ui/core/styles";
import { useTheme } from "@material-ui/core/styles";
import useMediaQuery from "@material-ui/core/useMediaQuery";
import consts from "src/constants/consts";
import ClaimTable from "src/components/DelegatedValidator/DelegatedClaim/ClaimTable/ClaimTable";
Expand All @@ -12,25 +12,31 @@ import ClaimCardListSkeleton from "src/components/DelegatedValidator/DelegatedCl
import NoResult from "src/components/common/NoResult";
import arrowIcon from "src/assets/wallet/arrow.svg";
import styles from "./DelegatedClaim.module.scss";
import { formatOrai } from "src/helpers/helper";

const cx = cn.bind(styles);

export default function({setActiveTab, address}) {
export default function({ setActiveTab, address }) {
const theme = useTheme();
const isLargeScreen = useMediaQuery(theme.breakpoints.up("lg"));
const path = consts.API.WALLET.CLAIM_REWARD + "/" + address;
const {data} = useGet({
const { data } = useGet({
path: path,
});

let tableSection;

if (data) {
if (Array.isArray(data?.claim_reward) && data.claim_reward.length > 0) {
const claimData =
Array.isArray(data?.claim_reward) && data.claim_reward.length > 0
? data?.claim_reward.filter(claim => parseInt(claim.staked) > 0 || parseFloat(formatOrai(claim.claimable_rewards)) >= parseFloat(formatOrai(1)))
: [];

if (claimData.length > 0) {
tableSection = isLargeScreen ? (
<ClaimTable data={data.claim_reward} totalStaked={data?.total_staked} totalRewards={data?.total_rewards} />
<ClaimTable data={claimData} totalStaked={data?.total_staked} totalRewards={data?.total_rewards} />
) : (
<ClaimCardList data={data.claim_reward} totalStaked={data?.total_staked} totalRewards={data?.total_rewards} />
<ClaimCardList data={claimData} totalStaked={data?.total_staked} totalRewards={data?.total_rewards} />
);
} else {
tableSection = <NoResult />;
Expand Down
Loading

0 comments on commit 2323a45

Please sign in to comment.