Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a284929
wallet porfolio
Adesojisouljay Jan 5, 2023
c328ac8
fixed trans
Adesojisouljay Jan 5, 2023
703288b
engine token details
Adesojisouljay Jan 6, 2023
b282444
fixed points
Adesojisouljay Jan 8, 2023
80ac66e
engine transactions history
Adesojisouljay Jan 9, 2023
c885bc3
profile tokens
Adesojisouljay Jan 20, 2023
2a9c3ef
profile tokens: engine
Adesojisouljay Jan 29, 2023
c67a23f
checkbox fixes
Adesojisouljay Feb 7, 2023
1aa76f6
type logo amd date format
Adesojisouljay Feb 10, 2023
edb371e
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay Feb 11, 2023
8833e1a
fix map key
Adesojisouljay Feb 11, 2023
4e06397
fixed chart toggle
Adesojisouljay Feb 13, 2023
2907956
chcekbox logics
Adesojisouljay Feb 18, 2023
37739d6
logic fixes
Adesojisouljay Feb 22, 2023
ecf9e74
transactions filtering
Adesojisouljay Mar 4, 2023
43480a1
filter transactions
Adesojisouljay Mar 13, 2023
7e31c80
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay Mar 13, 2023
8a5607a
fixed style import
Adesojisouljay Mar 13, 2023
30ec4d7
syntax fixes
Adesojisouljay Mar 14, 2023
5a80234
clear consoles
Adesojisouljay Mar 15, 2023
56df71e
default chart
Adesojisouljay Mar 29, 2023
a38aee5
fixed wallet path
Adesojisouljay Apr 4, 2023
95ac4e2
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay Apr 4, 2023
23fbe1e
bug fixes
Adesojisouljay May 29, 2023
fdcb288
Merge branch 'development' of https://github.com/ecency/ecency-vision…
Adesojisouljay May 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/common/api/hive-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,35 @@ export const getMarketData = async (symbol: any) => {
});
return history;
};

export async function getTransactions(symbol: string, account: string, limit: number, offset?: number): Promise<any> {
const url: any = engine.mainTransactionUrl;
return axios({
url: url,
method: "GET",
params: {
account,
token: symbol,
limit,
offset
}
}).then((response) => {
return response.data;
});
};

export async function getOtherTransactions(account: string, limit: number, symbol: string, offset: number = 0) {
const url: any = engine.otherTransactionsUrl;
const response = await axios({
url: url,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may leave just url instead of url: url

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, that's true,
Thanks🙏

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still didn't fixed

method: "GET",
params: {
account,
limit,
offset,
type: "user",
symbol
}
});
return response.data;
}
16 changes: 16 additions & 0 deletions src/common/api/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,19 @@ export const fetchGif = async (query: string | null, limit: string, offset: stri
}
return gifs;
};

export const marketInfo = async (): Promise<number> => {

const url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=hive%2C%20hive_dollar&order=market_cap_desc&per_page=100&page=1&sparkline=false`;
const data = await axios.get(url)
.then((r: any) => r.data)
return data;
};

export const marketChart = async (token: string): Promise<number> => {

const url = `https://api.coingecko.com/api/v3/coins/${token}/market_chart?vs_currency=usd&days=30`;
const data = await axios.get(url)
.then((r: any) => r.data)
return data;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, do not use async/await and then constructions together.
It should be:

const { data } = await axis.get(url);
return data;

};
7 changes: 7 additions & 0 deletions src/common/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { pageMapDispatchToProps, pageMapStateToProps } from "./pages/common";
import { connect } from "react-redux";
import loadable from "@loadable/component";
import Announcement from "./components/announcement";
import TokenDetails from "./components/token-details";

// Define lazy pages
const ProfileContainer = loadable(() => import("./pages/profile-functional"));
Expand Down Expand Up @@ -132,6 +133,12 @@ const App = (props: any) => {
path={routes.PROPOSAL_DETAIL}
component={ProposalDetailContainer}
/>
<Route
exact={true}
strict={true}
path={routes.TOKEN_DETAIL}
component={ProfilePage}
/>
<Route exact={true} strict={true} path={routes.ABOUT} component={AboutPage} />
<Route exact={true} strict={true} path={routes.GUESTS} component={GuestPostPage} />
<Route exact={true} strict={true} path={routes.CONTRIBUTE} component={ContributePage} />
Expand Down
1 change: 1 addition & 0 deletions src/common/components/engine-tokens-estimated/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getMetrics } from "../../api/hive-engine";

export const EngineTokensEstimated = (props: any) => {
const { tokens: userTokens, dynamicProps } = props;
// console.log(userTokens)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove please

const [estimated, setEstimated] = useState(`${_t("wallet.calculating")}...`);

useEffect(() => {
Expand Down
10 changes: 5 additions & 5 deletions src/common/components/hive-engine-chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const HiveEngineChart = (props: any) => {
enabled: false
},
chart: {
height: "70",
width: "600",
height: "40",
width: "100",
zoomType: "x",
backgroundColor: "transparent",
border: "none",
Expand All @@ -55,7 +55,7 @@ export const HiveEngineChart = (props: any) => {
area: {
fillColor: theme === Theme.night ? "#2e3d51" : "#f3f7fb",
lineColor: "transparent",
lineWidth: 399
lineWidth: 150
},
series: {
marker: {
Expand Down Expand Up @@ -119,14 +119,14 @@ export const HiveEngineChart = (props: any) => {
series: [
{
name: "tokens",
data: prices.length === 0 ? [0, 0] : prices,
data: prices?.length === 0 ? [0, 0] : prices,
type: "line",
enableMouseTracking: true
}
]
};
return (
<div className="market-graph d-flex justify-items-center ml-5">
<div className="market-graph d-flex justify-items-center">
<div className="graph">
<ReactHighcharts config={config} />
</div>
Expand Down
108 changes: 108 additions & 0 deletions src/common/components/hive-engine-transactions/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import React, { useEffect, useState } from 'react'
import { Button, FormControl } from 'react-bootstrap'
import { _t } from '../../i18n'
import { cashCoinSvg } from "../../img/svg";
import TwoUserAvatar from "../two-user-avatar";

import {
getTransactions,
getOtherTransactions
} from "../../api/hive-engine";
import LinearProgress from '../linear-progress';

export const EngineTransactionList = (props: any) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an any. Please, specify types


const { global, account, params } = props

const [transactions, setTransactions] = useState([])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify types please

const [otherTransactions, setOtherTransactions] = useState([])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify types please

const [loading, setLoading] = useState(false);
const [loadLimit, setLoadLimit] = useState(10)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed semicolons


useEffect(() => {
otherTokenTransactions();
getMainTransactions()
}, [])

const getMainTransactions = async () => {
const transactions = await getTransactions(params, account.name, 200);
console.log(transactions)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove please


};

const otherTokenTransactions = async () => {
setLoading(true)
const otherTransactions = await getOtherTransactions(account.name, 200, params.toUpperCase());
console.log(otherTransactions)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove please

setOtherTransactions(otherTransactions);
setLoading(false)
}

const getTransactionTime = (timestamp: number) => {
let date: any = new Date(timestamp * 1000)
return date.toDateString();
}

const loadMore = () => {
const moreItems = loadLimit + 10;
setLoadLimit(moreItems);
};

const optionChanged = (e: React.ChangeEvent<typeof FormControl & HTMLInputElement>) => {
console.log(e.target)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use this function?

Copy link
Copy Markdown
Collaborator Author

@Adesojisouljay Adesojisouljay Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I haven't used it yet, I'll use it, I'm not done with issue yet, I want to be sure all actions/logic works then I will refactor where necessary

}

return (
<div className="transaction-list">
<div className="transaction-list-header">
<h2>{_t("transactions.title")} </h2>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space at the end of tag content

<FormControl as="select" value="group" onChange={optionChanged} >
<option value="">{_t("transactions.group-all")}</option>
{["transfers", "market-orders", "interests", "stake-operations", "rewards"].map((x) => (
<option key={x} value={x}>
{_t(`transactions.group-${x}`)}
</option>
))}
</FormControl>
</div>
{loading && <LinearProgress />}
{otherTransactions?.slice(0, loadLimit).map((t: any) => {
return (
Copy link
Copy Markdown
Collaborator

@dkildar dkildar Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip: You can replace

foo() => {
return bar;
}

with

foo() => (bar)

No need to use extra return

otherTransactions?.length === 0 ? <p key={t?.id} className="text-muted empty-list">{_t("g.empty-list")}</p> :
<div className="transaction-list-item" key={t?.id}>
<div className="transaction-icon">
{t?.operation === "tokens_transfer" || t?.operation === "tokens_stake" || t?.operation === "tokens_delegate" ?
TwoUserAvatar({ global: global, from: t?.from, to: t?.to, size: "small" }) :
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a component, use as element please

cashCoinSvg }
</div>
<div className="transaction-title">
<div className="transaction-name">{t?.operation.replace("_", " ")}</div>
<div className="transaction-date">{getTransactionTime(t?.timestamp)}</div>
</div>
<div className="transaction-numbers">{`${t?.quantity} ${t?.symbol}`}</div>
<div className="transaction-details">
{t?.memo}
<p>
{t?.operation === "tokens_transfer" ?
<span>
<strong>@{t.from}</strong> -&gt; <strong>@{t.to}</strong>
</span> :
<span>
<strong>{`Txn Id: ${t.transactionId}`}</strong>
<p className='mt-2'>
<strong>{`Block Id: ${t.blockNumber}`}</strong>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These texts should be translated

</p>
</span>
}
</p>
</div>
</div>
)
})}
{!loading && otherTransactions.length > loadLimit &&
<Button disabled={false} block={true} onClick={loadMore} className="mt-2">
{_t("g.load-more")}
</Button>}
</div>
)
}
Loading