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

Feat/add cbbtc recurring #4955

Merged
merged 6 commits into from
Jan 27, 2025
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
4 changes: 2 additions & 2 deletions src/components/AmountInput/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const AmountInput: FC<IAmountInput> = ({
const isZero = regex.test(displayAmount);
if (amount === 0n && isZero) return;

const maxDecimals = decimals === 8 ? 8 : decimals / 3;
const maxDecimals = decimals === 8 ? 6 : decimals / 3;

const _displayAmount = truncateToDecimalPlaces(
formatUnits(amount, decimals),
Expand Down Expand Up @@ -80,7 +80,7 @@ export const AmountInput: FC<IAmountInput> = ({

// Allow more decimals if token has 8 decimals
if (decimals === 8) {
if (_decimals?.length > 8) return; // Limit to 8 decimals
if (_decimals?.length > 6) return; // Limit to 8 decimals
} else {
if (_decimals?.length > decimals / 3) return; // Limit to 6 or 2 decimals for other tokens
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ export const DepositSuperToken: FC<IDepositSuperTokenProps> = ({
} else {
superTokenAsset = await sf.loadWrapperSuperToken(superToken.id);
}
if (token && token.decimals === 6) {
if (token && (token.decimals === 6 || token.decimals === 8)) {
const divisor = BigInt(10 ** token.decimals);
const currentAmount = Number(amount) / Number(divisor);
newAmount = ethers.utils
.parseUnits(currentAmount.toString(), 18)
.parseUnits(currentAmount.toFixed(8), 18)
.toBigInt();
}
const upgradeOperation = await superTokenAsset.upgrade({
Expand Down
24 changes: 16 additions & 8 deletions src/components/views/donate/Recurring/RecurringDonationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const RecurringDonationCard = () => {
selectedRecurringToken?.token.decimals === 6
? 10000n
: selectedRecurringToken?.token.decimals === 8
? 100n
? 1000000n
: 1n;

// total means project + giveth
Expand Down Expand Up @@ -360,13 +360,21 @@ export const RecurringDonationCard = () => {
id: 'label.available',
})}
:{' '}
{truncateToDecimalPlaces(
formatUnits(
balance.value,
balance.decimals,
),
balance.decimals / 3,
)}
{balance.decimals === 8
? truncateToDecimalPlaces(
formatUnits(
balance.value,
balance.decimals,
),
18 / 3,
)
: truncateToDecimalPlaces(
formatUnits(
balance.value,
balance.decimals,
),
balance.decimals / 3,
)}
</GLinkStyled>
<IconWrapper
onClick={() => !isRefetching && refetch()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ const EndStreamInnerModal: FC<IEndStreamInnerModalProps> = ({
superToken = await sf.loadWrapperSuperToken(_superToken.id);
}

const matchingContract = donation.project.anchorContracts.find(
contract => contract.networkId === recurringNetworkId,
);

const deleteOp = superToken.deleteFlow({
sender: address,
receiver: donation.project.anchorContracts[0].address,
receiver: matchingContract?.address || '',
});

const tx = await deleteOp.exec(signer);
Expand Down
Loading