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

Fix/Recurring donation list amount, keys and GIV donations #4907

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const SelectTokenInnerModal: FC<ISelectTokenModalProps> = ({
) : sortedTokens.length > 0 && isConnected ? (
sortedTokens.map(({ token, balance }: ITokenBalance) => (
<TokenInfo
key={token.symbol}
key={token.address}
token={token}
hideZeroBalance={hideZeroBalance}
balance={balance}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,22 @@ const RecurringDonationInnerModal: FC<IRecurringDonationInnerModalProps> = ({
_superToken,
);

// If givethOldStream don't exist check one more time on network
if (givethOldStream === undefined) {
const existingFlow = await checkIfRecurringFlowExist(
sf,
_superToken.id,
address,
givethAnchorContract,
signer,
);
if (existingFlow.exists && existingFlow.flowRate !== '0') {
givethOldStream = {
currentFlowRate: existingFlow.flowRate,
};
}
}

// Update Giveth stream if it exists
if (givethOldStream) {
givethFlowRate =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const SelectTokenInnerModal: FC<ISelectTokenModalProps> = ({
) as IToken;
return token ? (
<StreamInfo
key={tokenId}
key={`${tokenId}-${token.symbol || token.id}`}
stream={tokenStreams[tokenId.toLowerCase()]}
recurringNetworkId={chain?.id}
superToken={token}
Expand All @@ -163,7 +163,7 @@ const SelectTokenInnerModal: FC<ISelectTokenModalProps> = ({
tokenStreams[token.id.toLowerCase()] ||
balances[token.symbol] === 0n ? null : (
<TokenInfo
key={token.symbol}
key={`${token.id}-${token.symbol}-${chain?.id}`}
token={token}
balance={balances[token.symbol]}
disable={
Expand Down Expand Up @@ -196,36 +196,31 @@ const SelectTokenInnerModal: FC<ISelectTokenModalProps> = ({
</TitleSubheader>
{underlyingTokens.length > 0 ? (
underlyingTokens.map(token => (
<>
<TokenInfo
key={token.underlyingToken?.symbol}
token={token.underlyingToken}
balance={
balances[
token.underlyingToken.symbol
]
}
disable={
balances[
token.underlyingToken.symbol
] === undefined ||
balances[
token.underlyingToken.symbol
] === 0n
}
onClick={() => {
setSelectedRecurringToken({
token: token.underlyingToken,
balance:
balances[
token.underlyingToken
.symbol
],
});
setShowModal(false);
}}
/>
</>
<TokenInfo
key={`${token.underlyingToken?.id || token.symbol}-${chain?.id}`}
token={token.underlyingToken}
balance={
balances[token.underlyingToken.symbol]
}
disable={
balances[
token.underlyingToken.symbol
] === undefined ||
balances[
token.underlyingToken.symbol
] === 0n
}
onClick={() => {
setSelectedRecurringToken({
token: token.underlyingToken,
balance:
balances[
token.underlyingToken.symbol
],
});
setShowModal(false);
}}
/>
kkatusic marked this conversation as resolved.
Show resolved Hide resolved
))
) : (
<Caption>
Expand Down
30 changes: 15 additions & 15 deletions src/config/production.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -638,21 +638,21 @@ const config: EnvConfig = {
isSuperToken: true,
coingeckoId: 'ethereum',
},
{
underlyingToken: {
decimals: 18,
id: '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
name: 'Coinbase Wrapped BTC',
symbol: 'cbBTC',
coingeckoId: 'bitcoin',
},
decimals: 18,
id: '0xDFd428908909CB5E24F5e79E6aD6BDE10bdf2327',
name: 'Coinbase wrapped BTC',
symbol: 'cbBTCx',
isSuperToken: true,
coingeckoId: 'bitcoin',
},
// {
// underlyingToken: {
// decimals: 8,
// id: '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
// name: 'Coinbase Wrapped BTC',
// symbol: 'cbBTC',
// coingeckoId: 'bitcoin',
// },
// decimals: 18,
// id: '0xDFd428908909CB5E24F5e79E6aD6BDE10bdf2327',
// name: 'Coinbase wrapped BTC',
// symbol: 'cbBTCx',
// isSuperToken: true,
// coingeckoId: 'bitcoin',
// },
{
underlyingToken: {
decimals: 18,
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export const formatDonation = (
rounded: boolean = false,
maximumFractionDigits: number = 2,
): string => {
if (amount === '<0.000001') {
return '< 0.01';
}
const num = parseFloat(String(amount || 0));
if (rounded) maximumFractionDigits = 0;
const threshold = Math.pow(10, -maximumFractionDigits);
Expand Down
Loading