Skip to content

Commit

Permalink
feat: 🎸 displaying profits and enhancing rare word displays
Browse files Browse the repository at this point in the history
  • Loading branch information
leosley-m committed Jun 28, 2024
1 parent 4e7f8df commit d3974c6
Show file tree
Hide file tree
Showing 13 changed files with 434 additions and 190 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/sonarqube.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
types: [opened, synchronize, reopened]

name: PR Static Code Analysis
jobs:
static-code-analysis:
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: SonarQube Scan
uses: sonarsource/[email protected]
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
with:
args: >
-Dsonar.projectKey=Schrodinger-AI-interface
2 changes: 2 additions & 0 deletions src/api/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ interface IPointItem {
inviteRate: number;
thirdFollowersNumber: number;
thirdRate: number;
ecoEarnReward: number;
}

interface IGetPointsData {
pointDetails: Array<IPointItem>;
hasBoundAddress: boolean;
evmAddress?: string;
}

interface ICatItemModel {
Expand Down
9 changes: 9 additions & 0 deletions src/assets/img/icons/scarce.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
131 changes: 131 additions & 0 deletions src/components/EarnList/components/ActionComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import { useAccountModal, useConnectModal } from '@rainbow-me/rainbowkit';
import { useGetSignature } from 'hooks/useGetSignature';
import { bindAddress as bindEvmAddress } from 'api/request';
import { useWalletService } from 'hooks/useWallet';
import { Button, HashAddress, ToolTip } from 'aelf-design';
import { useResponsive } from 'hooks/useResponsive';
import { useCallback, useEffect, useState } from 'react';
import { useAccount } from 'wagmi';
import { useCmsInfo } from 'redux/hooks';
import { ReactComponent as ArrowIcon } from 'assets/img/icons/arrow.svg';
import React from 'react';
import { openExternalLink } from 'utils/openlink';
import { OmittedType, getOmittedStr } from 'utils/addressFormatting';
import CommonCopy from 'components/CommonCopy';

function ActionComponent({
data,
hasBoundAddress = false,
bindAddress,
boundEvmAddress,
}: {
data: IPointItem;
hasBoundAddress?: boolean;
bindAddress?: () => void;
boundEvmAddress?: string;
}) {
const { symbol } = data;
const { getSignInfo } = useGetSignature();
const { wallet } = useWalletService();
const [connected, setConnected] = useState<boolean>(false);
const [evmAddress, setEvmAddress] = useState<string>('');
const [bindLoading, setBindLoading] = useState<boolean>(false);
const cmsInfo = useCmsInfo();
const { isLG } = useResponsive();

const { openConnectModal } = useConnectModal();
const { openAccountModal } = useAccountModal();

const account = useAccount();

useEffect(() => {
setConnected(account.isConnected);
setEvmAddress(account.address || '');
}, [account]);

const jumpToEcoEarn = () => {
const link = cmsInfo?.ecoEarn || cmsInfo?.gitbookEcoEarn;
if (!link) return;
openExternalLink(link, '_blank');
};

const sign = useCallback(async () => {
try {
if (bindLoading) return;
setBindLoading(true);
const info = `${wallet.address}-${evmAddress}`;
const res = await getSignInfo(info);
if (res?.publicKey && res.signature && evmAddress) {
await bindEvmAddress({
aelfAddress: wallet.address,
evmAddress,
signature: res.signature,
publicKey: res.publicKey,
});
bindAddress && bindAddress();
}
} catch (error) {
console.log('=====account error', error);
}
setBindLoading(false);
}, [bindAddress, bindLoading, evmAddress, getSignInfo, wallet.address]);

if (cmsInfo?.needBindEvm && cmsInfo.needBindEvm.includes(symbol) && !hasBoundAddress) {
return (
<div className="w-full lg:w-auto">
{connected ? (
<div className="flex flex-col items-start w-full">
<div onClick={openAccountModal} className="mb-[16px]">
<HashAddress
address={evmAddress}
preLen={4}
endLen={4}
hasCopy={false}
ignorePrefixSuffix={true}
size="small"
/>
</div>
<Button
type="link"
loading={bindLoading}
className="!h-[20px] !w-max !min-w-max !text-xs !font-medium !text-brandDefault !flex !items-center !p-0"
onClick={sign}>
Bind address
</Button>
</div>
) : (
<div className="flex items-center w-full">
<span
className="text-xs font-medium text-brandDefault flex items-center cursor-pointer"
onClick={openConnectModal}>
Connect EVM wallet
</span>
</div>
)}
</div>
);
}
return (
<div className="flex flex-col items-start">
{cmsInfo?.needBindEvm && cmsInfo.needBindEvm.includes(symbol) && boundEvmAddress ? (
<CommonCopy toCopy={boundEvmAddress}>
<ToolTip title={isLG ? '' : boundEvmAddress} trigger="hover">
<span className="text-xs font-medium text-brandDefault">
{getOmittedStr(boundEvmAddress, OmittedType.CUSTOM, {
prevLen: 4,
endLen: 4,
limitLen: 9,
})}
</span>
</ToolTip>
</CommonCopy>
) : null}
<div className="w-max flex items-center cursor-pointer" onClick={jumpToEcoEarn}>
<span className="text-xs font-medium text-brandDefault">Details</span>
<ArrowIcon className="fill-brandDefault scale-75 ml-[8px]" />
</div>
</div>
);
}

export default React.memo(ActionComponent);
27 changes: 27 additions & 0 deletions src/components/EarnList/components/ColumnsTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { ReactComponent as Question } from 'assets/img/icons/question.svg';
import { ToolTip } from 'aelf-design';

function ColumnsTitle({ title, tooltip }: { title: string; tooltip?: string[] }) {
return (
<div className="flex items-center">
{tooltip && tooltip.length ? (
<ToolTip
title={
<div>
{tooltip.map((item, index) => {
return <p key={index}>{item}</p>;
})}
</div>
}
className="mr-[4px]">
<Question className="fill-neutralDisable" />
</ToolTip>
) : null}

<span className="text-sm text-neutralDisable font-medium">{title}</span>
</div>
);
}

export default React.memo(ColumnsTitle);
26 changes: 26 additions & 0 deletions src/components/EarnList/components/TableCell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { ReactElement } from 'react';
import { ReactComponent as Question } from 'assets/img/icons/question.svg';
import { ToolTip } from 'aelf-design';

function TableCell({ value, tooltip }: { value: string | ReactElement; tooltip?: string[] }) {
return (
<div className="inline-block text-sm text-neutralPrimary font-medium">
{typeof value === 'string' ? <span className="text-sm text-neutralPrimary font-medium">{value}</span> : value}
{tooltip && tooltip.length ? (
<ToolTip
title={
<div>
{tooltip.map((item, index) => {
return <p key={index}>{item}</p>;
})}
</div>
}
className="ml-[4px] inline-block">
<Question className="fill-neutralDisable" />
</ToolTip>
) : null}
</div>
);
}

export default React.memo(TableCell);
18 changes: 18 additions & 0 deletions src/components/EarnList/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.earn-list {
@apply mt-[24px];
:global {
.aelfd-table-thead {
@apply bg-neutralDefaultBg rounded-lg;

> tr > th {
@apply bg-neutralDefaultBg;
}
.aelfd-table-cell {
@apply rounded-none;
}
.aelfd-table-cell::before {
@apply !bg-transparent;
}
}
}
}
Loading

0 comments on commit d3974c6

Please sign in to comment.