Skip to content

Commit

Permalink
fix: update etherscan API call
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Nov 8, 2024
1 parent e6c60a5 commit 715c6b9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
6 changes: 4 additions & 2 deletions boa/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def verify(
or wait for verification to complete. Defaults to False
"""
api_key = self.api_key or ""
output_selection = solc_json["settings"]["outputSelection"]
contract_file = next(k for k, v in output_selection.items() if "*" in v)
data = {
"module": "contract",
"action": "verifysourcecode",
Expand All @@ -69,8 +71,8 @@ def verify(
"sourceCode": json.dumps(solc_json),
"constructorArguments": constructor_calldata.hex(),
"contractaddress": address,
"contractname": contract_name,
"compilerversion": solc_json["compiler_version"],
"contractname": f"{contract_file}:{contract_name}",
"compilerversion": f"vyper:{solc_json['compiler_version'][1:]}",
"licenseType": license_type,
"optimizationUsed": "1",
}
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/network/sepolia/module_lib.vy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pragma version ~=0.4.0

@view
def throw():
raise "Error with message"

def throw_dev_reason():
raise # dev: some dev reason
25 changes: 23 additions & 2 deletions tests/integration/network/sepolia/test_sepolia_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
from random import randint, sample
from string import ascii_lowercase

import pytest

Expand Down Expand Up @@ -50,8 +52,27 @@ def verifier(request):
raise ValueError(f"Unknown verifier: {request.param}")


def test_verify(simple_contract, verifier):
result = boa.verify(simple_contract, verifier)
def test_verify(verifier):
# generate a random contract so the verification will actually be done again
name = "".join(sample(ascii_lowercase, 10))
value = randint(0, 2**256 - 1)
contract = boa.loads(
f"""
import module_lib
@deploy
def __init__(t: uint256):
if t == 0:
module_lib.throw()
@external
def {name}() -> uint256:
return {value}
""",
value,
name=name,
)
result = boa.verify(contract, verifier)
result.wait_for_verification()
assert result.is_verified()

Expand Down

0 comments on commit 715c6b9

Please sign in to comment.