Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CloudCludfore committed Jun 20, 2024
1 parent cfc30f8 commit f520863
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 39 deletions.
49 changes: 48 additions & 1 deletion src/app/get-aura/deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import { useAccount, useSendTransaction, useBalance } from "wagmi";
import TableHistory from "./table";
import { stringToHex, parseEther, parseUnits, formatUnits } from "viem";
import { useForm, Controller } from "react-hook-form";
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";

interface TableItemProps {
txTime: string;
evmTxHash: string;
cosmosTxHash: string;
depAddress: string;
amount: number;
status: string;
}

function Deposit() {
const [tutType, setTutType] = useState<string>("");

Expand All @@ -24,6 +35,7 @@ function Deposit() {
} = useForm();

const account = useAccount();
// const test = "0x7c698F755Cf38b71dEef73B77E0F1438EecA99F2";
const balance = useBalance({
address: account.address,
});
Expand All @@ -47,6 +59,41 @@ function Deposit() {
setValue("amount", inputValue.replace(/[^0-9]/g, ""));
};

const getActivityHistory = (fromAddress: string): Promise<DepositHistory[]> => {
const url = "https://cex.staging.aura.network/public/DepositService/deposits";

const request: AxiosRequestConfig = {
url: url,
method: "get",
params: {
from: fromAddress,
},
};

const res: Promise<AxiosResponse<DepositHistory[]>> = axios.request(request);
return res.then((response) => response.data);
};

const [activityHistories, setActivityHistories] = useState<TableItemProps[]>([]);
useEffect(() => {
getActivityHistory(account?.address?.toLowerCase() || "").then((res) => {
if (res?.length > 0) {
const mappedList = res?.map((item) => {
const status = item?.status === "completed" ? "success" : item?.status;
return {
txTime: item.created_at,
evmTxHash: item.incoming_tx_hash,
cosmosTxHash: item.outgoing_tx_hash,
depAddress: item.cex_address,
amount: Number(item.amount),
status: status?.charAt(0).toUpperCase() + status?.slice(1),
};
});
setActivityHistories(mappedList);
}
});
}, [account]);

if (!account?.address) {
return <div></div>;
}
Expand Down Expand Up @@ -157,7 +204,7 @@ function Deposit() {
</div>
)}
<div className="mt-12">
<TableHistory></TableHistory>
<TableHistory activityHistories={activityHistories}></TableHistory>
</div>
</div>
);
Expand Down
43 changes: 5 additions & 38 deletions src/app/get-aura/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,12 @@ interface TableItemProps {
status: string;
}

export default function TableHistory() {
const account = useAccount();
// const test = "0x7c698F755Cf38b71dEef73B77E0F1438EecA99F2";
const isMobile = useMediaQuery({ maxWidth: 600 });

const getActivityHistory = (fromAddress: string): Promise<DepositHistory[]> => {
const url = "https://cex.staging.aura.network/public/DepositService/deposits";

const request: AxiosRequestConfig = {
url: url,
method: "get",
params: {
from: fromAddress,
},
};

const res: Promise<AxiosResponse<DepositHistory[]>> = axios.request(request);
return res.then((response) => response.data);
};
type ActivityHistoryProp = {
activityHistories: TableItemProps[];
}

const [activityHistories, setActivityHistories] = useState<TableItemProps[]>([]);
useEffect(() => {
getActivityHistory(account?.address?.toLowerCase() || "").then((res) => {
if (res?.length > 0) {
const mappedList = res?.map((item) => {
const status = item?.status === "completed" ? "success" : item?.status;
return {
txTime: item.created_at,
evmTxHash: item.incoming_tx_hash,
cosmosTxHash: item.outgoing_tx_hash,
depAddress: item.cex_address,
amount: Number(item.amount),
status: status?.charAt(0).toUpperCase() + status?.slice(1),
};
});
setActivityHistories(mappedList);
}
});
}, []);
export default function TableHistory({activityHistories} : ActivityHistoryProp) {
const isMobile = useMediaQuery({ maxWidth: 600 });

if (isMobile) {
return (
Expand Down

0 comments on commit f520863

Please sign in to comment.