From 58855d2c6e1d2139f0b8f0b25ea99778b6c99a91 Mon Sep 17 00:00:00 2001 From: Mira Belenkiy Date: Mon, 19 Feb 2024 18:11:37 -0500 Subject: [PATCH 1/2] fix: hash input and compiler --- chainlink.py | 12 +++++++++--- config.yaml | 1 + foundry.toml | 2 ++ test_data/anvil_keys.yaml | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/chainlink.py b/chainlink.py index 1b21b71..f3afd1d 100644 --- a/chainlink.py +++ b/chainlink.py @@ -46,6 +46,7 @@ """ from chainmail import verify_signature +import eth_abi import os from Crypto.Hash import keccak import re @@ -66,6 +67,7 @@ sender_private_key = KEY['testnet_sender']['private_key'] sender_address = KEY['testnet_sender']['address'] rpc_url = KEY['rpc_url'] +etherscan_api_key = KEY['etherscan_api_key'] ENV_CONFIG_FILE = CONFIG['chainlink']['local_env_file'] @@ -152,10 +154,11 @@ def is_cast_and_send_succeed(output): parsed = parse_cast_send_output(output) return parsed['success'] -# Returns a hash of the input using the Ethereum hash function keccak256 +# Returns a hash of the input string using the Ethereum hash function keccak256 def hash(input): + input_bytes = eth_abi.encode(['string'], [input]) keccak_hash = keccak.new(digest_bits=256) - keccak_hash.update(bytes(input, 'utf-8')) + keccak_hash.update(input_bytes) hash = keccak_hash.hexdigest() print(f'keccak-256: {hash}') return hash @@ -177,7 +180,10 @@ def hash_email_address(email): # saved locally in a file for future use. def deploy(): # deploy smart contract - command = f'forge create {contract_file}:Chainmail --private-key {owner_private_key} --rpc-url {rpc_url}' + enable_verification = '' + if etherscan_api_key != '': + enable_verification = f' --etherscan-api-key {etherscan_api_key} --verify' + command = f'forge create {contract_file}:Chainmail --private-key {owner_private_key} --rpc-url {rpc_url}{enable_verification}' output = execute_or_die(command) # Save address of smart contract in environment for future use. This is important for testing on local anvil diff --git a/config.yaml b/config.yaml index c777101..6deb559 100644 --- a/config.yaml +++ b/config.yaml @@ -29,6 +29,7 @@ sender: # Location of key file with Ethereum private keys. # The test key file anvil_keys.yaml uses default anvil keys. +# local_key_file: './local_test_data/sepolia_keys.yaml' local_key_file: './test_data/anvil_keys.yaml' diff --git a/foundry.toml b/foundry.toml index 25b918f..e9c48bf 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,5 +2,7 @@ src = "src" out = "out" libs = ["lib"] +solc_version = "0.8.20" +optimizer = false # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/test_data/anvil_keys.yaml b/test_data/anvil_keys.yaml index 8a2b532..76ad529 100644 --- a/test_data/anvil_keys.yaml +++ b/test_data/anvil_keys.yaml @@ -38,3 +38,6 @@ rpc_url: 'http://localhost:8545' # For Infura testnet RPC: # rpc_url: 'https://goerli.infura.io/v3/' + +# For anvil use ''; for mainnet/testnet need to obtain an Etherscan token +etherscan_api_key: '' From e4a8fc0527ec463bd0e58a4dfa6d3100d382a971 Mon Sep 17 00:00:00 2001 From: Mira Belenkiy Date: Mon, 19 Feb 2024 18:13:57 -0500 Subject: [PATCH 2/2] remove commented out code --- config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/config.yaml b/config.yaml index 6deb559..c777101 100644 --- a/config.yaml +++ b/config.yaml @@ -29,7 +29,6 @@ sender: # Location of key file with Ethereum private keys. # The test key file anvil_keys.yaml uses default anvil keys. -# local_key_file: './local_test_data/sepolia_keys.yaml' local_key_file: './test_data/anvil_keys.yaml'