Skip to content

Commit

Permalink
Merge pull request #119 from valory-xyz/tanya/registry-fix
Browse files Browse the repository at this point in the history
(registry) fix: token amount to appove in services steps
  • Loading branch information
DavidMinarsch authored Oct 21, 2024
2 parents 09ab9c4 + 97562a6 commit 1766230
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Space } from 'antd';
import { isLocalNetwork, notifyError, notifySuccess } from '@autonolas/frontend-library';

import { useHelpers } from 'common-util/hooks';
import { getTokenDetailsRequest } from 'common-util/Details/utils';
import { SendTransactionButton } from 'common-util/TransactionHelpers/SendTransactionButton';
import { checkAndApproveToken, mintTokenRequest } from '../utils';
import { useGetActivateRegistration } from '../useSvmServiceStateManagement';
Expand All @@ -29,12 +30,12 @@ export const PreRegistration = ({
// if not eth, check if the user has sufficient token balance
// and if not, approve the token
if (!isEthToken && !isSvm) {
const deposit = await getTokenDetailsRequest(serviceId);
await checkAndApproveToken({
account,
chainId,
serviceId,
// any amount, if not ETH token substitute with 1
amountToApprove: 1,
amountToApprove: deposit.securityDeposit,
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Divider, Typography } from 'antd';
import { ethers } from 'ethers';
import { isArray } from 'lodash';
import PropTypes from 'prop-types';
import { useEffect, useState } from 'react';
Expand Down Expand Up @@ -114,6 +113,13 @@ export const ActiveRegistration = ({
getSvmBonds,
]);

let totalTokenBonds = 0;
isArray(ethTokenBonds) &&
ethTokenBonds.forEach((bond, index) => {
const addressCount = getNumberOfAgentAddress(dataSource[index].agentAddresses);
totalTokenBonds += addressCount * bond;
});

const handleStep2RegisterAgents = async () => {
const { ids, agentInstances } = getIdsAndAgentInstances(dataSource);

Expand All @@ -127,7 +133,7 @@ export const ActiveRegistration = ({
account,
chainId,
serviceId,
amountToApprove: ethers.parseUnits(`${totalBonds}`, 'ether'),
amountToApprove: `${totalTokenBonds}`,
});
}

Expand Down Expand Up @@ -159,13 +165,6 @@ export const ActiveRegistration = ({

const btnProps = getOtherBtnProps(STEP);
const totalBondEthToken = totalBonds ? convertToEth(totalBonds.toString()) : '--';

let totalTokenBonds = 0;
isArray(ethTokenBonds) &&
ethTokenBonds.forEach((bond, index) => {
const addressCount = getNumberOfAgentAddress(dataSource[index].agentAddresses);
totalTokenBonds += addressCount * bond;
});
const totalTokenBondsEth = totalTokenBonds ? convertToEth(totalTokenBonds.toString()) : '--';

return (
Expand Down

0 comments on commit 1766230

Please sign in to comment.