Skip to content

Commit

Permalink
Nym node - Fix claim delegator rewards (#5090)
Browse files Browse the repository at this point in the history
* update function param from mixId to nodeId

* fix claim operator rewards
  • Loading branch information
fmtabbara authored Nov 5, 2024
1 parent c6959d3 commit fa551b6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
1 change: 0 additions & 1 deletion explorer/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const isLessThan = (a: number, b: number) => a < b;
*/

export const isBalanceEnough = (fee: string, tx: string = '0', balance: string = '0') => {
console.log('balance', balance, fee, tx);
try {
return Big(balance).gte(Big(fee).plus(Big(tx)));
} catch (e) {
Expand Down
12 changes: 3 additions & 9 deletions nym-wallet/src/components/Bonding/modals/RedeemRewardsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,29 @@ import { ModalListItem } from 'src/components/Modals/ModalListItem';
import { SimpleModal } from 'src/components/Modals/SimpleModal';
import { ModalFee } from 'src/components/Modals/ModalFee';
import { useGetFee } from 'src/hooks/useGetFee';
import { simulateClaimOperatorReward, simulateVestingClaimOperatorReward } from 'src/requests';
import { AppContext } from 'src/context';
import { BalanceWarning } from 'src/components/FeeWarning';
import { Box } from '@mui/material';
import { TBondedMixnode } from 'src/requests/mixnodeDetails';
import { TBondedNymNode } from 'src/requests/nymNodeDetails';

export const RedeemRewardsModal = ({
node,
onConfirm,
onError,
onClose,
}: {
node: TBondedMixnode;
node: TBondedNymNode;
onConfirm: (fee?: FeeDetails) => Promise<void>;
onError: (err: string) => void;
onClose: () => void;
}) => {
const { fee, getFee, isFeeLoading, feeError } = useGetFee();
const { fee, isFeeLoading, feeError } = useGetFee();
const { userBalance } = useContext(AppContext);

useEffect(() => {
if (feeError) onError(feeError);
}, [feeError]);

useEffect(() => {
if (node.proxy) getFee(simulateVestingClaimOperatorReward, {});
else getFee(simulateClaimOperatorReward, {});
}, []);

const handleOnOK = async () => onConfirm(fee);

return (
Expand Down
2 changes: 1 addition & 1 deletion nym-wallet/src/pages/bonding/Bonding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const Bonding = () => {
/>
)}

{showModal === 'redeem' && bondedNode && isMixnode(bondedNode) && (
{showModal === 'redeem' && bondedNode && isNymNode(bondedNode) && (
<RedeemRewardsModal
node={bondedNode}
onClose={() => setShowModal(undefined)}
Expand Down
2 changes: 1 addition & 1 deletion nym-wallet/src/requests/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
NodeConfigUpdate,
GatewayConfigUpdate,
} from '@nymproject/types';
import { TBondGatewayArgs, TBondGatewaySignatureArgs, TNodeConfigUpdateArgs } from '../types';
import { TBondGatewayArgs, TBondGatewaySignatureArgs } from '../types';
import { invokeWrapper } from './wrapper';

export const bondGateway = async (args: TBondGatewayArgs) =>
Expand Down
2 changes: 1 addition & 1 deletion nym-wallet/src/requests/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const claimOperatorReward = async (fee?: Fee) =>

export const claimDelegatorRewards = async (mixId: number, fee?: FeeDetails) =>
invokeWrapper<TransactionExecuteResult[]>('claim_locked_and_unlocked_delegator_reward', {
mixId,
nodeId: mixId,
fee: fee?.fee,
});

Expand Down

0 comments on commit fa551b6

Please sign in to comment.