I'm trying to perform a function that exchanges one token for another, but I'm getting a very strange bug. If I call the function in web3, I get the standard metamask popup asking whether to confirm or reject the transaction. Now what's happening is if I hit reject, the value exchange still happens, even though there is no transaction on metamask nor on my ganache cli, just the values are updated on metamask. Then if I confirm the transaction, the transaction goes through as normal, except that double the expected value is exchanged.
Occasionally I get RPC Error: MetaMask Tx Signature: User denied transaction signature.
as expected, yet the value is still exchanged. I've tried restarting my ganache cli, resetting my accounts on metamask, and even reinstalling metamask, but still the same.
Solidity
function deposit(uint amount) public {
require(daitoken.transferFrom(msg.sender, address(this), amount), 'transferFrom failed');
emit Transfer(msg.sender, address(this), amount);
require(ldai.mint(msg.sender, amount), 'mint failed');
emit Mint(msg.sender, amount);
emit Deposit(msg.sender, amount);
}
Web3
const num = this.state.amount * (10**18);
this.props.contract.methods.deposit(num.toString()).send({from: this.props.account});