fix: transfer from contract

This commit is contained in:
nikdementev 2021-07-08 20:50:44 +03:00
parent 5a2e0151bf
commit 99e1a769eb
No known key found for this signature in database
GPG Key ID: 769B05D57CF16FE2
4 changed files with 11 additions and 4 deletions

View File

@ -19,6 +19,10 @@ interface IVerifier {
function verifyProof(bytes memory _proof, uint256[24] memory _input) external view returns (bool);
}
interface ERC20 {
function transfer(address to, uint256 value) external returns (bool);
}
contract TornadoPool {
uint256 public constant FIELD_SIZE = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
uint256 public constant MAX_EXT_AMOUNT = 2**248 - 1;
@ -90,13 +94,15 @@ contract TornadoPool {
} else if (extAmount < 0) {
require(msg.value == 0, "Sent ETH amount should be 0 for withdrawal");
require(_extData.recipient != address(0), "Can't withdraw to zero address");
_extData.recipient.transfer(uint256(-extAmount));
// _extData.recipient.transfer(uint256(-extAmount));
ERC20(0x4200000000000000000000000000000000000006).transfer(_extData.recipient, uint256(-extAmount));
} else {
require(msg.value == 0, "Sent ETH amount should be 0 for transaction");
}
if (_fee > 0) {
_extData.relayer.transfer(_fee);
// _extData.relayer.transfer(_fee);
ERC20(0x4200000000000000000000000000000000000006).transfer(_extData.relayer, _fee);
}
emit NewCommitment(_outputCommitments[0], currentCommitmentIndex++, _extData.encryptedOutput1);

View File

@ -13,7 +13,7 @@ const config = {
},
},
ovm: {
solcVersion: '0.7.6', // Your version goes here.
solcVersion: '0.7.6+commit.3b061308',
},
networks: {
// goerli: {

View File

@ -10,6 +10,7 @@
"circuit": "./scripts/buildCircuit.sh 2 && ./scripts/buildCircuit.sh 16",
"compile": "npx hardhat compile",
"build": "npm run circuit && npm run compile",
"deploy": "npx hardhat run scripts/deploy.js --network optimism",
"download": "curl -L https://github.com/tornadocash/tornado-pool/releases/download/tmp/ptau15 --create-dirs -o artifacts/circuits/ptau15",
"test": "npx hardhat test",
"eslint": "eslint --ext .js --ignore-path .gitignore .",

View File

@ -1,6 +1,6 @@
const { ethers } = require('hardhat')
const MERKLE_TREE_HEIGHT = 5
const MERKLE_TREE_HEIGHT = 32
const MerkleTree = require('fixed-merkle-tree')
const { poseidon } = require('circomlib')
const poseidonHash = (items) => ethers.BigNumber.from(poseidon(items).toString())