Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Fix type of address param in contracts methods (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabijanC authored May 24, 2022
1 parent 1839594 commit cd599a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions starknet_devnet/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Class for storing and handling contracts
"""

from typing import Dict
from .origin import Origin
from .util import (
StarknetDevnetException,
Expand All @@ -16,40 +17,40 @@ class DevnetContracts:

def __init__(self, origin: Origin):
self.origin = origin
self.__intstances = {}
self.__instances: Dict[int, ContractWrapper] = {}

def store(self, address: str, contract: ContractWrapper) -> None:
def store(self, address: int, contract: ContractWrapper) -> None:
"""
Store the contract wrapper.
"""
self.__intstances[address] = contract
self.__instances[address] = contract

def is_deployed(self, address: str) -> bool:
def is_deployed(self, address: int) -> bool:
"""
Check if the contract is deployed.
"""
return address in self.__intstances
return address in self.__instances

def get_by_address(self, address: str) -> ContractWrapper:
def get_by_address(self, address: int) -> ContractWrapper:
"""
Get the contract wrapper by address.
"""
if not self.is_deployed(address):
message = f"No contract at the provided address ({fixed_length_hex(address)})."
raise StarknetDevnetException(message=message)

return self.__intstances[address]
return self.__instances[address]

def get_code(self, address: str) -> str:
def get_code(self, address: int) -> str:
"""
Get the contract code by address.
"""
if not self.is_deployed(address):
return self.origin.get_code(address)

return self.__intstances[address].code
return self.__instances[address].code

def get_full_contract(self, address: str) -> ContractWrapper:
def get_full_contract(self, address: int) -> ContractWrapper:
"""
Get the contract wrapper by address.
"""
Expand Down
2 changes: 1 addition & 1 deletion starknet_devnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
DEFAULT_HOST = "127.0.0.1"
DEFAULT_PORT = 5050

def custom_int(arg: str) -> str:
def custom_int(arg: str) -> int:
"""
Converts the argument to an integer.
Conversion base is 16 if `arg` starts with `0x`, otherwise `10`.
Expand Down

0 comments on commit cd599a9

Please sign in to comment.