Module moody.m.v_r_f_coordinator
Generated wrapper for VRFCoordinator Solidity contract.
Expand source code
"""Generated wrapper for VRFCoordinator Solidity contract."""
# pylint: disable=too-many-arguments
import json
from typing import ( # pylint: disable=unused-import
Any,
List,
Optional,
Tuple,
Union,
)
import time
from eth_utils import to_checksum_address
from mypy_extensions import TypedDict # pylint: disable=unused-import
from hexbytes import HexBytes
from web3 import Web3
from web3.contract import ContractFunction
from web3.datastructures import AttributeDict
from web3.providers.base import BaseProvider
from web3.exceptions import ContractLogicError
from moody.m.bases import ContractMethod, Validator, ContractBase, Signatures
from moody.m.tx_params import TxParams
from moody.libeb import MiliDoS
from moody import Bolors
# Try to import a custom validator class definition; if there isn't one,
# declare one that we can instantiate for the default argument to the
# constructor for VRFCoordinator below.
try:
# both mypy and pylint complain about what we're doing here, but this
# works just fine, so their messages have been disabled here.
from . import ( # type: ignore # pylint: disable=import-self
VRFCoordinatorValidator,
)
except ImportError:
class VRFCoordinatorValidator( # type: ignore
Validator
):
"""No-op input validator."""
try:
from .middleware import MIDDLEWARE # type: ignore
except ImportError:
pass
class PreseedOffsetMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the PRESEED_OFFSET method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address)
self._underlying_method = contract_function
self.sign = validator.getSignature("PRESEED_OFFSET")
def block_call(self, debug:bool=False) -> int:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method()
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: preseed_offset")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, preseed_offset: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, preseed_offset. Reason: Unknown")
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().transact(tx_params.as_dict())
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().estimateGas(tx_params.as_dict())
class ProofLengthMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the PROOF_LENGTH method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address)
self._underlying_method = contract_function
self.sign = validator.getSignature("PROOF_LENGTH")
def block_call(self, debug:bool=False) -> int:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method()
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: proof_length")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, proof_length: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, proof_length. Reason: Unknown")
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().transact(tx_params.as_dict())
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().estimateGas(tx_params.as_dict())
class PublicKeyOffsetMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the PUBLIC_KEY_OFFSET method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address)
self._underlying_method = contract_function
self.sign = validator.getSignature("PUBLIC_KEY_OFFSET")
def block_call(self, debug:bool=False) -> int:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method()
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: public_key_offset")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, public_key_offset: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, public_key_offset. Reason: Unknown")
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().transact(tx_params.as_dict())
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().estimateGas(tx_params.as_dict())
class CallbacksMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the callbacks method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("callbacks")
def validate_and_normalize_inputs(self, index_0: Union[bytes, str])->any:
"""Validate the inputs to the callbacks method."""
self.validator.assert_valid(
method_name='callbacks',
parameter_name='index_0',
argument_value=index_0,
)
return (index_0)
def block_call(self,index_0: Union[bytes, str], debug:bool=False) -> Tuple[str, int, Union[bytes, str]]:
_fn = self._underlying_method(index_0)
returned = _fn.call({
'from': self._operate
})
return (returned[0],returned[1],returned[2],)
def block_send(self, index_0: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Tuple[str, int, Union[bytes, str]]:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(index_0)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: callbacks")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, callbacks: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, callbacks. Reason: Unknown")
def send_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).transact(tx_params.as_dict())
def build_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).buildTransaction(tx_params.as_dict())
def estimate_gas(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
class FulfillRandomnessRequestMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the fulfillRandomnessRequest method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("fulfillRandomnessRequest")
def validate_and_normalize_inputs(self, proof: Union[bytes, str])->any:
"""Validate the inputs to the fulfillRandomnessRequest method."""
self.validator.assert_valid(
method_name='fulfillRandomnessRequest',
parameter_name='_proof',
argument_value=proof,
)
return (proof)
def block_send(self, proof: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(proof)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: fulfill_randomness_request")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, fulfill_randomness_request: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, fulfill_randomness_request. Reason: Unknown")
def send_transaction(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(proof) = self.validate_and_normalize_inputs(proof)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(proof).transact(tx_params.as_dict())
def build_transaction(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(proof) = self.validate_and_normalize_inputs(proof)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(proof).buildTransaction(tx_params.as_dict())
def estimate_gas(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(proof) = self.validate_and_normalize_inputs(proof)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(proof).estimateGas(tx_params.as_dict())
class HashOfKeyMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the hashOfKey method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("hashOfKey")
def validate_and_normalize_inputs(self, public_key: List[int])->any:
"""Validate the inputs to the hashOfKey method."""
self.validator.assert_valid(
method_name='hashOfKey',
parameter_name='_publicKey',
argument_value=public_key,
)
return (public_key)
def block_call(self,public_key: List[int], debug:bool=False) -> Union[bytes, str]:
_fn = self._underlying_method(public_key)
returned = _fn.call({
'from': self._operate
})
return Union[bytes, str](returned)
def block_send(self, public_key: List[int],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Union[bytes, str]:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(public_key)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: hash_of_key")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, hash_of_key: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, hash_of_key. Reason: Unknown")
def send_transaction(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(public_key) = self.validate_and_normalize_inputs(public_key)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(public_key).transact(tx_params.as_dict())
def build_transaction(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(public_key) = self.validate_and_normalize_inputs(public_key)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(public_key).buildTransaction(tx_params.as_dict())
def estimate_gas(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(public_key) = self.validate_and_normalize_inputs(public_key)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(public_key).estimateGas(tx_params.as_dict())
class IsOwnerMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the isOwner method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address)
self._underlying_method = contract_function
self.sign = validator.getSignature("isOwner")
def block_call(self, debug:bool=False) -> bool:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return bool(returned)
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> bool:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method()
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: is_owner")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_owner: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_owner. Reason: Unknown")
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().transact(tx_params.as_dict())
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().estimateGas(tx_params.as_dict())
class OnTokenTransferMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the onTokenTransfer method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("onTokenTransfer")
def validate_and_normalize_inputs(self, sender: str, fee: int, data: Union[bytes, str])->any:
"""Validate the inputs to the onTokenTransfer method."""
self.validator.assert_valid(
method_name='onTokenTransfer',
parameter_name='_sender',
argument_value=sender,
)
sender = self.validate_and_checksum_address(sender)
self.validator.assert_valid(
method_name='onTokenTransfer',
parameter_name='_fee',
argument_value=fee,
)
# safeguard against fractional inputs
fee = int(fee)
self.validator.assert_valid(
method_name='onTokenTransfer',
parameter_name='_data',
argument_value=data,
)
return (sender, fee, data)
def block_send(self, sender: str, fee: int, data: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(sender, fee, data)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: on_token_transfer")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, on_token_transfer: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, on_token_transfer. Reason: Unknown")
def send_transaction(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(sender, fee, data).transact(tx_params.as_dict())
def build_transaction(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(sender, fee, data).buildTransaction(tx_params.as_dict())
def estimate_gas(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(sender, fee, data).estimateGas(tx_params.as_dict())
class OwnerMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the owner method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address)
self._underlying_method = contract_function
self.sign = validator.getSignature("owner")
def block_call(self, debug:bool=False) -> str:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return str(returned)
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> str:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method()
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: owner")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, owner: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, owner. Reason: Unknown")
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().transact(tx_params.as_dict())
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method().estimateGas(tx_params.as_dict())
class RegisterProvingKeyMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the registerProvingKey method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("registerProvingKey")
def validate_and_normalize_inputs(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str])->any:
"""Validate the inputs to the registerProvingKey method."""
self.validator.assert_valid(
method_name='registerProvingKey',
parameter_name='_fee',
argument_value=fee,
)
# safeguard against fractional inputs
fee = int(fee)
self.validator.assert_valid(
method_name='registerProvingKey',
parameter_name='_oracle',
argument_value=oracle,
)
oracle = self.validate_and_checksum_address(oracle)
self.validator.assert_valid(
method_name='registerProvingKey',
parameter_name='_publicProvingKey',
argument_value=public_proving_key,
)
self.validator.assert_valid(
method_name='registerProvingKey',
parameter_name='_jobID',
argument_value=job_id,
)
return (fee, oracle, public_proving_key, job_id)
def block_send(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(fee, oracle, public_proving_key, job_id)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: register_proving_key")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, register_proving_key: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, register_proving_key. Reason: Unknown")
def send_transaction(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(fee, oracle, public_proving_key, job_id).transact(tx_params.as_dict())
def build_transaction(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(fee, oracle, public_proving_key, job_id).buildTransaction(tx_params.as_dict())
def estimate_gas(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(fee, oracle, public_proving_key, job_id).estimateGas(tx_params.as_dict())
class ServiceAgreementsMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the serviceAgreements method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("serviceAgreements")
def validate_and_normalize_inputs(self, index_0: Union[bytes, str])->any:
"""Validate the inputs to the serviceAgreements method."""
self.validator.assert_valid(
method_name='serviceAgreements',
parameter_name='index_0',
argument_value=index_0,
)
return (index_0)
def block_call(self,index_0: Union[bytes, str], debug:bool=False) -> Tuple[str, int, Union[bytes, str]]:
_fn = self._underlying_method(index_0)
returned = _fn.call({
'from': self._operate
})
return (returned[0],returned[1],returned[2],)
def block_send(self, index_0: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Tuple[str, int, Union[bytes, str]]:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(index_0)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: service_agreements")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, service_agreements: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, service_agreements. Reason: Unknown")
def send_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).transact(tx_params.as_dict())
def build_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).buildTransaction(tx_params.as_dict())
def estimate_gas(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
class TransferOwnershipMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the transferOwnership method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("transferOwnership")
def validate_and_normalize_inputs(self, new_owner: str)->any:
"""Validate the inputs to the transferOwnership method."""
self.validator.assert_valid(
method_name='transferOwnership',
parameter_name='newOwner',
argument_value=new_owner,
)
new_owner = self.validate_and_checksum_address(new_owner)
return (new_owner)
def block_send(self, new_owner: str,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(new_owner)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: transfer_ownership")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_ownership: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_ownership. Reason: Unknown")
def send_transaction(self, new_owner: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(new_owner) = self.validate_and_normalize_inputs(new_owner)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(new_owner).transact(tx_params.as_dict())
def build_transaction(self, new_owner: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(new_owner) = self.validate_and_normalize_inputs(new_owner)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(new_owner).buildTransaction(tx_params.as_dict())
def estimate_gas(self, new_owner: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(new_owner) = self.validate_and_normalize_inputs(new_owner)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(new_owner).estimateGas(tx_params.as_dict())
class WithdrawMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the withdraw method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("withdraw")
def validate_and_normalize_inputs(self, recipient: str, amount: int)->any:
"""Validate the inputs to the withdraw method."""
self.validator.assert_valid(
method_name='withdraw',
parameter_name='_recipient',
argument_value=recipient,
)
recipient = self.validate_and_checksum_address(recipient)
self.validator.assert_valid(
method_name='withdraw',
parameter_name='_amount',
argument_value=amount,
)
# safeguard against fractional inputs
amount = int(amount)
return (recipient, amount)
def block_send(self, recipient: str, amount: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(recipient, amount)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: withdraw")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdraw: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdraw. Reason: Unknown")
def send_transaction(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(recipient, amount) = self.validate_and_normalize_inputs(recipient, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(recipient, amount).transact(tx_params.as_dict())
def build_transaction(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(recipient, amount) = self.validate_and_normalize_inputs(recipient, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(recipient, amount).buildTransaction(tx_params.as_dict())
def estimate_gas(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(recipient, amount) = self.validate_and_normalize_inputs(recipient, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(recipient, amount).estimateGas(tx_params.as_dict())
class WithdrawableTokensMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the withdrawableTokens method."""
def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None):
"""Persist instance data."""
super().__init__(elib, contract_address, validator)
self._underlying_method = contract_function
self.sign = validator.getSignature("withdrawableTokens")
def validate_and_normalize_inputs(self, index_0: str)->any:
"""Validate the inputs to the withdrawableTokens method."""
self.validator.assert_valid(
method_name='withdrawableTokens',
parameter_name='index_0',
argument_value=index_0,
)
index_0 = self.validate_and_checksum_address(index_0)
return (index_0)
def block_call(self,index_0: str, debug:bool=False) -> int:
_fn = self._underlying_method(index_0)
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, index_0: str,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(index_0)
try:
_t = _fn.buildTransaction({
'from': self._operate,
'gas': _gaswei,
'gasPrice': _pricewei
})
_t['nonce'] = self._web3_eth.getTransactionCount(self._operate)
if _valeth > 0:
_t['value'] = _valeth
if _debugtx:
print(f"======== Signing ✅ by {self._operate}")
print(f"======== Transaction ✅ check")
print(_t)
if 'data' in _t:
signed = self._web3_eth.account.sign_transaction(_t)
txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction)
tx_receipt = None
if _receipList is True:
print(f"======== awaiting Confirmation 🚸️ {self.sign}")
tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash)
if _debugtx:
print("======== TX Result ✅")
print(tx_receipt)
print(f"======== TX blockHash ✅")
if tx_receipt is not None:
print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}")
else:
print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash")
if _receipList is False:
time.sleep(self._wait)
except ContractLogicError as er:
print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: withdrawable_tokens")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdrawable_tokens: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdrawable_tokens. Reason: Unknown")
def send_transaction(self, index_0: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).transact(tx_params.as_dict())
def build_transaction(self, index_0: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).buildTransaction(tx_params.as_dict())
def estimate_gas(self, index_0: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(index_0) = self.validate_and_normalize_inputs(index_0)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
class SignatureGenerator(Signatures):
"""
The signature is generated for this and it is installed.
"""
def __init__(self, abi: any):
super().__init__(abi)
def preseed_offset(self) -> str:
return self._function_signatures["PRESEED_OFFSET"]
def proof_length(self) -> str:
return self._function_signatures["PROOF_LENGTH"]
def public_key_offset(self) -> str:
return self._function_signatures["PUBLIC_KEY_OFFSET"]
def callbacks(self) -> str:
return self._function_signatures["callbacks"]
def fulfill_randomness_request(self) -> str:
return self._function_signatures["fulfillRandomnessRequest"]
def hash_of_key(self) -> str:
return self._function_signatures["hashOfKey"]
def is_owner(self) -> str:
return self._function_signatures["isOwner"]
def on_token_transfer(self) -> str:
return self._function_signatures["onTokenTransfer"]
def owner(self) -> str:
return self._function_signatures["owner"]
def register_proving_key(self) -> str:
return self._function_signatures["registerProvingKey"]
def service_agreements(self) -> str:
return self._function_signatures["serviceAgreements"]
def transfer_ownership(self) -> str:
return self._function_signatures["transferOwnership"]
def withdraw(self) -> str:
return self._function_signatures["withdraw"]
def withdrawable_tokens(self) -> str:
return self._function_signatures["withdrawableTokens"]
# pylint: disable=too-many-public-methods,too-many-instance-attributes
class VRFCoordinator(ContractBase):
"""Wrapper class for VRFCoordinator Solidity contract.
All method parameters of type `bytes`:code: should be encoded as UTF-8,
which can be accomplished via `str.encode("utf_8")`:code:.
"""
_fn_preseed_offset: PreseedOffsetMethod
"""Constructor-initialized instance of
:class:`PreseedOffsetMethod`.
"""
_fn_proof_length: ProofLengthMethod
"""Constructor-initialized instance of
:class:`ProofLengthMethod`.
"""
_fn_public_key_offset: PublicKeyOffsetMethod
"""Constructor-initialized instance of
:class:`PublicKeyOffsetMethod`.
"""
_fn_callbacks: CallbacksMethod
"""Constructor-initialized instance of
:class:`CallbacksMethod`.
"""
_fn_fulfill_randomness_request: FulfillRandomnessRequestMethod
"""Constructor-initialized instance of
:class:`FulfillRandomnessRequestMethod`.
"""
_fn_hash_of_key: HashOfKeyMethod
"""Constructor-initialized instance of
:class:`HashOfKeyMethod`.
"""
_fn_is_owner: IsOwnerMethod
"""Constructor-initialized instance of
:class:`IsOwnerMethod`.
"""
_fn_on_token_transfer: OnTokenTransferMethod
"""Constructor-initialized instance of
:class:`OnTokenTransferMethod`.
"""
_fn_owner: OwnerMethod
"""Constructor-initialized instance of
:class:`OwnerMethod`.
"""
_fn_register_proving_key: RegisterProvingKeyMethod
"""Constructor-initialized instance of
:class:`RegisterProvingKeyMethod`.
"""
_fn_service_agreements: ServiceAgreementsMethod
"""Constructor-initialized instance of
:class:`ServiceAgreementsMethod`.
"""
_fn_transfer_ownership: TransferOwnershipMethod
"""Constructor-initialized instance of
:class:`TransferOwnershipMethod`.
"""
_fn_withdraw: WithdrawMethod
"""Constructor-initialized instance of
:class:`WithdrawMethod`.
"""
_fn_withdrawable_tokens: WithdrawableTokensMethod
"""Constructor-initialized instance of
:class:`WithdrawableTokensMethod`.
"""
SIGNATURES:SignatureGenerator = None
def __init__(
self,
core_lib: MiliDoS,
contract_address: str,
validator: VRFCoordinatorValidator = None,
):
"""Get an instance of wrapper for smart contract.
"""
# pylint: disable=too-many-statements
super().__init__()
self.contract_address = contract_address
web3 = core_lib.w3
if not validator:
validator = VRFCoordinatorValidator(web3, contract_address)
# if any middleware was imported, inject it
try:
MIDDLEWARE
except NameError:
pass
else:
try:
for middleware in MIDDLEWARE:
web3.middleware_onion.inject(
middleware['function'], layer=middleware['layer'],
)
except ValueError as value_error:
if value_error.args == ("You can't add the same un-named instance twice",):
pass
self._web3_eth = web3.eth
functions = self._web3_eth.contract(address=to_checksum_address(contract_address), abi=VRFCoordinator.abi()).functions
signed = SignatureGenerator(VRFCoordinator.abi())
validator.bindSignatures(signed)
self.SIGNATURES = signed
self._fn_preseed_offset = PreseedOffsetMethod(core_lib, contract_address, functions.PRESEED_OFFSET, validator)
self._fn_proof_length = ProofLengthMethod(core_lib, contract_address, functions.PROOF_LENGTH, validator)
self._fn_public_key_offset = PublicKeyOffsetMethod(core_lib, contract_address, functions.PUBLIC_KEY_OFFSET, validator)
self._fn_callbacks = CallbacksMethod(core_lib, contract_address, functions.callbacks, validator)
self._fn_fulfill_randomness_request = FulfillRandomnessRequestMethod(core_lib, contract_address, functions.fulfillRandomnessRequest, validator)
self._fn_hash_of_key = HashOfKeyMethod(core_lib, contract_address, functions.hashOfKey, validator)
self._fn_is_owner = IsOwnerMethod(core_lib, contract_address, functions.isOwner, validator)
self._fn_on_token_transfer = OnTokenTransferMethod(core_lib, contract_address, functions.onTokenTransfer, validator)
self._fn_owner = OwnerMethod(core_lib, contract_address, functions.owner, validator)
self._fn_register_proving_key = RegisterProvingKeyMethod(core_lib, contract_address, functions.registerProvingKey, validator)
self._fn_service_agreements = ServiceAgreementsMethod(core_lib, contract_address, functions.serviceAgreements, validator)
self._fn_transfer_ownership = TransferOwnershipMethod(core_lib, contract_address, functions.transferOwnership, validator)
self._fn_withdraw = WithdrawMethod(core_lib, contract_address, functions.withdraw, validator)
self._fn_withdrawable_tokens = WithdrawableTokensMethod(core_lib, contract_address, functions.withdrawableTokens, validator)
def event_new_service_agreement(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event new_service_agreement in contract VRFCoordinator
Get log entry for NewServiceAgreement event.
:param tx_hash: hash of transaction emitting NewServiceAgreement event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.NewServiceAgreement().processReceipt(tx_receipt)
def event_ownership_transferred(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event ownership_transferred in contract VRFCoordinator
Get log entry for OwnershipTransferred event.
:param tx_hash: hash of transaction emitting OwnershipTransferred event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.OwnershipTransferred().processReceipt(tx_receipt)
def event_randomness_request(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event randomness_request in contract VRFCoordinator
Get log entry for RandomnessRequest event.
:param tx_hash: hash of transaction emitting RandomnessRequest event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.RandomnessRequest().processReceipt(tx_receipt)
def event_randomness_request_fulfilled(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event randomness_request_fulfilled in contract VRFCoordinator
Get log entry for RandomnessRequestFulfilled event.
:param tx_hash: hash of transaction emitting RandomnessRequestFulfilled
event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.RandomnessRequestFulfilled().processReceipt(tx_receipt)
def preseed_offset(self) -> int:
"""
Implementation of preseed_offset in contract VRFCoordinator
Method of the function
"""
return self._fn_preseed_offset.block_call()
def proof_length(self) -> int:
"""
Implementation of proof_length in contract VRFCoordinator
Method of the function
"""
return self._fn_proof_length.block_call()
def public_key_offset(self) -> int:
"""
Implementation of public_key_offset in contract VRFCoordinator
Method of the function
"""
return self._fn_public_key_offset.block_call()
def callbacks(self, index_0: Union[bytes, str]) -> Tuple[str, int, Union[bytes, str]]:
"""
Implementation of callbacks in contract VRFCoordinator
Method of the function
"""
return self._fn_callbacks.block_call(index_0)
def fulfill_randomness_request(self, proof: Union[bytes, str]) -> None:
"""
Implementation of fulfill_randomness_request in contract VRFCoordinator
Method of the function
"""
return self._fn_fulfill_randomness_request.block_send(proof, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def hash_of_key(self, public_key: List[int]) -> Union[bytes, str]:
"""
Implementation of hash_of_key in contract VRFCoordinator
Method of the function
"""
return self._fn_hash_of_key.block_call(public_key)
def is_owner(self) -> bool:
"""
Implementation of is_owner in contract VRFCoordinator
Method of the function
"""
return self._fn_is_owner.block_call()
def on_token_transfer(self, sender: str, fee: int, data: Union[bytes, str]) -> None:
"""
Implementation of on_token_transfer in contract VRFCoordinator
Method of the function
"""
return self._fn_on_token_transfer.block_send(sender, fee, data, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def owner(self) -> str:
"""
Implementation of owner in contract VRFCoordinator
Method of the function
"""
return self._fn_owner.block_call()
def register_proving_key(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str]) -> None:
"""
Implementation of register_proving_key in contract VRFCoordinator
Method of the function
"""
return self._fn_register_proving_key.block_send(fee, oracle, public_proving_key, job_id, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def service_agreements(self, index_0: Union[bytes, str]) -> Tuple[str, int, Union[bytes, str]]:
"""
Implementation of service_agreements in contract VRFCoordinator
Method of the function
"""
return self._fn_service_agreements.block_call(index_0)
def transfer_ownership(self, new_owner: str) -> None:
"""
Implementation of transfer_ownership in contract VRFCoordinator
Method of the function
"""
return self._fn_transfer_ownership.block_send(new_owner, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def withdraw(self, recipient: str, amount: int) -> None:
"""
Implementation of withdraw in contract VRFCoordinator
Method of the function
"""
return self._fn_withdraw.block_send(recipient, amount, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def withdrawable_tokens(self, index_0: str) -> int:
"""
Implementation of withdrawable_tokens in contract VRFCoordinator
Method of the function
"""
return self._fn_withdrawable_tokens.block_call(index_0)
def CallContractWait(self, t_long:int)-> "VRFCoordinator":
self._fn_preseed_offset.setWait(t_long)
self._fn_proof_length.setWait(t_long)
self._fn_public_key_offset.setWait(t_long)
self._fn_callbacks.setWait(t_long)
self._fn_fulfill_randomness_request.setWait(t_long)
self._fn_hash_of_key.setWait(t_long)
self._fn_is_owner.setWait(t_long)
self._fn_on_token_transfer.setWait(t_long)
self._fn_owner.setWait(t_long)
self._fn_register_proving_key.setWait(t_long)
self._fn_service_agreements.setWait(t_long)
self._fn_transfer_ownership.setWait(t_long)
self._fn_withdraw.setWait(t_long)
self._fn_withdrawable_tokens.setWait(t_long)
return self
@staticmethod
def abi():
"""Return the ABI to the underlying contract."""
return json.loads(
'[{"inputs":[{"internalType":"address","name":"_link","type":"address"},{"internalType":"address","name":"_blockHashStore","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"NewServiceAgreement","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"seed","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"jobID","type":"bytes32"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"requestID","type":"bytes32"}],"name":"RandomnessRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"requestId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"output","type":"uint256"}],"name":"RandomnessRequestFulfilled","type":"event"},{"inputs":[],"name":"PRESEED_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROOF_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUBLIC_KEY_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"index_0","type":"bytes32"}],"name":"callbacks","outputs":[{"internalType":"address","name":"callbackContract","type":"address"},{"internalType":"uint96","name":"randomnessFee","type":"uint96"},{"internalType":"bytes32","name":"seedAndBlockNum","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_proof","type":"bytes"}],"name":"fulfillRandomnessRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[2]","name":"_publicKey","type":"uint256[2]"}],"name":"hashOfKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"uint256[2]","name":"_publicProvingKey","type":"uint256[2]"},{"internalType":"bytes32","name":"_jobID","type":"bytes32"}],"name":"registerProvingKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"index_0","type":"bytes32"}],"name":"serviceAgreements","outputs":[{"internalType":"address","name":"vRFOracle","type":"address"},{"internalType":"uint96","name":"fee","type":"uint96"},{"internalType":"bytes32","name":"jobID","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"withdrawableTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]' # noqa: E501 (line-too-long)
)
# pylint: disable=too-many-lines
Classes
class CallbacksMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the callbacks method.
Persist instance data.
Expand source code
class CallbacksMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the callbacks method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("callbacks") def validate_and_normalize_inputs(self, index_0: Union[bytes, str])->any: """Validate the inputs to the callbacks method.""" self.validator.assert_valid( method_name='callbacks', parameter_name='index_0', argument_value=index_0, ) return (index_0) def block_call(self,index_0: Union[bytes, str], debug:bool=False) -> Tuple[str, int, Union[bytes, str]]: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return (returned[0],returned[1],returned[2],) def block_send(self, index_0: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Tuple[str, int, Union[bytes, str]]: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(index_0) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: callbacks") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, callbacks: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, callbacks. Reason: Unknown") def send_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).transact(tx_params.as_dict()) def build_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).buildTransaction(tx_params.as_dict()) def estimate_gas(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, index_0: Union[bytes, str], debug: bool = False) ‑> Tuple[str, int, Union[bytes, str]]
-
Expand source code
def block_call(self,index_0: Union[bytes, str], debug:bool=False) -> Tuple[str, int, Union[bytes, str]]: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return (returned[0],returned[1],returned[2],)
def block_send(self, index_0: Union[bytes, str], _gaswei: int, _pricewei: int) ‑> Tuple[str, int, Union[bytes, str]]
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, index_0: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Tuple[str, int, Union[bytes, str]]: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(index_0) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: callbacks") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, callbacks: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, callbacks. Reason: Unknown")
def build_transaction(self, index_0: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).buildTransaction(tx_params.as_dict())
def estimate_gas(self, index_0: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
def send_transaction(self, index_0: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, index_0: Union[bytes, str]) ‑>
-
Validate the inputs to the callbacks method.
Expand source code
def validate_and_normalize_inputs(self, index_0: Union[bytes, str])->any: """Validate the inputs to the callbacks method.""" self.validator.assert_valid( method_name='callbacks', parameter_name='index_0', argument_value=index_0, ) return (index_0)
Inherited members
class FulfillRandomnessRequestMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the fulfillRandomnessRequest method.
Persist instance data.
Expand source code
class FulfillRandomnessRequestMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the fulfillRandomnessRequest method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("fulfillRandomnessRequest") def validate_and_normalize_inputs(self, proof: Union[bytes, str])->any: """Validate the inputs to the fulfillRandomnessRequest method.""" self.validator.assert_valid( method_name='fulfillRandomnessRequest', parameter_name='_proof', argument_value=proof, ) return (proof) def block_send(self, proof: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(proof) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: fulfill_randomness_request") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, fulfill_randomness_request: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, fulfill_randomness_request. Reason: Unknown") def send_transaction(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (proof) = self.validate_and_normalize_inputs(proof) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(proof).transact(tx_params.as_dict()) def build_transaction(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (proof) = self.validate_and_normalize_inputs(proof) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(proof).buildTransaction(tx_params.as_dict()) def estimate_gas(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (proof) = self.validate_and_normalize_inputs(proof) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(proof).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, proof: Union[bytes, str], _gaswei: int, _pricewei: int) ‑> NoneType
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, proof: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(proof) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: fulfill_randomness_request") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, fulfill_randomness_request: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, fulfill_randomness_request. Reason: Unknown")
def build_transaction(self, proof: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (proof) = self.validate_and_normalize_inputs(proof) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(proof).buildTransaction(tx_params.as_dict())
def estimate_gas(self, proof: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (proof) = self.validate_and_normalize_inputs(proof) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(proof).estimateGas(tx_params.as_dict())
def send_transaction(self, proof: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (proof) = self.validate_and_normalize_inputs(proof) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(proof).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, proof: Union[bytes, str]) ‑>
-
Validate the inputs to the fulfillRandomnessRequest method.
Expand source code
def validate_and_normalize_inputs(self, proof: Union[bytes, str])->any: """Validate the inputs to the fulfillRandomnessRequest method.""" self.validator.assert_valid( method_name='fulfillRandomnessRequest', parameter_name='_proof', argument_value=proof, ) return (proof)
Inherited members
class HashOfKeyMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the hashOfKey method.
Persist instance data.
Expand source code
class HashOfKeyMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the hashOfKey method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("hashOfKey") def validate_and_normalize_inputs(self, public_key: List[int])->any: """Validate the inputs to the hashOfKey method.""" self.validator.assert_valid( method_name='hashOfKey', parameter_name='_publicKey', argument_value=public_key, ) return (public_key) def block_call(self,public_key: List[int], debug:bool=False) -> Union[bytes, str]: _fn = self._underlying_method(public_key) returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned) def block_send(self, public_key: List[int],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Union[bytes, str]: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(public_key) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: hash_of_key") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, hash_of_key: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, hash_of_key. Reason: Unknown") def send_transaction(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (public_key) = self.validate_and_normalize_inputs(public_key) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(public_key).transact(tx_params.as_dict()) def build_transaction(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (public_key) = self.validate_and_normalize_inputs(public_key) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(public_key).buildTransaction(tx_params.as_dict()) def estimate_gas(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (public_key) = self.validate_and_normalize_inputs(public_key) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(public_key).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, public_key: List[int], debug: bool = False) ‑> Union[bytes, str]
-
Expand source code
def block_call(self,public_key: List[int], debug:bool=False) -> Union[bytes, str]: _fn = self._underlying_method(public_key) returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned)
def block_send(self, public_key: List[int], _gaswei: int, _pricewei: int) ‑> Union[bytes, str]
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, public_key: List[int],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Union[bytes, str]: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(public_key) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: hash_of_key") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, hash_of_key: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, hash_of_key. Reason: Unknown")
def build_transaction(self, public_key: List[int], tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (public_key) = self.validate_and_normalize_inputs(public_key) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(public_key).buildTransaction(tx_params.as_dict())
def estimate_gas(self, public_key: List[int], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (public_key) = self.validate_and_normalize_inputs(public_key) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(public_key).estimateGas(tx_params.as_dict())
def send_transaction(self, public_key: List[int], tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, public_key: List[int], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (public_key) = self.validate_and_normalize_inputs(public_key) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(public_key).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, public_key: List[int]) ‑>
-
Validate the inputs to the hashOfKey method.
Expand source code
def validate_and_normalize_inputs(self, public_key: List[int])->any: """Validate the inputs to the hashOfKey method.""" self.validator.assert_valid( method_name='hashOfKey', parameter_name='_publicKey', argument_value=public_key, ) return (public_key)
Inherited members
class IsOwnerMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the isOwner method.
Persist instance data.
Expand source code
class IsOwnerMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the isOwner method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address) self._underlying_method = contract_function self.sign = validator.getSignature("isOwner") def block_call(self, debug:bool=False) -> bool: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return bool(returned) def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> bool: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: is_owner") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_owner: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_owner. Reason: Unknown") def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict()) def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict()) def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, debug: bool = False) ‑> bool
-
Expand source code
def block_call(self, debug:bool=False) -> bool: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return bool(returned)
def block_send(self, _gaswei: int, _pricewei: int) ‑> bool
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> bool: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: is_owner") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_owner: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_owner. Reason: Unknown")
def build_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
def send_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict())
Inherited members
class OnTokenTransferMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the onTokenTransfer method.
Persist instance data.
Expand source code
class OnTokenTransferMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the onTokenTransfer method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("onTokenTransfer") def validate_and_normalize_inputs(self, sender: str, fee: int, data: Union[bytes, str])->any: """Validate the inputs to the onTokenTransfer method.""" self.validator.assert_valid( method_name='onTokenTransfer', parameter_name='_sender', argument_value=sender, ) sender = self.validate_and_checksum_address(sender) self.validator.assert_valid( method_name='onTokenTransfer', parameter_name='_fee', argument_value=fee, ) # safeguard against fractional inputs fee = int(fee) self.validator.assert_valid( method_name='onTokenTransfer', parameter_name='_data', argument_value=data, ) return (sender, fee, data) def block_send(self, sender: str, fee: int, data: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(sender, fee, data) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: on_token_transfer") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, on_token_transfer: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, on_token_transfer. Reason: Unknown") def send_transaction(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, fee, data).transact(tx_params.as_dict()) def build_transaction(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, fee, data).buildTransaction(tx_params.as_dict()) def estimate_gas(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, fee, data).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, sender: str, fee: int, data: Union[bytes, str], _gaswei: int, _pricewei: int) ‑> NoneType
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, sender: str, fee: int, data: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(sender, fee, data) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: on_token_transfer") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, on_token_transfer: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, on_token_transfer. Reason: Unknown")
def build_transaction(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, fee, data).buildTransaction(tx_params.as_dict())
def estimate_gas(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, fee, data).estimateGas(tx_params.as_dict())
def send_transaction(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, sender: str, fee: int, data: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (sender, fee, data) = self.validate_and_normalize_inputs(sender, fee, data) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, fee, data).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, sender: str, fee: int, data: Union[bytes, str]) ‑>
-
Validate the inputs to the onTokenTransfer method.
Expand source code
def validate_and_normalize_inputs(self, sender: str, fee: int, data: Union[bytes, str])->any: """Validate the inputs to the onTokenTransfer method.""" self.validator.assert_valid( method_name='onTokenTransfer', parameter_name='_sender', argument_value=sender, ) sender = self.validate_and_checksum_address(sender) self.validator.assert_valid( method_name='onTokenTransfer', parameter_name='_fee', argument_value=fee, ) # safeguard against fractional inputs fee = int(fee) self.validator.assert_valid( method_name='onTokenTransfer', parameter_name='_data', argument_value=data, ) return (sender, fee, data)
Inherited members
class OwnerMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the owner method.
Persist instance data.
Expand source code
class OwnerMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the owner method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address) self._underlying_method = contract_function self.sign = validator.getSignature("owner") def block_call(self, debug:bool=False) -> str: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return str(returned) def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> str: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: owner") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, owner: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, owner. Reason: Unknown") def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict()) def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict()) def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, debug: bool = False) ‑> str
-
Expand source code
def block_call(self, debug:bool=False) -> str: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return str(returned)
def block_send(self, _gaswei: int, _pricewei: int) ‑> str
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> str: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: owner") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, owner: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, owner. Reason: Unknown")
def build_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
def send_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict())
Inherited members
class PreseedOffsetMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the PRESEED_OFFSET method.
Persist instance data.
Expand source code
class PreseedOffsetMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the PRESEED_OFFSET method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address) self._underlying_method = contract_function self.sign = validator.getSignature("PRESEED_OFFSET") def block_call(self, debug:bool=False) -> int: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: preseed_offset") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, preseed_offset: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, preseed_offset. Reason: Unknown") def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict()) def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict()) def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, debug: bool = False) ‑> int
-
Expand source code
def block_call(self, debug:bool=False) -> int: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, _gaswei: int, _pricewei: int) ‑> int
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: preseed_offset") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, preseed_offset: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, preseed_offset. Reason: Unknown")
def build_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
def send_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict())
Inherited members
class ProofLengthMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the PROOF_LENGTH method.
Persist instance data.
Expand source code
class ProofLengthMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the PROOF_LENGTH method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address) self._underlying_method = contract_function self.sign = validator.getSignature("PROOF_LENGTH") def block_call(self, debug:bool=False) -> int: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: proof_length") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, proof_length: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, proof_length. Reason: Unknown") def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict()) def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict()) def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, debug: bool = False) ‑> int
-
Expand source code
def block_call(self, debug:bool=False) -> int: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, _gaswei: int, _pricewei: int) ‑> int
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: proof_length") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, proof_length: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, proof_length. Reason: Unknown")
def build_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
def send_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict())
Inherited members
class PublicKeyOffsetMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the PUBLIC_KEY_OFFSET method.
Persist instance data.
Expand source code
class PublicKeyOffsetMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the PUBLIC_KEY_OFFSET method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address) self._underlying_method = contract_function self.sign = validator.getSignature("PUBLIC_KEY_OFFSET") def block_call(self, debug:bool=False) -> int: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: public_key_offset") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, public_key_offset: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, public_key_offset. Reason: Unknown") def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict()) def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict()) def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, debug: bool = False) ‑> int
-
Expand source code
def block_call(self, debug:bool=False) -> int: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, _gaswei: int, _pricewei: int) ‑> int
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, _gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method() try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: public_key_offset") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, public_key_offset: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, public_key_offset. Reason: Unknown")
def build_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().buildTransaction(tx_params.as_dict())
def estimate_gas(self, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().estimateGas(tx_params.as_dict())
def send_transaction(self, tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ tx_params = super().normalize_tx_params(tx_params) return self._underlying_method().transact(tx_params.as_dict())
Inherited members
class RegisterProvingKeyMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the registerProvingKey method.
Persist instance data.
Expand source code
class RegisterProvingKeyMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the registerProvingKey method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("registerProvingKey") def validate_and_normalize_inputs(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str])->any: """Validate the inputs to the registerProvingKey method.""" self.validator.assert_valid( method_name='registerProvingKey', parameter_name='_fee', argument_value=fee, ) # safeguard against fractional inputs fee = int(fee) self.validator.assert_valid( method_name='registerProvingKey', parameter_name='_oracle', argument_value=oracle, ) oracle = self.validate_and_checksum_address(oracle) self.validator.assert_valid( method_name='registerProvingKey', parameter_name='_publicProvingKey', argument_value=public_proving_key, ) self.validator.assert_valid( method_name='registerProvingKey', parameter_name='_jobID', argument_value=job_id, ) return (fee, oracle, public_proving_key, job_id) def block_send(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(fee, oracle, public_proving_key, job_id) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: register_proving_key") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, register_proving_key: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, register_proving_key. Reason: Unknown") def send_transaction(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(fee, oracle, public_proving_key, job_id).transact(tx_params.as_dict()) def build_transaction(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(fee, oracle, public_proving_key, job_id).buildTransaction(tx_params.as_dict()) def estimate_gas(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(fee, oracle, public_proving_key, job_id).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], _gaswei: int, _pricewei: int) ‑> NoneType
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(fee, oracle, public_proving_key, job_id) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: register_proving_key") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, register_proving_key: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, register_proving_key. Reason: Unknown")
def build_transaction(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(fee, oracle, public_proving_key, job_id).buildTransaction(tx_params.as_dict())
def estimate_gas(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(fee, oracle, public_proving_key, job_id).estimateGas(tx_params.as_dict())
def send_transaction(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (fee, oracle, public_proving_key, job_id) = self.validate_and_normalize_inputs(fee, oracle, public_proving_key, job_id) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(fee, oracle, public_proving_key, job_id).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str]) ‑>
-
Validate the inputs to the registerProvingKey method.
Expand source code
def validate_and_normalize_inputs(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str])->any: """Validate the inputs to the registerProvingKey method.""" self.validator.assert_valid( method_name='registerProvingKey', parameter_name='_fee', argument_value=fee, ) # safeguard against fractional inputs fee = int(fee) self.validator.assert_valid( method_name='registerProvingKey', parameter_name='_oracle', argument_value=oracle, ) oracle = self.validate_and_checksum_address(oracle) self.validator.assert_valid( method_name='registerProvingKey', parameter_name='_publicProvingKey', argument_value=public_proving_key, ) self.validator.assert_valid( method_name='registerProvingKey', parameter_name='_jobID', argument_value=job_id, ) return (fee, oracle, public_proving_key, job_id)
Inherited members
class ServiceAgreementsMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the serviceAgreements method.
Persist instance data.
Expand source code
class ServiceAgreementsMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the serviceAgreements method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("serviceAgreements") def validate_and_normalize_inputs(self, index_0: Union[bytes, str])->any: """Validate the inputs to the serviceAgreements method.""" self.validator.assert_valid( method_name='serviceAgreements', parameter_name='index_0', argument_value=index_0, ) return (index_0) def block_call(self,index_0: Union[bytes, str], debug:bool=False) -> Tuple[str, int, Union[bytes, str]]: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return (returned[0],returned[1],returned[2],) def block_send(self, index_0: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Tuple[str, int, Union[bytes, str]]: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(index_0) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: service_agreements") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, service_agreements: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, service_agreements. Reason: Unknown") def send_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).transact(tx_params.as_dict()) def build_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).buildTransaction(tx_params.as_dict()) def estimate_gas(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, index_0: Union[bytes, str], debug: bool = False) ‑> Tuple[str, int, Union[bytes, str]]
-
Expand source code
def block_call(self,index_0: Union[bytes, str], debug:bool=False) -> Tuple[str, int, Union[bytes, str]]: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return (returned[0],returned[1],returned[2],)
def block_send(self, index_0: Union[bytes, str], _gaswei: int, _pricewei: int) ‑> Tuple[str, int, Union[bytes, str]]
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, index_0: Union[bytes, str],_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Tuple[str, int, Union[bytes, str]]: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(index_0) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: service_agreements") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, service_agreements: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, service_agreements. Reason: Unknown")
def build_transaction(self, index_0: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).buildTransaction(tx_params.as_dict())
def estimate_gas(self, index_0: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
def send_transaction(self, index_0: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, index_0: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, index_0: Union[bytes, str]) ‑>
-
Validate the inputs to the serviceAgreements method.
Expand source code
def validate_and_normalize_inputs(self, index_0: Union[bytes, str])->any: """Validate the inputs to the serviceAgreements method.""" self.validator.assert_valid( method_name='serviceAgreements', parameter_name='index_0', argument_value=index_0, ) return (index_0)
Inherited members
class SignatureGenerator (abi:
) -
The signature is generated for this and it is installed.
Expand source code
class SignatureGenerator(Signatures): """ The signature is generated for this and it is installed. """ def __init__(self, abi: any): super().__init__(abi) def preseed_offset(self) -> str: return self._function_signatures["PRESEED_OFFSET"] def proof_length(self) -> str: return self._function_signatures["PROOF_LENGTH"] def public_key_offset(self) -> str: return self._function_signatures["PUBLIC_KEY_OFFSET"] def callbacks(self) -> str: return self._function_signatures["callbacks"] def fulfill_randomness_request(self) -> str: return self._function_signatures["fulfillRandomnessRequest"] def hash_of_key(self) -> str: return self._function_signatures["hashOfKey"] def is_owner(self) -> str: return self._function_signatures["isOwner"] def on_token_transfer(self) -> str: return self._function_signatures["onTokenTransfer"] def owner(self) -> str: return self._function_signatures["owner"] def register_proving_key(self) -> str: return self._function_signatures["registerProvingKey"] def service_agreements(self) -> str: return self._function_signatures["serviceAgreements"] def transfer_ownership(self) -> str: return self._function_signatures["transferOwnership"] def withdraw(self) -> str: return self._function_signatures["withdraw"] def withdrawable_tokens(self) -> str: return self._function_signatures["withdrawableTokens"]
Ancestors
Methods
def callbacks(self) ‑> str
-
Expand source code
def callbacks(self) -> str: return self._function_signatures["callbacks"]
def fulfill_randomness_request(self) ‑> str
-
Expand source code
def fulfill_randomness_request(self) -> str: return self._function_signatures["fulfillRandomnessRequest"]
def hash_of_key(self) ‑> str
-
Expand source code
def hash_of_key(self) -> str: return self._function_signatures["hashOfKey"]
def is_owner(self) ‑> str
-
Expand source code
def is_owner(self) -> str: return self._function_signatures["isOwner"]
def on_token_transfer(self) ‑> str
-
Expand source code
def on_token_transfer(self) -> str: return self._function_signatures["onTokenTransfer"]
def owner(self) ‑> str
-
Expand source code
def owner(self) -> str: return self._function_signatures["owner"]
def preseed_offset(self) ‑> str
-
Expand source code
def preseed_offset(self) -> str: return self._function_signatures["PRESEED_OFFSET"]
def proof_length(self) ‑> str
-
Expand source code
def proof_length(self) -> str: return self._function_signatures["PROOF_LENGTH"]
def public_key_offset(self) ‑> str
-
Expand source code
def public_key_offset(self) -> str: return self._function_signatures["PUBLIC_KEY_OFFSET"]
def register_proving_key(self) ‑> str
-
Expand source code
def register_proving_key(self) -> str: return self._function_signatures["registerProvingKey"]
def service_agreements(self) ‑> str
-
Expand source code
def service_agreements(self) -> str: return self._function_signatures["serviceAgreements"]
def transfer_ownership(self) ‑> str
-
Expand source code
def transfer_ownership(self) -> str: return self._function_signatures["transferOwnership"]
def withdraw(self) ‑> str
-
Expand source code
def withdraw(self) -> str: return self._function_signatures["withdraw"]
def withdrawable_tokens(self) ‑> str
-
Expand source code
def withdrawable_tokens(self) -> str: return self._function_signatures["withdrawableTokens"]
class TransferOwnershipMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the transferOwnership method.
Persist instance data.
Expand source code
class TransferOwnershipMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the transferOwnership method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("transferOwnership") def validate_and_normalize_inputs(self, new_owner: str)->any: """Validate the inputs to the transferOwnership method.""" self.validator.assert_valid( method_name='transferOwnership', parameter_name='newOwner', argument_value=new_owner, ) new_owner = self.validate_and_checksum_address(new_owner) return (new_owner) def block_send(self, new_owner: str,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(new_owner) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: transfer_ownership") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_ownership: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_ownership. Reason: Unknown") def send_transaction(self, new_owner: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (new_owner) = self.validate_and_normalize_inputs(new_owner) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(new_owner).transact(tx_params.as_dict()) def build_transaction(self, new_owner: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (new_owner) = self.validate_and_normalize_inputs(new_owner) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(new_owner).buildTransaction(tx_params.as_dict()) def estimate_gas(self, new_owner: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (new_owner) = self.validate_and_normalize_inputs(new_owner) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(new_owner).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, new_owner: str, _gaswei: int, _pricewei: int) ‑> NoneType
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, new_owner: str,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(new_owner) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: transfer_ownership") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_ownership: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_ownership. Reason: Unknown")
def build_transaction(self, new_owner: str, tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, new_owner: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (new_owner) = self.validate_and_normalize_inputs(new_owner) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(new_owner).buildTransaction(tx_params.as_dict())
def estimate_gas(self, new_owner: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, new_owner: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (new_owner) = self.validate_and_normalize_inputs(new_owner) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(new_owner).estimateGas(tx_params.as_dict())
def send_transaction(self, new_owner: str, tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, new_owner: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (new_owner) = self.validate_and_normalize_inputs(new_owner) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(new_owner).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, new_owner: str) ‑>
-
Validate the inputs to the transferOwnership method.
Expand source code
def validate_and_normalize_inputs(self, new_owner: str)->any: """Validate the inputs to the transferOwnership method.""" self.validator.assert_valid( method_name='transferOwnership', parameter_name='newOwner', argument_value=new_owner, ) new_owner = self.validate_and_checksum_address(new_owner) return (new_owner)
Inherited members
class VRFCoordinator (core_lib: MiliDoS, contract_address: str, validator: VRFCoordinatorValidator = None)
-
Wrapper class for VRFCoordinator Solidity contract.
All method parameters of type
bytes
:code: should be encoded as UTF-8, which can be accomplished viastr.encode("utf_8")
:code:.Get an instance of wrapper for smart contract.
Expand source code
class VRFCoordinator(ContractBase): """Wrapper class for VRFCoordinator Solidity contract. All method parameters of type `bytes`:code: should be encoded as UTF-8, which can be accomplished via `str.encode("utf_8")`:code:. """ _fn_preseed_offset: PreseedOffsetMethod """Constructor-initialized instance of :class:`PreseedOffsetMethod`. """ _fn_proof_length: ProofLengthMethod """Constructor-initialized instance of :class:`ProofLengthMethod`. """ _fn_public_key_offset: PublicKeyOffsetMethod """Constructor-initialized instance of :class:`PublicKeyOffsetMethod`. """ _fn_callbacks: CallbacksMethod """Constructor-initialized instance of :class:`CallbacksMethod`. """ _fn_fulfill_randomness_request: FulfillRandomnessRequestMethod """Constructor-initialized instance of :class:`FulfillRandomnessRequestMethod`. """ _fn_hash_of_key: HashOfKeyMethod """Constructor-initialized instance of :class:`HashOfKeyMethod`. """ _fn_is_owner: IsOwnerMethod """Constructor-initialized instance of :class:`IsOwnerMethod`. """ _fn_on_token_transfer: OnTokenTransferMethod """Constructor-initialized instance of :class:`OnTokenTransferMethod`. """ _fn_owner: OwnerMethod """Constructor-initialized instance of :class:`OwnerMethod`. """ _fn_register_proving_key: RegisterProvingKeyMethod """Constructor-initialized instance of :class:`RegisterProvingKeyMethod`. """ _fn_service_agreements: ServiceAgreementsMethod """Constructor-initialized instance of :class:`ServiceAgreementsMethod`. """ _fn_transfer_ownership: TransferOwnershipMethod """Constructor-initialized instance of :class:`TransferOwnershipMethod`. """ _fn_withdraw: WithdrawMethod """Constructor-initialized instance of :class:`WithdrawMethod`. """ _fn_withdrawable_tokens: WithdrawableTokensMethod """Constructor-initialized instance of :class:`WithdrawableTokensMethod`. """ SIGNATURES:SignatureGenerator = None def __init__( self, core_lib: MiliDoS, contract_address: str, validator: VRFCoordinatorValidator = None, ): """Get an instance of wrapper for smart contract. """ # pylint: disable=too-many-statements super().__init__() self.contract_address = contract_address web3 = core_lib.w3 if not validator: validator = VRFCoordinatorValidator(web3, contract_address) # if any middleware was imported, inject it try: MIDDLEWARE except NameError: pass else: try: for middleware in MIDDLEWARE: web3.middleware_onion.inject( middleware['function'], layer=middleware['layer'], ) except ValueError as value_error: if value_error.args == ("You can't add the same un-named instance twice",): pass self._web3_eth = web3.eth functions = self._web3_eth.contract(address=to_checksum_address(contract_address), abi=VRFCoordinator.abi()).functions signed = SignatureGenerator(VRFCoordinator.abi()) validator.bindSignatures(signed) self.SIGNATURES = signed self._fn_preseed_offset = PreseedOffsetMethod(core_lib, contract_address, functions.PRESEED_OFFSET, validator) self._fn_proof_length = ProofLengthMethod(core_lib, contract_address, functions.PROOF_LENGTH, validator) self._fn_public_key_offset = PublicKeyOffsetMethod(core_lib, contract_address, functions.PUBLIC_KEY_OFFSET, validator) self._fn_callbacks = CallbacksMethod(core_lib, contract_address, functions.callbacks, validator) self._fn_fulfill_randomness_request = FulfillRandomnessRequestMethod(core_lib, contract_address, functions.fulfillRandomnessRequest, validator) self._fn_hash_of_key = HashOfKeyMethod(core_lib, contract_address, functions.hashOfKey, validator) self._fn_is_owner = IsOwnerMethod(core_lib, contract_address, functions.isOwner, validator) self._fn_on_token_transfer = OnTokenTransferMethod(core_lib, contract_address, functions.onTokenTransfer, validator) self._fn_owner = OwnerMethod(core_lib, contract_address, functions.owner, validator) self._fn_register_proving_key = RegisterProvingKeyMethod(core_lib, contract_address, functions.registerProvingKey, validator) self._fn_service_agreements = ServiceAgreementsMethod(core_lib, contract_address, functions.serviceAgreements, validator) self._fn_transfer_ownership = TransferOwnershipMethod(core_lib, contract_address, functions.transferOwnership, validator) self._fn_withdraw = WithdrawMethod(core_lib, contract_address, functions.withdraw, validator) self._fn_withdrawable_tokens = WithdrawableTokensMethod(core_lib, contract_address, functions.withdrawableTokens, validator) def event_new_service_agreement( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event new_service_agreement in contract VRFCoordinator Get log entry for NewServiceAgreement event. :param tx_hash: hash of transaction emitting NewServiceAgreement event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.NewServiceAgreement().processReceipt(tx_receipt) def event_ownership_transferred( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event ownership_transferred in contract VRFCoordinator Get log entry for OwnershipTransferred event. :param tx_hash: hash of transaction emitting OwnershipTransferred event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.OwnershipTransferred().processReceipt(tx_receipt) def event_randomness_request( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event randomness_request in contract VRFCoordinator Get log entry for RandomnessRequest event. :param tx_hash: hash of transaction emitting RandomnessRequest event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.RandomnessRequest().processReceipt(tx_receipt) def event_randomness_request_fulfilled( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event randomness_request_fulfilled in contract VRFCoordinator Get log entry for RandomnessRequestFulfilled event. :param tx_hash: hash of transaction emitting RandomnessRequestFulfilled event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.RandomnessRequestFulfilled().processReceipt(tx_receipt) def preseed_offset(self) -> int: """ Implementation of preseed_offset in contract VRFCoordinator Method of the function """ return self._fn_preseed_offset.block_call() def proof_length(self) -> int: """ Implementation of proof_length in contract VRFCoordinator Method of the function """ return self._fn_proof_length.block_call() def public_key_offset(self) -> int: """ Implementation of public_key_offset in contract VRFCoordinator Method of the function """ return self._fn_public_key_offset.block_call() def callbacks(self, index_0: Union[bytes, str]) -> Tuple[str, int, Union[bytes, str]]: """ Implementation of callbacks in contract VRFCoordinator Method of the function """ return self._fn_callbacks.block_call(index_0) def fulfill_randomness_request(self, proof: Union[bytes, str]) -> None: """ Implementation of fulfill_randomness_request in contract VRFCoordinator Method of the function """ return self._fn_fulfill_randomness_request.block_send(proof, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def hash_of_key(self, public_key: List[int]) -> Union[bytes, str]: """ Implementation of hash_of_key in contract VRFCoordinator Method of the function """ return self._fn_hash_of_key.block_call(public_key) def is_owner(self) -> bool: """ Implementation of is_owner in contract VRFCoordinator Method of the function """ return self._fn_is_owner.block_call() def on_token_transfer(self, sender: str, fee: int, data: Union[bytes, str]) -> None: """ Implementation of on_token_transfer in contract VRFCoordinator Method of the function """ return self._fn_on_token_transfer.block_send(sender, fee, data, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def owner(self) -> str: """ Implementation of owner in contract VRFCoordinator Method of the function """ return self._fn_owner.block_call() def register_proving_key(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str]) -> None: """ Implementation of register_proving_key in contract VRFCoordinator Method of the function """ return self._fn_register_proving_key.block_send(fee, oracle, public_proving_key, job_id, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def service_agreements(self, index_0: Union[bytes, str]) -> Tuple[str, int, Union[bytes, str]]: """ Implementation of service_agreements in contract VRFCoordinator Method of the function """ return self._fn_service_agreements.block_call(index_0) def transfer_ownership(self, new_owner: str) -> None: """ Implementation of transfer_ownership in contract VRFCoordinator Method of the function """ return self._fn_transfer_ownership.block_send(new_owner, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def withdraw(self, recipient: str, amount: int) -> None: """ Implementation of withdraw in contract VRFCoordinator Method of the function """ return self._fn_withdraw.block_send(recipient, amount, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def withdrawable_tokens(self, index_0: str) -> int: """ Implementation of withdrawable_tokens in contract VRFCoordinator Method of the function """ return self._fn_withdrawable_tokens.block_call(index_0) def CallContractWait(self, t_long:int)-> "VRFCoordinator": self._fn_preseed_offset.setWait(t_long) self._fn_proof_length.setWait(t_long) self._fn_public_key_offset.setWait(t_long) self._fn_callbacks.setWait(t_long) self._fn_fulfill_randomness_request.setWait(t_long) self._fn_hash_of_key.setWait(t_long) self._fn_is_owner.setWait(t_long) self._fn_on_token_transfer.setWait(t_long) self._fn_owner.setWait(t_long) self._fn_register_proving_key.setWait(t_long) self._fn_service_agreements.setWait(t_long) self._fn_transfer_ownership.setWait(t_long) self._fn_withdraw.setWait(t_long) self._fn_withdrawable_tokens.setWait(t_long) return self @staticmethod def abi(): """Return the ABI to the underlying contract.""" return json.loads( '[{"inputs":[{"internalType":"address","name":"_link","type":"address"},{"internalType":"address","name":"_blockHashStore","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"NewServiceAgreement","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"seed","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"jobID","type":"bytes32"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"requestID","type":"bytes32"}],"name":"RandomnessRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"requestId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"output","type":"uint256"}],"name":"RandomnessRequestFulfilled","type":"event"},{"inputs":[],"name":"PRESEED_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROOF_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUBLIC_KEY_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"index_0","type":"bytes32"}],"name":"callbacks","outputs":[{"internalType":"address","name":"callbackContract","type":"address"},{"internalType":"uint96","name":"randomnessFee","type":"uint96"},{"internalType":"bytes32","name":"seedAndBlockNum","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_proof","type":"bytes"}],"name":"fulfillRandomnessRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[2]","name":"_publicKey","type":"uint256[2]"}],"name":"hashOfKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"uint256[2]","name":"_publicProvingKey","type":"uint256[2]"},{"internalType":"bytes32","name":"_jobID","type":"bytes32"}],"name":"registerProvingKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"index_0","type":"bytes32"}],"name":"serviceAgreements","outputs":[{"internalType":"address","name":"vRFOracle","type":"address"},{"internalType":"uint96","name":"fee","type":"uint96"},{"internalType":"bytes32","name":"jobID","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"withdrawableTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]' # noqa: E501 (line-too-long) )
Ancestors
Class variables
var SIGNATURES : SignatureGenerator
Static methods
def abi()
-
Return the ABI to the underlying contract.
Expand source code
@staticmethod def abi(): """Return the ABI to the underlying contract.""" return json.loads( '[{"inputs":[{"internalType":"address","name":"_link","type":"address"},{"internalType":"address","name":"_blockHashStore","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"NewServiceAgreement","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"seed","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"jobID","type":"bytes32"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"requestID","type":"bytes32"}],"name":"RandomnessRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"requestId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"output","type":"uint256"}],"name":"RandomnessRequestFulfilled","type":"event"},{"inputs":[],"name":"PRESEED_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROOF_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PUBLIC_KEY_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"index_0","type":"bytes32"}],"name":"callbacks","outputs":[{"internalType":"address","name":"callbackContract","type":"address"},{"internalType":"uint96","name":"randomnessFee","type":"uint96"},{"internalType":"bytes32","name":"seedAndBlockNum","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_proof","type":"bytes"}],"name":"fulfillRandomnessRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[2]","name":"_publicKey","type":"uint256[2]"}],"name":"hashOfKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"uint256[2]","name":"_publicProvingKey","type":"uint256[2]"},{"internalType":"bytes32","name":"_jobID","type":"bytes32"}],"name":"registerProvingKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"index_0","type":"bytes32"}],"name":"serviceAgreements","outputs":[{"internalType":"address","name":"vRFOracle","type":"address"},{"internalType":"uint96","name":"fee","type":"uint96"},{"internalType":"bytes32","name":"jobID","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"withdrawableTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]' # noqa: E501 (line-too-long) )
Methods
def CallContractWait(self, t_long: int) ‑> VRFCoordinator
-
Expand source code
def CallContractWait(self, t_long:int)-> "VRFCoordinator": self._fn_preseed_offset.setWait(t_long) self._fn_proof_length.setWait(t_long) self._fn_public_key_offset.setWait(t_long) self._fn_callbacks.setWait(t_long) self._fn_fulfill_randomness_request.setWait(t_long) self._fn_hash_of_key.setWait(t_long) self._fn_is_owner.setWait(t_long) self._fn_on_token_transfer.setWait(t_long) self._fn_owner.setWait(t_long) self._fn_register_proving_key.setWait(t_long) self._fn_service_agreements.setWait(t_long) self._fn_transfer_ownership.setWait(t_long) self._fn_withdraw.setWait(t_long) self._fn_withdrawable_tokens.setWait(t_long) return self
def callbacks(self, index_0: Union[bytes, str]) ‑> Tuple[str, int, Union[bytes, str]]
-
Implementation of callbacks in contract VRFCoordinator Method of the function
Expand source code
def callbacks(self, index_0: Union[bytes, str]) -> Tuple[str, int, Union[bytes, str]]: """ Implementation of callbacks in contract VRFCoordinator Method of the function """ return self._fn_callbacks.block_call(index_0)
def event_new_service_agreement(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event new_service_agreement in contract VRFCoordinator Get log entry for NewServiceAgreement event. :param tx_hash: hash of transaction emitting NewServiceAgreement event
Expand source code
def event_new_service_agreement( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event new_service_agreement in contract VRFCoordinator Get log entry for NewServiceAgreement event. :param tx_hash: hash of transaction emitting NewServiceAgreement event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.NewServiceAgreement().processReceipt(tx_receipt)
def event_ownership_transferred(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event ownership_transferred in contract VRFCoordinator Get log entry for OwnershipTransferred event. :param tx_hash: hash of transaction emitting OwnershipTransferred event
Expand source code
def event_ownership_transferred( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event ownership_transferred in contract VRFCoordinator Get log entry for OwnershipTransferred event. :param tx_hash: hash of transaction emitting OwnershipTransferred event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.OwnershipTransferred().processReceipt(tx_receipt)
def event_randomness_request(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event randomness_request in contract VRFCoordinator Get log entry for RandomnessRequest event. :param tx_hash: hash of transaction emitting RandomnessRequest event
Expand source code
def event_randomness_request( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event randomness_request in contract VRFCoordinator Get log entry for RandomnessRequest event. :param tx_hash: hash of transaction emitting RandomnessRequest event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.RandomnessRequest().processReceipt(tx_receipt)
def event_randomness_request_fulfilled(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event randomness_request_fulfilled in contract VRFCoordinator Get log entry for RandomnessRequestFulfilled event. :param tx_hash: hash of transaction emitting RandomnessRequestFulfilled event
Expand source code
def event_randomness_request_fulfilled( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event randomness_request_fulfilled in contract VRFCoordinator Get log entry for RandomnessRequestFulfilled event. :param tx_hash: hash of transaction emitting RandomnessRequestFulfilled event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=VRFCoordinator.abi()).events.RandomnessRequestFulfilled().processReceipt(tx_receipt)
def fulfill_randomness_request(self, proof: Union[bytes, str]) ‑> NoneType
-
Implementation of fulfill_randomness_request in contract VRFCoordinator Method of the function
Expand source code
def fulfill_randomness_request(self, proof: Union[bytes, str]) -> None: """ Implementation of fulfill_randomness_request in contract VRFCoordinator Method of the function """ return self._fn_fulfill_randomness_request.block_send(proof, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def hash_of_key(self, public_key: List[int]) ‑> Union[bytes, str]
-
Implementation of hash_of_key in contract VRFCoordinator Method of the function
Expand source code
def hash_of_key(self, public_key: List[int]) -> Union[bytes, str]: """ Implementation of hash_of_key in contract VRFCoordinator Method of the function """ return self._fn_hash_of_key.block_call(public_key)
def is_owner(self) ‑> bool
-
Implementation of is_owner in contract VRFCoordinator Method of the function
Expand source code
def is_owner(self) -> bool: """ Implementation of is_owner in contract VRFCoordinator Method of the function """ return self._fn_is_owner.block_call()
def on_token_transfer(self, sender: str, fee: int, data: Union[bytes, str]) ‑> NoneType
-
Implementation of on_token_transfer in contract VRFCoordinator Method of the function
Expand source code
def on_token_transfer(self, sender: str, fee: int, data: Union[bytes, str]) -> None: """ Implementation of on_token_transfer in contract VRFCoordinator Method of the function """ return self._fn_on_token_transfer.block_send(sender, fee, data, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def owner(self) ‑> str
-
Implementation of owner in contract VRFCoordinator Method of the function
Expand source code
def owner(self) -> str: """ Implementation of owner in contract VRFCoordinator Method of the function """ return self._fn_owner.block_call()
def preseed_offset(self) ‑> int
-
Implementation of preseed_offset in contract VRFCoordinator Method of the function
Expand source code
def preseed_offset(self) -> int: """ Implementation of preseed_offset in contract VRFCoordinator Method of the function """ return self._fn_preseed_offset.block_call()
def proof_length(self) ‑> int
-
Implementation of proof_length in contract VRFCoordinator Method of the function
Expand source code
def proof_length(self) -> int: """ Implementation of proof_length in contract VRFCoordinator Method of the function """ return self._fn_proof_length.block_call()
def public_key_offset(self) ‑> int
-
Implementation of public_key_offset in contract VRFCoordinator Method of the function
Expand source code
def public_key_offset(self) -> int: """ Implementation of public_key_offset in contract VRFCoordinator Method of the function """ return self._fn_public_key_offset.block_call()
def register_proving_key(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str]) ‑> NoneType
-
Implementation of register_proving_key in contract VRFCoordinator Method of the function
Expand source code
def register_proving_key(self, fee: int, oracle: str, public_proving_key: List[int], job_id: Union[bytes, str]) -> None: """ Implementation of register_proving_key in contract VRFCoordinator Method of the function """ return self._fn_register_proving_key.block_send(fee, oracle, public_proving_key, job_id, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def service_agreements(self, index_0: Union[bytes, str]) ‑> Tuple[str, int, Union[bytes, str]]
-
Implementation of service_agreements in contract VRFCoordinator Method of the function
Expand source code
def service_agreements(self, index_0: Union[bytes, str]) -> Tuple[str, int, Union[bytes, str]]: """ Implementation of service_agreements in contract VRFCoordinator Method of the function """ return self._fn_service_agreements.block_call(index_0)
def transfer_ownership(self, new_owner: str) ‑> NoneType
-
Implementation of transfer_ownership in contract VRFCoordinator Method of the function
Expand source code
def transfer_ownership(self, new_owner: str) -> None: """ Implementation of transfer_ownership in contract VRFCoordinator Method of the function """ return self._fn_transfer_ownership.block_send(new_owner, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def withdraw(self, recipient: str, amount: int) ‑> NoneType
-
Implementation of withdraw in contract VRFCoordinator Method of the function
Expand source code
def withdraw(self, recipient: str, amount: int) -> None: """ Implementation of withdraw in contract VRFCoordinator Method of the function """ return self._fn_withdraw.block_send(recipient, amount, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def withdrawable_tokens(self, index_0: str) ‑> int
-
Implementation of withdrawable_tokens in contract VRFCoordinator Method of the function
Expand source code
def withdrawable_tokens(self, index_0: str) -> int: """ Implementation of withdrawable_tokens in contract VRFCoordinator Method of the function """ return self._fn_withdrawable_tokens.block_call(index_0)
class VRFCoordinatorValidator (web3_or_provider: web3.main.Web3, contract_address: str)
-
No-op input validator.
Initialize the instance.
Expand source code
class VRFCoordinatorValidator( # type: ignore Validator ): """No-op input validator."""
Ancestors
Inherited members
class WithdrawMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the withdraw method.
Persist instance data.
Expand source code
class WithdrawMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the withdraw method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("withdraw") def validate_and_normalize_inputs(self, recipient: str, amount: int)->any: """Validate the inputs to the withdraw method.""" self.validator.assert_valid( method_name='withdraw', parameter_name='_recipient', argument_value=recipient, ) recipient = self.validate_and_checksum_address(recipient) self.validator.assert_valid( method_name='withdraw', parameter_name='_amount', argument_value=amount, ) # safeguard against fractional inputs amount = int(amount) return (recipient, amount) def block_send(self, recipient: str, amount: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(recipient, amount) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: withdraw") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdraw: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdraw. Reason: Unknown") def send_transaction(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (recipient, amount) = self.validate_and_normalize_inputs(recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(recipient, amount).transact(tx_params.as_dict()) def build_transaction(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (recipient, amount) = self.validate_and_normalize_inputs(recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(recipient, amount).buildTransaction(tx_params.as_dict()) def estimate_gas(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (recipient, amount) = self.validate_and_normalize_inputs(recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(recipient, amount).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, recipient: str, amount: int, _gaswei: int, _pricewei: int) ‑> NoneType
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, recipient: str, amount: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(recipient, amount) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: withdraw") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdraw: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdraw. Reason: Unknown")
def build_transaction(self, recipient: str, amount: int, tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (recipient, amount) = self.validate_and_normalize_inputs(recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(recipient, amount).buildTransaction(tx_params.as_dict())
def estimate_gas(self, recipient: str, amount: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (recipient, amount) = self.validate_and_normalize_inputs(recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(recipient, amount).estimateGas(tx_params.as_dict())
def send_transaction(self, recipient: str, amount: int, tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (recipient, amount) = self.validate_and_normalize_inputs(recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(recipient, amount).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, recipient: str, amount: int) ‑>
-
Validate the inputs to the withdraw method.
Expand source code
def validate_and_normalize_inputs(self, recipient: str, amount: int)->any: """Validate the inputs to the withdraw method.""" self.validator.assert_valid( method_name='withdraw', parameter_name='_recipient', argument_value=recipient, ) recipient = self.validate_and_checksum_address(recipient) self.validator.assert_valid( method_name='withdraw', parameter_name='_amount', argument_value=amount, ) # safeguard against fractional inputs amount = int(amount) return (recipient, amount)
Inherited members
class WithdrawableTokensMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the withdrawableTokens method.
Persist instance data.
Expand source code
class WithdrawableTokensMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the withdrawableTokens method.""" def __init__(self, elib: MiliDoS, contract_address: str, contract_function: ContractFunction, validator: Validator=None): """Persist instance data.""" super().__init__(elib, contract_address, validator) self._underlying_method = contract_function self.sign = validator.getSignature("withdrawableTokens") def validate_and_normalize_inputs(self, index_0: str)->any: """Validate the inputs to the withdrawableTokens method.""" self.validator.assert_valid( method_name='withdrawableTokens', parameter_name='index_0', argument_value=index_0, ) index_0 = self.validate_and_checksum_address(index_0) return (index_0) def block_call(self,index_0: str, debug:bool=False) -> int: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, index_0: str,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(index_0) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: withdrawable_tokens") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdrawable_tokens: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdrawable_tokens. Reason: Unknown") def send_transaction(self, index_0: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).transact(tx_params.as_dict()) def build_transaction(self, index_0: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).buildTransaction(tx_params.as_dict()) def estimate_gas(self, index_0: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, index_0: str, debug: bool = False) ‑> int
-
Expand source code
def block_call(self,index_0: str, debug:bool=False) -> int: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, index_0: str, _gaswei: int, _pricewei: int) ‑> int
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, index_0: str,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> int: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(index_0) try: _t = _fn.buildTransaction({ 'from': self._operate, 'gas': _gaswei, 'gasPrice': _pricewei }) _t['nonce'] = self._web3_eth.getTransactionCount(self._operate) if _valeth > 0: _t['value'] = _valeth if _debugtx: print(f"======== Signing ✅ by {self._operate}") print(f"======== Transaction ✅ check") print(_t) if 'data' in _t: signed = self._web3_eth.account.sign_transaction(_t) txHash = self._web3_eth.sendRawTransaction(signed.rawTransaction) tx_receipt = None if _receipList is True: print(f"======== awaiting Confirmation 🚸️ {self.sign}") tx_receipt = self._web3_eth.waitForTransactionReceipt(txHash) if _debugtx: print("======== TX Result ✅") print(tx_receipt) print(f"======== TX blockHash ✅") if tx_receipt is not None: print(f"{Bolors.OK}{tx_receipt.blockHash.hex()}{Bolors.RESET}") else: print(f"{Bolors.WARNING}{txHash.hex()}{Bolors.RESET} - broadcast hash") if _receipList is False: time.sleep(self._wait) except ContractLogicError as er: print(f"{Bolors.FAIL}Error {er} {Bolors.RESET}: withdrawable_tokens") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdrawable_tokens: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, withdrawable_tokens. Reason: Unknown")
def build_transaction(self, index_0: str, tx_params: Union[TxParams, NoneType] = None) ‑> dict
-
Construct calldata to be used as input to the method.
Expand source code
def build_transaction(self, index_0: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).buildTransaction(tx_params.as_dict())
def estimate_gas(self, index_0: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, index_0: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).estimateGas(tx_params.as_dict())
def send_transaction(self, index_0: str, tx_params: Union[TxParams, NoneType] = None) ‑> Union[hexbytes.main.HexBytes, bytes]
-
Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
Expand source code
def send_transaction(self, index_0: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (index_0) = self.validate_and_normalize_inputs(index_0) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(index_0).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, index_0: str) ‑>
-
Validate the inputs to the withdrawableTokens method.
Expand source code
def validate_and_normalize_inputs(self, index_0: str)->any: """Validate the inputs to the withdrawableTokens method.""" self.validator.assert_valid( method_name='withdrawableTokens', parameter_name='index_0', argument_value=index_0, ) index_0 = self.validate_and_checksum_address(index_0) return (index_0)
Inherited members