Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet-porfolio #1183

Open
wants to merge 25 commits into
base: development
Choose a base branch
from
Open

wallet-porfolio #1183

wants to merge 25 commits into from

Conversation

Adesojisouljay
Copy link
Collaborator

@Adesojisouljay Adesojisouljay commented Jan 5, 2023

What does this PR?

New wallet view
Shows overall(estimated) wallet value
User can hide or show charts
Users can add or remove hive engine tokens
User can navigate to each token separately (https://ecency.com/@username/wallet/token) to see more transaction info or token info

How to use this feature
Navigate to user profile,
click on wallets then you will see your assets (hive, hive-power, hbd, engine tokens and spk tokens) listed, you can click on each one for more info.
To add more tokens click on add token button, select the token you want to add and confirm. You can also add more than one token. To remove a token from list, you will follow the same procedure and uncheck token.

Screenshot
Screenshot (574)

See video on loom

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
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
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
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


const getMainTransactions = async () => {
const transactions = await getTransactions(params, account.name, 200);
console.log(transactions)
Copy link
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
Collaborator

Choose a reason for hiding this comment

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

Remove please

};

const optionChanged = (e: React.ChangeEvent<typeof FormControl & HTMLInputElement>) => {
console.log(e.target)
Copy link
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
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

@@ -234,6 +235,7 @@ export const WalletEcency = (props: Props) => {
const initiateOnElectron = (username: string) => {
if (!isMounted && global.isElectron) {
let getPoints = new Promise((res) => fetchPoints(username));
console.log(getPoints)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove please

@@ -199,6 +199,7 @@ export const WalletEcency = (props: Props) => {
const [showPurchaseDialog, setShowPurchaseDialog] = useState(false);

const { global, activeUser, account, points, history, fetchPoints, updateActiveUser } = props;
console.log(points)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove please


const marketChartInfo = async () => {
const data: any = await marketChart("hive")
console.log(data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove please

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @dkildar, all console.log( ) would be removed, I'm still working on this issue, would clean all and refactor once I'm done

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
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;

@@ -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
Collaborator

Choose a reason for hiding this comment

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

Remove please

const [transactions, setTransactions] = useState([])
const [otherTransactions, setOtherTransactions] = useState([])
const [loading, setLoading] = useState(false);
const [loadLimit, setLoadLimit] = useState(10)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missed semicolons

} from "../../api/hive-engine";
import LinearProgress from '../linear-progress';

export const EngineTransactionList = (props: any) => {
Copy link
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

return (
<div className="transaction-list">
<div className="transaction-list-header">
<h2>{_t("transactions.title")} </h2>
Copy link
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

</div>
{loading && <LinearProgress />}
{otherTransactions?.slice(0, loadLimit).map((t: any) => {
return (
Copy link
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

<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
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

<span>
<strong>{`Txn Id: ${t.transactionId}`}</strong>
<p className='mt-2'>
<strong>{`Block Id: ${t.blockNumber}`}</strong>
Copy link
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

import { marketChart } from '../../api/misc'
import moment from "moment";

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

Choose a reason for hiding this comment

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

Specify types please

export const HiveWalletPortfolioChart = (props: any) => {
const { theme } = props;

const [prices, setPrices] = useState([])
Copy link
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 { global, account, params } = props

const [transactions, setTransactions] = useState([])
Copy link
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 { global, account, params } = props

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

Choose a reason for hiding this comment

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

Specify types please

estimatedPointsValueLoading: boolean;
}

export class WalletPortfolio extends BaseComponent<Props, State> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use functional component instead of class based please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants