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

add realtime superfluid donations amounts to donor profiles #66

Merged
merged 19 commits into from
Jan 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
af10f15
added donation timestamp to DonorCollective (needed for superfluid re…
krisbitney Dec 26, 2023
75f6abc
Merge remote-tracking branch 'origin/kris/data-flow' into kris/realti…
krisbitney Dec 26, 2023
99ab3af
displaying realtime superfluid donations (untested)
krisbitney Dec 26, 2023
48f2507
Merge remote-tracking branch 'origin/web3Integrations' into kris/real…
krisbitney Dec 26, 2023
0df8bc3
Merge remote-tracking branch 'origin/web3Integrations' into kris/real…
krisbitney Dec 26, 2023
698e3c5
Merge remote-tracking branch 'origin/web3Integrations' into kris/real…
krisbitney Dec 26, 2023
8c1641c
Merge remote-tracking branch 'origin/kris/data-flow' into kris/realti…
krisbitney Dec 28, 2023
25380e4
post-merge fixes
krisbitney Dec 28, 2023
8cc5c3f
removed unused constants
krisbitney Dec 28, 2023
60844f0
removed redundant view from ViewStewardsPage.tsx
krisbitney Dec 28, 2023
178e8d5
removed unused styles from ViewStewardsPage.tsx
krisbitney Dec 28, 2023
e014225
removed unused styles from ViewDonorsPage.tsx
krisbitney Dec 28, 2023
fed3a87
ui fixes ViewStewardsPage and ViewDonorsPage
krisbitney Dec 28, 2023
f803942
removed unused import and console log
krisbitney Dec 28, 2023
b8d12ed
Merge remote-tracking branch 'origin/kris/data-flow' into kris/realti…
krisbitney Dec 29, 2023
89eb735
Merge pull request #71 from GoodDollar/kris/desktop-stewards-donors-l…
krisbitney Dec 29, 2023
5a86cef
removed mock data
krisbitney Dec 29, 2023
638593d
added flowing balances for total donation amounts for collectives and…
krisbitney Jan 4, 2024
e6f04a1
added useTokenList hook
krisbitney Jan 4, 2024
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
Prev Previous commit
Next Next commit
post-merge fixes
  • Loading branch information
krisbitney committed Dec 28, 2023
commit 25380e4a1f566d415e5394a81b9f3b22e990b7a0
23 changes: 6 additions & 17 deletions packages/app/src/components/ViewCollective.tsx
Original file line number Diff line number Diff line change
@@ -73,23 +73,12 @@ function ViewCollective({ collective }: ViewCollectiveProps) {

const { price: tokenPrice } = useGetTokenPrice('G$');

const {
decimal: decimalDonations,
formatted: formattedDonations,
usdValue: donationsUsdValue,
} = calculateAmounts(totalDonations, tokenPrice);

const {
decimal: decimalTotalRewards,
formatted: formattedTotalRewards,
usdValue: totalRewardsUsdValue,
} = calculateAmounts(totalRewards, tokenPrice);

const {
decimal: decimalCurrentPool,
formatted: formattedCurrentPool,
usdValue: currentPoolUsdValue,
} = calculateAmounts(currentPool, tokenPrice);
const { formatted: formattedDonations, usdValue: donationsUsdValue } = calculateAmounts(totalDonations, tokenPrice);
Copy link
Contributor

Choose a reason for hiding this comment

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

donation to pools should use flow rate

Copy link
Contributor

Choose a reason for hiding this comment

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

only stewards currently receive single payments.
donor can donate a single donation or a flow therefor pools have incoming flow rate on top of single donations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed this in a new commit. Please take a look when you have a chance.

const { formatted: formattedTotalRewards, usdValue: totalRewardsUsdValue } = calculateAmounts(
totalRewards,
tokenPrice
);
const { formatted: formattedCurrentPool, usdValue: currentPoolUsdValue } = calculateAmounts(currentPool, tokenPrice);

const renderDonorsButton = () => (
<RoundedButton
13 changes: 8 additions & 5 deletions packages/app/src/components/WalletCards/DonorCollectiveCard.tsx
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ import { Text, View, Image } from 'react-native';
import RoundedButton from '../RoundedButton';
import useCrossNavigate from '../../routes/useCrossNavigate';
import { DonorCollective, IpfsCollective } from '../../models/models';
import { ethers } from 'ethers';
import { styles } from './styles';
import { DonorGreenIcon, InfoIcon } from '../../assets';
import { useFlowingBalance } from '../../hooks/useFlowingBalance';

interface DonorCollectiveCardProps {
collective: DonorCollective;
@@ -27,9 +27,12 @@ function DonorCollectiveCard({
// TODO: how to calculate people supported?
const peopleSupported = 0;

const donations: number = parseFloat(ethers.utils.formatEther(collective.contribution));
const donationsUsdValue = tokenPrice ? (donations * tokenPrice).toFixed(2) : '0';
const formattedDonations = donations.toFixed(3);
const { formatted: donationsFormatted, usdValue: donationsUsdValue } = useFlowingBalance(
collective.contribution,
collective.timestamp, // Timestamp in Subgraph's UTC.
collective.flowRate,
tokenPrice
);

const dynamicContainerStyle = isDesktopResolution ? { width: '48%' } : {};

@@ -49,7 +52,7 @@ function DonorCollectiveCard({
<Text style={styles.info}>{userName} has donated</Text>
<View style={styles.row}>
<Text style={styles.bold}>G$ </Text>
<Text style={styles.totalReceived}>{formattedDonations}</Text>
<Text style={styles.totalReceived}>{donationsFormatted}</Text>
</View>
<Text style={styles.formattedUsd}>= {donationsUsdValue} USD</Text>
</View>
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import { IpfsCollective, StewardCollective } from '../../models/models';
import { ethers } from 'ethers';
import { styles } from './styles';
import { InfoIcon, StewardOrange } from '../../assets';
import { calculateAmounts } from '../../lib/calculateAmounts';

interface StewardCollectiveCardProps {
collective: StewardCollective;
@@ -25,9 +26,10 @@ function StewardCollectiveCard({
const { navigate } = useCrossNavigate();
const userName = ensName ?? 'This wallet';

const rewards: number = parseFloat(ethers.utils.formatEther(collective.totalEarned));
const rewardsUsdValue = tokenPrice ? (rewards * tokenPrice).toFixed(2) : '0';
const formattedRewards = rewards.toFixed(3);
const { formatted: rewardsFormatted, usdValue: rewardsUsdValue } = calculateAmounts(
collective.totalEarned,
tokenPrice
);

const dynamicContainerStyle = isDesktopResolution ? { width: '48%' } : {};

@@ -55,7 +57,7 @@ function StewardCollectiveCard({
<Text style={styles.info}>Towards this collective, and received</Text>
<View style={styles.row}>
<Text style={styles.bold}>G$ </Text>
<Text style={styles.totalReceived}>{formattedRewards}</Text>
<Text style={styles.totalReceived}>{rewardsFormatted}</Text>
</View>
<Text style={styles.formattedUsd}>= {rewardsUsdValue} USD</Text>
</View>
Loading