Skip to content

Commit

Permalink
fix issues with to_checksum_address where input is >40bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Nov 6, 2024
1 parent 107561b commit 8a7cb72
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 3 additions & 4 deletions kakarot_scripts/deployment/dualvm_token_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ async def deploy_dualvm_tokens() -> None:

# The lazy execution must be done before we check the deployments succeeded, as the l2 contracts
# need to be deployed first
register_lazy_account(await get_starknet_account())
account = await get_starknet_account()
register_lazy_account(account)

kakarot_address = get_starknet_deployments()["kakarot"]
evm_deployments = get_evm_deployments()
Expand Down Expand Up @@ -121,11 +122,9 @@ async def deploy_dualvm_tokens() -> None:

await execute_calls()
dump_evm_deployments(evm_deployments)
remove_lazy_account(await get_starknet_account())
remove_lazy_account(account)

# Check deployments
# Reload evm deployments to get the proper formatting of addresses.
evm_deployments = get_evm_deployments()
for token in tokens_to_deploy:
token_contract = await get_solidity_contract(
"CairoPrecompiles", "DualVmToken", evm_deployments[token["name"]]["address"]
Expand Down
4 changes: 1 addition & 3 deletions kakarot_scripts/deployment/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ async def main():
logger.error("❌ Coinbase is set to 0, all transaction fees will be lost")
else:
logger.info(f"✅ Coinbase set to: 0x{coinbase_address:040x}")
coinbase = await get_contract(
"Kakarot", "Coinbase", address=f"0x{coinbase_address:040x}"
)
coinbase = await get_contract("Kakarot", "Coinbase", address=coinbase_address)
coinbase_balance = await eth_balance_of(coinbase_address)
if coinbase_balance / 1e18 > 0.001:
logger.info(
Expand Down
10 changes: 8 additions & 2 deletions kakarot_scripts/utils/kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,23 @@ def process_link_references(
async def get_contract(
contract_app: str,
contract_name: str,
address=None,
address: Optional[int | str] = None,
caller_eoa: Optional[Account] = None,
) -> Web3Contract:
artifacts = get_solidity_artifacts(contract_app, contract_name)

address = int(address, 16) if isinstance(address, str) else address

bytecode, bytecode_runtime = await link_libraries(artifacts)

contract = cast(
Web3Contract,
WEB3.eth.contract(
address=to_checksum_address(address) if address is not None else address,
address=(
to_checksum_address(f"{address:040x}")
if address is not None
else address
),
abi=artifacts["abi"],
bytecode=bytecode,
),
Expand Down

0 comments on commit 8a7cb72

Please sign in to comment.