Skip to content

Commit

Permalink
fix(Staking): limit parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Nov 6, 2023
1 parent b1b3f42 commit 7e849c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/hooks/api/escrow/use-get-account-staking-data.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CurrencyExt } from '@interlay/interbtc-api';
import { CurrencyExt, newMonetaryAmount } from '@interlay/interbtc-api';
import { MonetaryAmount } from '@interlay/monetary-js';
import { AccountId } from '@polkadot/types/interfaces';
import Big from 'big.js';
Expand All @@ -7,6 +7,7 @@ import { useErrorHandler } from 'react-error-boundary';
import { useQuery } from 'react-query';

import { BLOCK_TIME } from '@/config/parachain';
import { GOVERNANCE_TOKEN } from '@/config/relay-chains';
import { REFETCH_INTERVAL } from '@/utils/constants/api';

import useAccountId from '../../use-account-id';
Expand Down Expand Up @@ -61,14 +62,17 @@ const getAccountStakingData = async (accountId: AccountId): Promise<AccountStaki
votingBalancePromise
]);

const unparsedLimit = limit?.values().next().value?.toString() as string;
const parsedLimit = newMonetaryAmount(unparsedLimit || 0, GOVERNANCE_TOKEN);

const unlock = getUnlockData(stakedBalance.endBlock, currentBlockNumber);

return {
unlock,
balance: stakedBalance.amount,
votingBalance,
projected,
limit
limit: parsedLimit
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const StakingAccountDetails = ({
const [isOpen, setOpen] = useState(false);

const transaction = useTransaction(Transaction.ESCROW_WITHDRAW_REWARDS, {
onSuccess: onClaimRewards
onSuccess: () => {
onClaimRewards();
setOpen(false);
}
});

const handleSubmit = () => transaction.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const StakingWithdrawCard = ({ data, onWithdraw, ...props }: StakingWithdrawCard
const [isOpen, setOpen] = useState(false);

const transaction = useTransaction(Transaction.ESCROW_WITHDRAW, {
onSuccess: onWithdraw
onSuccess: () => {
onWithdraw();
setOpen(false);
}
});

const handleSubmit = () => transaction.execute();
Expand Down

0 comments on commit 7e849c0

Please sign in to comment.