Skip to content

Commit

Permalink
Merge pull request #108 from valory-xyz/tanya/registry-gas-fix
Browse files Browse the repository at this point in the history
(registry) fix: add gas estimation to creating agent and component
  • Loading branch information
Tanya-atatakai authored Oct 1, 2024
2 parents a1bf4aa + 7fb85ce commit 84158ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions apps/autonolas-registry/components/ListAgents/mint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useRouter } from 'next/router';
import { Typography } from 'antd';
import { notifyError, notifySuccess } from '@autonolas/frontend-library';

import { getEstimatedGasLimit } from 'libs/util-functions/src';

import RegisterForm from 'common-util/List/RegisterForm';
import { AlertSuccess, AlertError } from 'common-util/List/ListCommon';
import { getMechMinterContract } from 'common-util/Contracts';
Expand Down Expand Up @@ -41,14 +43,14 @@ const MintAgent = () => {

const contract = getMechMinterContract(account);

const fn = contract.methods
.create(
'1',
values.owner_address,
`0x${values.hash}`,
values.dependencies ? values.dependencies.split(', ') : [],
)
.send({ from: account });
const createFn = contract.methods.create(
'1',
values.owner_address,
`0x${values.hash}`,
values.dependencies ? values.dependencies.split(', ') : [],
);
const estimatedGas = await getEstimatedGasLimit(createFn, account);
const fn = createFn.send({ from: account, gasLimit: estimatedGas });

sendTransaction(fn, account)
.then((result) => {
Expand Down
18 changes: 10 additions & 8 deletions apps/autonolas-registry/components/ListComponents/mint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useRouter } from 'next/router';
import { Typography } from 'antd';
import { notifyError, notifySuccess } from '@autonolas/frontend-library';

import { getEstimatedGasLimit } from 'libs/util-functions/src';

import RegisterForm from 'common-util/List/RegisterForm';
import { AlertSuccess, AlertError } from 'common-util/List/ListCommon';
import { getMechMinterContract } from 'common-util/Contracts';
Expand Down Expand Up @@ -40,14 +42,14 @@ const MintComponent = () => {
}

const contract = getMechMinterContract();
const fn = contract.methods
.create(
'0',
values.owner_address,
`0x${values.hash}`,
values.dependencies ? values.dependencies.split(', ') : [],
)
.send({ from: account });
const createFn = contract.methods.create(
'0',
values.owner_address,
`0x${values.hash}`,
values.dependencies ? values.dependencies.split(', ') : [],
);
const estimatedGas = await getEstimatedGasLimit(createFn, account);
const fn = createFn.send({ from: account, gasLimit: estimatedGas });

sendTransaction(fn, account)
.then((result) => {
Expand Down

0 comments on commit 84158ce

Please sign in to comment.