-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
discussionQuestions, feedback and general information.Questions, feedback and general information.
Description
Describe the bug
I am getting an revert exception in my React app even the created instance exists. At const exchange = await this.getExchange(exchangeAddress); the error occurs. For a while it had worked and then it didn't anymore. I could not reproduce the error. Testing with Hardhat against local network.
import Exchange from '../abi/src/contracts/Exchange.sol/Exchange.json';
....
....
.....
getExchange = async (exchangeAddress: string) => {
const exchange = new ethers.Contract(
exchangeAddress,
Exchange.abi,
this.state.signer
);
return exchange;
};
Is consumed in:
getTokenAmount = async (ethAmount: string) => {
try {
const exchangeAddress =
await this.state.factory.callStatic.createExchange(
REACT_APP_TOKEN_ADDRESS,
{
from: this.state.account,
}
);
const exchange = await this.getExchange(exchangeAddress);
console.log(exchange) // <-- the exchange instance exists in the browser console
const res = await exchange.getTokenAmount(ethAmount);// <- throws revert exception
return res;
} catch (err) {
console.log(err);
}
};
Reproduction steps
ABI for Exchange contract:
https://github.com/melonecrypto/meloneswap/tree/main/src/abi/src/contracts/Exchange.sol
Error in Browser
Error: call revert exception (method="getTokenAmount(uint256)", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.4.0)
at Logger.makeError (index.ts:213)
at Logger.throwError (index.ts:225)
at Interface.decodeFunctionResult (interface.ts:425)
at Contract.<anonymous> (index.ts:332)
at Generator.next (<anonymous>)
at fulfilled (index.ts:2)
Environment:
OS: MAC OS Big Sur
Editor: VS-Code
Testing-Environment: Hardhat : 2.5.0 localhost: url: 'http://127.0.0.1:8545'
Package.json
Metadata
Metadata
Assignees
Labels
discussionQuestions, feedback and general information.Questions, feedback and general information.