updated contract readme

This commit is contained in:
Divide-By-0
2023-04-14 13:54:53 +02:00
parent bbca808293
commit a9e8ef39f7
4 changed files with 43 additions and 20 deletions

View File

@@ -276,7 +276,28 @@ cd src/contracts
forge test
```
To deploy contract to forked mainnet, do:
To deploy contract to forked mainnet, edit `src/contracts/.env` based off of `src/contracts/.env.example` and do:
```
# Set terminal to the folder with this README
cd src/contracts
source .env
# Run local chain in tmux window 1
anvil --fork-url https://eth-goerli.g.alchemy.com/v2/$ALCHEMY_GOERLI_KEY --port 8548 # Run in tmux
# Export to abi for relayers
forge inspect src/TwitterEmailHandler.sol:$MAIN_CONTRACT_NAME abi --via-ir >> contract.abi
# First, test deploy without actually broadcasting it
forge script script/Deploy.s.sol:Deploy --via-ir -vvvv --rpc-url $RPC_URL
# Then, actually deploy
forge script script/Deploy.s.sol:Deploy --via-ir -vvvv --rpc-url $RPC_URL --broadcast
# Verify the contract with the raw one via Etherscan
forge verify-contract $EMAIL_ADDR $MAIN_CONTRACT_NAME --watch --etherscan-api-key $GOERLI_ETHERSCAN_API_KEY
```
```
anvil --fork-url https://eth-mainnet.alchemyapi.io/v2/***REMOVED*** --port 8547 # Run in tmux

View File

@@ -25,14 +25,14 @@ To deploy contract to local forked mainnet or prod, edit Deploy.s.sol to point t
```
# Set terminal to the folder with this README
cd src/contracts
source .env
export MAIN_CONTRACT_NAME=VerifiedTwitterEmail
# Run local chain in tmux window 1
export ALCHEMY_GOERLI_KEY=...
anvil --fork-url https://eth-goerli.g.alchemy.com/v2/$ALCHEMY_GOERLI_KEY --port 8548 # Run in tmux
# Export to abi for relayers
forge inspect src/TwitterEmailHandler.sol:$MAIN_CONTRACT_NAME abi --via-ir >> contract.abi
source .env
# First, test deploy without actually broadcasting it
forge script script/Deploy.s.sol:Deploy --via-ir -vvvv --rpc-url $RPC_URL

View File

@@ -79,7 +79,7 @@ contract VerifiedWalletEmail {
}
require(verifier.verifyProof(a, b, c, signals), "Invalid Proof"); // checks effects iteractions, this should come first
console.log("Proof passed!s");
console.log("Proof passed!");
// Effects: Send money
if (balance[fromEmail] == 0) {
balance[fromEmail] = 10;

View File

@@ -292,29 +292,31 @@ contract WalletUtilsTest is Test {
];
// Test proof verification
// bool verified = proofVerifier.verifyProof(proof_a, proof_b, proof_c, publicSignals);
// assertEq(verified, true);
bool verified = proofVerifier.verifyProof(proof_a, proof_b, proof_c, publicSignals);
assertEq(verified, true);
// Check from/to email domains are correct [in this case, only from domain is checked]
// Right now, we just check that any email was received from anyone at Twitter, which is good enough for now
// We will upload the version with these domain checks soon!
// require(_domainCheck(headerSignals), "Invalid domain");
uint256[] memory bodySignals = new uint256[](body_len);
for (uint256 i = 0; i < body_len; i++) {
bodySignals[i] = publicSignals[i];
}
// uint256[] memory bodySignals = new uint256[](body_len);
// for (uint256 i = 0; i < body_len; i++) {
// bodySignals[i] = publicSignals[i];
// }
string memory fromEmail = StringUtils.convertPackedBytesToBytes(StringUtils.sliceArray(bodySignals, 0, 4), packSize * 4, packSize);
string memory recipientEmail = StringUtils.convertPackedBytesToBytes(StringUtils.sliceArray(bodySignals, 4, 8), packSize * 4, packSize);
string memory amount = StringUtils.convertPackedBytesToBytes(StringUtils.sliceArray(bodySignals, 8, 12), packSize * 4, packSize);
string memory currency = StringUtils.convertPackedBytesToBytes(StringUtils.sliceArray(bodySignals, 12, 16), packSize * 4, packSize);
console.logString(fromEmail);
console.logString(recipientEmail);
console.logString(amount);
console.logString(currency);
string memory domain = StringUtils.getDomainFromEmail(fromEmail);
console.logString(domain);
// string memory fromEmail = StringUtils.convertPackedBytesToBytes(StringUtils.sliceArray(bodySignals, 0, 4), packSize * 4, packSize);
// string memory recipientEmail = StringUtils.convertPackedBytesToBytes(StringUtils.sliceArray(bodySignals, 4, 8), packSize * 4, packSize);
// string memory amount = StringUtils.convertPackedBytesToBytes(StringUtils.sliceArray(bodySignals, 8, 12), packSize * 4, packSize);
// string memory currency = StringUtils.convertPackedBytesToBytes(StringUtils.sliceArray(bodySignals, 12, 16), packSize * 4, packSize);
// console.logString(fromEmail);
// console.logString(recipientEmail);
// console.logString(amount);
// console.logString(currency);
// string memory domain = StringUtils.getDomainFromEmail(fromEmail);
// console.logString(domain);
console.log(abi.encode(proof_a, proof_b, proof_c, publicSignals));
// Test mint after spoofing msg.sender
Vm vm = Vm(VM_ADDR);