Module moody.m.beri_coin
Generated wrapper for BeriCoin Solidity contract.
Expand source code
"""Generated wrapper for BeriCoin 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 BeriCoin 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
BeriCoinValidator,
)
except ImportError:
class BeriCoinValidator( # type: ignore
Validator
):
"""No-op input validator."""
try:
from .middleware import MIDDLEWARE # type: ignore
except ImportError:
pass
class AdminRoleMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the ADMIN_ROLE 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("ADMIN_ROLE")
def block_call(self, debug: bool = False) -> Union[bytes, str]:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return Union[bytes, str](returned)
def block_send(self, _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()
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}: admin_role")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, admin_role: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, admin_role. 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 DefaultAdminRoleMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the DEFAULT_ADMIN_ROLE 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("DEFAULT_ADMIN_ROLE")
def block_call(self, debug: bool = False) -> Union[bytes, str]:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return Union[bytes, str](returned)
def block_send(self, _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()
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}: default_admin_role")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, default_admin_role: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, default_admin_role. 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 DomainTypehashMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the DOMAIN_TYPEHASH 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("DOMAIN_TYPEHASH")
def block_call(self, debug: bool = False) -> Union[bytes, str]:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return Union[bytes, str](returned)
def block_send(self, _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()
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}: domain_typehash")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, domain_typehash: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, domain_typehash. 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 PermitTypehashMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the PERMIT_TYPEHASH 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("PERMIT_TYPEHASH")
def block_call(self, debug: bool = False) -> Union[bytes, str]:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return Union[bytes, str](returned)
def block_send(self, _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()
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}: permit_typehash")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit_typehash: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit_typehash. 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 SuperRoleMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the SUPER_ROLE 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("SUPER_ROLE")
def block_call(self, debug: bool = False) -> Union[bytes, str]:
_fn = self._underlying_method()
returned = _fn.call({
'from': self._operate
})
return Union[bytes, str](returned)
def block_send(self, _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()
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}: super_role")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, super_role: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, super_role. 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 AddAdminMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the addAdmin 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("addAdmin")
def validate_and_normalize_inputs(self, account: str) -> any:
"""Validate the inputs to the addAdmin method."""
self.validator.assert_valid(
method_name='addAdmin',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (account)
def block_send(self, account: 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(account)
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}: add_admin")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_admin: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_admin. Reason: Unknown")
def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).transact(tx_params.as_dict())
def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).estimateGas(tx_params.as_dict())
class AllowanceMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the allowance 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("allowance")
def validate_and_normalize_inputs(self, owner: str, spender: str) -> any:
"""Validate the inputs to the allowance method."""
self.validator.assert_valid(
method_name='allowance',
parameter_name='owner',
argument_value=owner,
)
owner = self.validate_and_checksum_address(owner)
self.validator.assert_valid(
method_name='allowance',
parameter_name='spender',
argument_value=spender,
)
spender = self.validate_and_checksum_address(spender)
return (owner, spender)
def block_call(self, owner: str, spender: str, debug: bool = False) -> int:
_fn = self._underlying_method(owner, spender)
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, owner: str, spender: 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(owner, spender)
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}: allowance")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, allowance: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, allowance. Reason: Unknown")
def send_transaction(self, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(owner, spender) = self.validate_and_normalize_inputs(owner, spender)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(owner, spender).transact(tx_params.as_dict())
def build_transaction(self, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(owner, spender) = self.validate_and_normalize_inputs(owner, spender)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(owner, spender).buildTransaction(tx_params.as_dict())
def estimate_gas(self, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(owner, spender) = self.validate_and_normalize_inputs(owner, spender)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(owner, spender).estimateGas(tx_params.as_dict())
class ApproveMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the approve 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("approve")
def validate_and_normalize_inputs(self, spender: str, amount: int) -> any:
"""Validate the inputs to the approve method."""
self.validator.assert_valid(
method_name='approve',
parameter_name='spender',
argument_value=spender,
)
spender = self.validate_and_checksum_address(spender)
self.validator.assert_valid(
method_name='approve',
parameter_name='amount',
argument_value=amount,
)
# safeguard against fractional inputs
amount = int(amount)
return (spender, amount)
def block_send(self, spender: str, amount: int, _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(spender, 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}: approve")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, approve: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, approve. Reason: Unknown")
def send_transaction(self, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(spender, amount) = self.validate_and_normalize_inputs(spender, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, amount).transact(tx_params.as_dict())
def build_transaction(self, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(spender, amount) = self.validate_and_normalize_inputs(spender, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, amount).buildTransaction(tx_params.as_dict())
def estimate_gas(self, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(spender, amount) = self.validate_and_normalize_inputs(spender, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, amount).estimateGas(tx_params.as_dict())
class BalanceOfMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the balanceOf 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("balanceOf")
def validate_and_normalize_inputs(self, account: str) -> any:
"""Validate the inputs to the balanceOf method."""
self.validator.assert_valid(
method_name='balanceOf',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (account)
def block_call(self, account: str, debug: bool = False) -> int:
_fn = self._underlying_method(account)
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, account: 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(account)
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}: balance_of")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, balance_of: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, balance_of. Reason: Unknown")
def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).transact(tx_params.as_dict())
def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).estimateGas(tx_params.as_dict())
class CandyOfMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the candyOf 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("candyOf")
def validate_and_normalize_inputs(self, account: str) -> any:
"""Validate the inputs to the candyOf method."""
self.validator.assert_valid(
method_name='candyOf',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (account)
def block_call(self, account: str, debug: bool = False) -> int:
_fn = self._underlying_method(account)
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, account: 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(account)
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}: candy_of")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, candy_of: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, candy_of. Reason: Unknown")
def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).transact(tx_params.as_dict())
def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).estimateGas(tx_params.as_dict())
class CloseMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the close 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("close")
def block_send(self, _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()
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}: close")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, close: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, close. 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 DecimalsMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the decimals 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("decimals")
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}: decimals")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decimals: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decimals. 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 DecreaseAllowanceMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the decreaseAllowance 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("decreaseAllowance")
def validate_and_normalize_inputs(self, spender: str, subtracted_value: int) -> any:
"""Validate the inputs to the decreaseAllowance method."""
self.validator.assert_valid(
method_name='decreaseAllowance',
parameter_name='spender',
argument_value=spender,
)
spender = self.validate_and_checksum_address(spender)
self.validator.assert_valid(
method_name='decreaseAllowance',
parameter_name='subtractedValue',
argument_value=subtracted_value,
)
# safeguard against fractional inputs
subtracted_value = int(subtracted_value)
return (spender, subtracted_value)
def block_send(self, spender: str, subtracted_value: int, _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(spender, subtracted_value)
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}: decrease_allowance")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decrease_allowance: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decrease_allowance. Reason: Unknown")
def send_transaction(self, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, subtracted_value).transact(tx_params.as_dict())
def build_transaction(self, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, subtracted_value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, subtracted_value).estimateGas(tx_params.as_dict())
class GetRoleAdminMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the getRoleAdmin 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("getRoleAdmin")
def validate_and_normalize_inputs(self, role: Union[bytes, str]) -> any:
"""Validate the inputs to the getRoleAdmin method."""
self.validator.assert_valid(
method_name='getRoleAdmin',
parameter_name='role',
argument_value=role,
)
return (role)
def block_call(self, role: Union[bytes, str], debug: bool = False) -> Union[bytes, str]:
_fn = self._underlying_method(role)
returned = _fn.call({
'from': self._operate
})
return Union[bytes, str](returned)
def block_send(self, role: Union[bytes, str], _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(role)
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}: get_role_admin")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_admin: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_admin. Reason: Unknown")
def send_transaction(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(role) = self.validate_and_normalize_inputs(role)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role).transact(tx_params.as_dict())
def build_transaction(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(role) = self.validate_and_normalize_inputs(role)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(role) = self.validate_and_normalize_inputs(role)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role).estimateGas(tx_params.as_dict())
class GetRoleMemberMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the getRoleMember 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("getRoleMember")
def validate_and_normalize_inputs(self, role: Union[bytes, str], index: int) -> any:
"""Validate the inputs to the getRoleMember method."""
self.validator.assert_valid(
method_name='getRoleMember',
parameter_name='role',
argument_value=role,
)
self.validator.assert_valid(
method_name='getRoleMember',
parameter_name='index',
argument_value=index,
)
# safeguard against fractional inputs
index = int(index)
return (role, index)
def block_call(self, role: Union[bytes, str], index: int, debug: bool = False) -> str:
_fn = self._underlying_method(role, index)
returned = _fn.call({
'from': self._operate
})
return str(returned)
def block_send(self, role: Union[bytes, str], index: int, _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(role, index)
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}: get_role_member")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member. Reason: Unknown")
def send_transaction(self, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(role, index) = self.validate_and_normalize_inputs(role, index)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, index).transact(tx_params.as_dict())
def build_transaction(self, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(role, index) = self.validate_and_normalize_inputs(role, index)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, index).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(role, index) = self.validate_and_normalize_inputs(role, index)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, index).estimateGas(tx_params.as_dict())
class GetRoleMemberCountMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the getRoleMemberCount 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("getRoleMemberCount")
def validate_and_normalize_inputs(self, role: Union[bytes, str]) -> any:
"""Validate the inputs to the getRoleMemberCount method."""
self.validator.assert_valid(
method_name='getRoleMemberCount',
parameter_name='role',
argument_value=role,
)
return (role)
def block_call(self, role: Union[bytes, str], debug: bool = False) -> int:
_fn = self._underlying_method(role)
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, role: Union[bytes, 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(role)
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}: get_role_member_count")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member_count: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member_count. Reason: Unknown")
def send_transaction(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(role) = self.validate_and_normalize_inputs(role)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role).transact(tx_params.as_dict())
def build_transaction(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(role) = self.validate_and_normalize_inputs(role)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(role) = self.validate_and_normalize_inputs(role)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role).estimateGas(tx_params.as_dict())
class GrantRoleMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the grantRole 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("grantRole")
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any:
"""Validate the inputs to the grantRole method."""
self.validator.assert_valid(
method_name='grantRole',
parameter_name='role',
argument_value=role,
)
self.validator.assert_valid(
method_name='grantRole',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (role, account)
def block_send(self, role: Union[bytes, str], account: 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(role, account)
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}: grant_role")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, grant_role: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, grant_role. Reason: Unknown")
def send_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).transact(tx_params.as_dict())
def build_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
class HasRoleMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the hasRole 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("hasRole")
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any:
"""Validate the inputs to the hasRole method."""
self.validator.assert_valid(
method_name='hasRole',
parameter_name='role',
argument_value=role,
)
self.validator.assert_valid(
method_name='hasRole',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (role, account)
def block_call(self, role: Union[bytes, str], account: str, debug: bool = False) -> bool:
_fn = self._underlying_method(role, account)
returned = _fn.call({
'from': self._operate
})
return bool(returned)
def block_send(self, role: Union[bytes, str], account: str, _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(role, account)
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}: has_role")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, has_role: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, has_role. Reason: Unknown")
def send_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).transact(tx_params.as_dict())
def build_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
class IncreaseAllowanceMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the increaseAllowance 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("increaseAllowance")
def validate_and_normalize_inputs(self, spender: str, added_value: int) -> any:
"""Validate the inputs to the increaseAllowance method."""
self.validator.assert_valid(
method_name='increaseAllowance',
parameter_name='spender',
argument_value=spender,
)
spender = self.validate_and_checksum_address(spender)
self.validator.assert_valid(
method_name='increaseAllowance',
parameter_name='addedValue',
argument_value=added_value,
)
# safeguard against fractional inputs
added_value = int(added_value)
return (spender, added_value)
def block_send(self, spender: str, added_value: int, _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(spender, added_value)
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}: increase_allowance")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, increase_allowance: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, increase_allowance. Reason: Unknown")
def send_transaction(self, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(spender, added_value) = self.validate_and_normalize_inputs(spender, added_value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, added_value).transact(tx_params.as_dict())
def build_transaction(self, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(spender, added_value) = self.validate_and_normalize_inputs(spender, added_value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, added_value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(spender, added_value) = self.validate_and_normalize_inputs(spender, added_value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(spender, added_value).estimateGas(tx_params.as_dict())
class IsAdminMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the isAdmin 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("isAdmin")
def validate_and_normalize_inputs(self, account: str) -> any:
"""Validate the inputs to the isAdmin method."""
self.validator.assert_valid(
method_name='isAdmin',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (account)
def block_call(self, account: str, debug: bool = False) -> bool:
_fn = self._underlying_method(account)
returned = _fn.call({
'from': self._operate
})
return bool(returned)
def block_send(self, account: str, _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(account)
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_admin")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_admin: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_admin. Reason: Unknown")
def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).transact(tx_params.as_dict())
def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).estimateGas(tx_params.as_dict())
class MeMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the me 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("me")
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}: me")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, me: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, me. 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 NameMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the name 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("name")
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}: name")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, name: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, name. 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 NoncesMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the nonces 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("nonces")
def validate_and_normalize_inputs(self, index_0: str) -> any:
"""Validate the inputs to the nonces method."""
self.validator.assert_valid(
method_name='nonces',
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}: nonces")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, nonces: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, nonces. 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 PermitMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the permit 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("permit")
def validate_and_normalize_inputs(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str]) -> any:
"""Validate the inputs to the permit method."""
self.validator.assert_valid(
method_name='permit',
parameter_name='owner',
argument_value=owner,
)
owner = self.validate_and_checksum_address(owner)
self.validator.assert_valid(
method_name='permit',
parameter_name='spender',
argument_value=spender,
)
spender = self.validate_and_checksum_address(spender)
self.validator.assert_valid(
method_name='permit',
parameter_name='rawAmount',
argument_value=raw_amount,
)
# safeguard against fractional inputs
raw_amount = int(raw_amount)
self.validator.assert_valid(
method_name='permit',
parameter_name='deadline',
argument_value=deadline,
)
# safeguard against fractional inputs
deadline = int(deadline)
self.validator.assert_valid(
method_name='permit',
parameter_name='v',
argument_value=v,
)
self.validator.assert_valid(
method_name='permit',
parameter_name='r',
argument_value=r,
)
self.validator.assert_valid(
method_name='permit',
parameter_name='s',
argument_value=s,
)
return (owner, spender, raw_amount, deadline, v, r, s)
def block_send(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: 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(owner, spender, raw_amount, deadline, v, r, s)
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}: permit")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit. Reason: Unknown")
def send_transaction(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).transact(tx_params.as_dict())
def build_transaction(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).buildTransaction(tx_params.as_dict())
def estimate_gas(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).estimateGas(tx_params.as_dict())
class RenounceAdminMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the renounceAdmin 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("renounceAdmin")
def block_send(self, _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()
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}: renounce_admin")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_admin: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_admin. 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 RenounceRoleMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the renounceRole 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("renounceRole")
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any:
"""Validate the inputs to the renounceRole method."""
self.validator.assert_valid(
method_name='renounceRole',
parameter_name='role',
argument_value=role,
)
self.validator.assert_valid(
method_name='renounceRole',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (role, account)
def block_send(self, role: Union[bytes, str], account: 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(role, account)
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}: renounce_role")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_role: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_role. Reason: Unknown")
def send_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).transact(tx_params.as_dict())
def build_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
class RevokeRoleMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the revokeRole 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("revokeRole")
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any:
"""Validate the inputs to the revokeRole method."""
self.validator.assert_valid(
method_name='revokeRole',
parameter_name='role',
argument_value=role,
)
self.validator.assert_valid(
method_name='revokeRole',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (role, account)
def block_send(self, role: Union[bytes, str], account: 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(role, account)
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}: revoke_role")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, revoke_role: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, revoke_role. Reason: Unknown")
def send_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).transact(tx_params.as_dict())
def build_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(role, account) = self.validate_and_normalize_inputs(role, account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
class SafeBurnMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the safeBurn 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("safeBurn")
def validate_and_normalize_inputs(self, account: str, value: int) -> any:
"""Validate the inputs to the safeBurn method."""
self.validator.assert_valid(
method_name='safeBurn',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
self.validator.assert_valid(
method_name='safeBurn',
parameter_name='value',
argument_value=value,
)
# safeguard against fractional inputs
value = int(value)
return (account, value)
def block_send(self, account: str, value: int, _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(account, value)
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}: safe_burn")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_burn: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_burn. Reason: Unknown")
def send_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).transact(tx_params.as_dict())
def build_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
class SafeMintMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the safeMint 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("safeMint")
def validate_and_normalize_inputs(self, account: str, value: int) -> any:
"""Validate the inputs to the safeMint method."""
self.validator.assert_valid(
method_name='safeMint',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
self.validator.assert_valid(
method_name='safeMint',
parameter_name='value',
argument_value=value,
)
# safeguard against fractional inputs
value = int(value)
return (account, value)
def block_send(self, account: str, value: int, _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(account, value)
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}: safe_mint")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_mint: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_mint. Reason: Unknown")
def send_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).transact(tx_params.as_dict())
def build_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
class SafeRefundMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the safeRefund 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("safeRefund")
def validate_and_normalize_inputs(self, account: str, value: int) -> any:
"""Validate the inputs to the safeRefund method."""
self.validator.assert_valid(
method_name='safeRefund',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
self.validator.assert_valid(
method_name='safeRefund',
parameter_name='value',
argument_value=value,
)
# safeguard against fractional inputs
value = int(value)
return (account, value)
def block_send(self, account: str, value: int, _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(account, value)
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}: safe_refund")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_refund: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_refund. Reason: Unknown")
def send_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).transact(tx_params.as_dict())
def build_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
class SafeTransferMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the safeTransfer 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("safeTransfer")
def validate_and_normalize_inputs(self, _from: str, to: str, value: int) -> any:
"""Validate the inputs to the safeTransfer method."""
self.validator.assert_valid(
method_name='safeTransfer',
parameter_name='from',
argument_value=_from,
)
_from = self.validate_and_checksum_address(_from)
self.validator.assert_valid(
method_name='safeTransfer',
parameter_name='to',
argument_value=to,
)
to = self.validate_and_checksum_address(to)
self.validator.assert_valid(
method_name='safeTransfer',
parameter_name='value',
argument_value=value,
)
# safeguard against fractional inputs
value = int(value)
return (_from, to, value)
def block_send(self, _from: str, to: str, value: int, _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(_from, to, value)
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}: safe_transfer")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_transfer: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_transfer. Reason: Unknown")
def send_transaction(self, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(_from, to, value) = self.validate_and_normalize_inputs(_from, to, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(_from, to, value).transact(tx_params.as_dict())
def build_transaction(self, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(_from, to, value) = self.validate_and_normalize_inputs(_from, to, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(_from, to, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(_from, to, value) = self.validate_and_normalize_inputs(_from, to, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(_from, to, value).estimateGas(tx_params.as_dict())
class SendCandyMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the sendCandy 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("sendCandy")
def validate_and_normalize_inputs(self, account: str, value: int) -> any:
"""Validate the inputs to the sendCandy method."""
self.validator.assert_valid(
method_name='sendCandy',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
self.validator.assert_valid(
method_name='sendCandy',
parameter_name='value',
argument_value=value,
)
# safeguard against fractional inputs
value = int(value)
return (account, value)
def block_send(self, account: str, value: int, _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(account, value)
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}: send_candy")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_candy: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_candy. Reason: Unknown")
def send_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).transact(tx_params.as_dict())
def build_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account, value) = self.validate_and_normalize_inputs(account, value)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
class SymbolMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the symbol 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("symbol")
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}: symbol")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, symbol: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, symbol. 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 TokenOfMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the tokenOf 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("tokenOf")
def validate_and_normalize_inputs(self, account: str) -> any:
"""Validate the inputs to the tokenOf method."""
self.validator.assert_valid(
method_name='tokenOf',
parameter_name='account',
argument_value=account,
)
account = self.validate_and_checksum_address(account)
return (account)
def block_call(self, account: str, debug: bool = False) -> int:
_fn = self._underlying_method(account)
returned = _fn.call({
'from': self._operate
})
return int(returned)
def block_send(self, account: 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(account)
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}: token_of")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_of: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_of. Reason: Unknown")
def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).transact(tx_params.as_dict())
def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(account) = self.validate_and_normalize_inputs(account)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(account).estimateGas(tx_params.as_dict())
class TokenRateMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the tokenRate 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("tokenRate")
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}: token_rate")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_rate: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_rate. 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 TotalSupplyMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the totalSupply 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("totalSupply")
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}: total_supply")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, total_supply: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, total_supply. 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 TransferMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the transfer 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("transfer")
def validate_and_normalize_inputs(self, recipient: str, amount: int) -> any:
"""Validate the inputs to the transfer method."""
self.validator.assert_valid(
method_name='transfer',
parameter_name='recipient',
argument_value=recipient,
)
recipient = self.validate_and_checksum_address(recipient)
self.validator.assert_valid(
method_name='transfer',
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) -> 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(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}: transfer")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer. 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 TransferFromMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the transferFrom 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("transferFrom")
def validate_and_normalize_inputs(self, sender: str, recipient: str, amount: int) -> any:
"""Validate the inputs to the transferFrom method."""
self.validator.assert_valid(
method_name='transferFrom',
parameter_name='sender',
argument_value=sender,
)
sender = self.validate_and_checksum_address(sender)
self.validator.assert_valid(
method_name='transferFrom',
parameter_name='recipient',
argument_value=recipient,
)
recipient = self.validate_and_checksum_address(recipient)
self.validator.assert_valid(
method_name='transferFrom',
parameter_name='amount',
argument_value=amount,
)
# safeguard against fractional inputs
amount = int(amount)
return (sender, recipient, amount)
def block_send(self, sender: str, recipient: str, amount: int, _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(sender, 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}: transfer_from")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_from: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_from. Reason: Unknown")
def send_transaction(self, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(sender, recipient, amount).transact(tx_params.as_dict())
def build_transaction(self, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(sender, recipient, amount).buildTransaction(tx_params.as_dict())
def estimate_gas(self, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(sender, recipient, amount).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 admin_role(self) -> str:
return self._function_signatures["ADMIN_ROLE"]
def default_admin_role(self) -> str:
return self._function_signatures["DEFAULT_ADMIN_ROLE"]
def domain_typehash(self) -> str:
return self._function_signatures["DOMAIN_TYPEHASH"]
def permit_typehash(self) -> str:
return self._function_signatures["PERMIT_TYPEHASH"]
def super_role(self) -> str:
return self._function_signatures["SUPER_ROLE"]
def add_admin(self) -> str:
return self._function_signatures["addAdmin"]
def allowance(self) -> str:
return self._function_signatures["allowance"]
def approve(self) -> str:
return self._function_signatures["approve"]
def balance_of(self) -> str:
return self._function_signatures["balanceOf"]
def candy_of(self) -> str:
return self._function_signatures["candyOf"]
def close(self) -> str:
return self._function_signatures["close"]
def decimals(self) -> str:
return self._function_signatures["decimals"]
def decrease_allowance(self) -> str:
return self._function_signatures["decreaseAllowance"]
def get_role_admin(self) -> str:
return self._function_signatures["getRoleAdmin"]
def get_role_member(self) -> str:
return self._function_signatures["getRoleMember"]
def get_role_member_count(self) -> str:
return self._function_signatures["getRoleMemberCount"]
def grant_role(self) -> str:
return self._function_signatures["grantRole"]
def has_role(self) -> str:
return self._function_signatures["hasRole"]
def increase_allowance(self) -> str:
return self._function_signatures["increaseAllowance"]
def is_admin(self) -> str:
return self._function_signatures["isAdmin"]
def me(self) -> str:
return self._function_signatures["me"]
def name(self) -> str:
return self._function_signatures["name"]
def nonces(self) -> str:
return self._function_signatures["nonces"]
def permit(self) -> str:
return self._function_signatures["permit"]
def renounce_admin(self) -> str:
return self._function_signatures["renounceAdmin"]
def renounce_role(self) -> str:
return self._function_signatures["renounceRole"]
def revoke_role(self) -> str:
return self._function_signatures["revokeRole"]
def safe_burn(self) -> str:
return self._function_signatures["safeBurn"]
def safe_mint(self) -> str:
return self._function_signatures["safeMint"]
def safe_refund(self) -> str:
return self._function_signatures["safeRefund"]
def safe_transfer(self) -> str:
return self._function_signatures["safeTransfer"]
def send_candy(self) -> str:
return self._function_signatures["sendCandy"]
def symbol(self) -> str:
return self._function_signatures["symbol"]
def token_of(self) -> str:
return self._function_signatures["tokenOf"]
def token_rate(self) -> str:
return self._function_signatures["tokenRate"]
def total_supply(self) -> str:
return self._function_signatures["totalSupply"]
def transfer(self) -> str:
return self._function_signatures["transfer"]
def transfer_from(self) -> str:
return self._function_signatures["transferFrom"]
# pylint: disable=too-many-public-methods,too-many-instance-attributes
class BeriCoin(ContractBase):
"""Wrapper class for BeriCoin Solidity contract."""
_fn_admin_role: AdminRoleMethod
"""Constructor-initialized instance of
:class:`AdminRoleMethod`.
"""
_fn_default_admin_role: DefaultAdminRoleMethod
"""Constructor-initialized instance of
:class:`DefaultAdminRoleMethod`.
"""
_fn_domain_typehash: DomainTypehashMethod
"""Constructor-initialized instance of
:class:`DomainTypehashMethod`.
"""
_fn_permit_typehash: PermitTypehashMethod
"""Constructor-initialized instance of
:class:`PermitTypehashMethod`.
"""
_fn_super_role: SuperRoleMethod
"""Constructor-initialized instance of
:class:`SuperRoleMethod`.
"""
_fn_add_admin: AddAdminMethod
"""Constructor-initialized instance of
:class:`AddAdminMethod`.
"""
_fn_allowance: AllowanceMethod
"""Constructor-initialized instance of
:class:`AllowanceMethod`.
"""
_fn_approve: ApproveMethod
"""Constructor-initialized instance of
:class:`ApproveMethod`.
"""
_fn_balance_of: BalanceOfMethod
"""Constructor-initialized instance of
:class:`BalanceOfMethod`.
"""
_fn_candy_of: CandyOfMethod
"""Constructor-initialized instance of
:class:`CandyOfMethod`.
"""
_fn_close: CloseMethod
"""Constructor-initialized instance of
:class:`CloseMethod`.
"""
_fn_decimals: DecimalsMethod
"""Constructor-initialized instance of
:class:`DecimalsMethod`.
"""
_fn_decrease_allowance: DecreaseAllowanceMethod
"""Constructor-initialized instance of
:class:`DecreaseAllowanceMethod`.
"""
_fn_get_role_admin: GetRoleAdminMethod
"""Constructor-initialized instance of
:class:`GetRoleAdminMethod`.
"""
_fn_get_role_member: GetRoleMemberMethod
"""Constructor-initialized instance of
:class:`GetRoleMemberMethod`.
"""
_fn_get_role_member_count: GetRoleMemberCountMethod
"""Constructor-initialized instance of
:class:`GetRoleMemberCountMethod`.
"""
_fn_grant_role: GrantRoleMethod
"""Constructor-initialized instance of
:class:`GrantRoleMethod`.
"""
_fn_has_role: HasRoleMethod
"""Constructor-initialized instance of
:class:`HasRoleMethod`.
"""
_fn_increase_allowance: IncreaseAllowanceMethod
"""Constructor-initialized instance of
:class:`IncreaseAllowanceMethod`.
"""
_fn_is_admin: IsAdminMethod
"""Constructor-initialized instance of
:class:`IsAdminMethod`.
"""
_fn_me: MeMethod
"""Constructor-initialized instance of
:class:`MeMethod`.
"""
_fn_name: NameMethod
"""Constructor-initialized instance of
:class:`NameMethod`.
"""
_fn_nonces: NoncesMethod
"""Constructor-initialized instance of
:class:`NoncesMethod`.
"""
_fn_permit: PermitMethod
"""Constructor-initialized instance of
:class:`PermitMethod`.
"""
_fn_renounce_admin: RenounceAdminMethod
"""Constructor-initialized instance of
:class:`RenounceAdminMethod`.
"""
_fn_renounce_role: RenounceRoleMethod
"""Constructor-initialized instance of
:class:`RenounceRoleMethod`.
"""
_fn_revoke_role: RevokeRoleMethod
"""Constructor-initialized instance of
:class:`RevokeRoleMethod`.
"""
_fn_safe_burn: SafeBurnMethod
"""Constructor-initialized instance of
:class:`SafeBurnMethod`.
"""
_fn_safe_mint: SafeMintMethod
"""Constructor-initialized instance of
:class:`SafeMintMethod`.
"""
_fn_safe_refund: SafeRefundMethod
"""Constructor-initialized instance of
:class:`SafeRefundMethod`.
"""
_fn_safe_transfer: SafeTransferMethod
"""Constructor-initialized instance of
:class:`SafeTransferMethod`.
"""
_fn_send_candy: SendCandyMethod
"""Constructor-initialized instance of
:class:`SendCandyMethod`.
"""
_fn_symbol: SymbolMethod
"""Constructor-initialized instance of
:class:`SymbolMethod`.
"""
_fn_token_of: TokenOfMethod
"""Constructor-initialized instance of
:class:`TokenOfMethod`.
"""
_fn_token_rate: TokenRateMethod
"""Constructor-initialized instance of
:class:`TokenRateMethod`.
"""
_fn_total_supply: TotalSupplyMethod
"""Constructor-initialized instance of
:class:`TotalSupplyMethod`.
"""
_fn_transfer: TransferMethod
"""Constructor-initialized instance of
:class:`TransferMethod`.
"""
_fn_transfer_from: TransferFromMethod
"""Constructor-initialized instance of
:class:`TransferFromMethod`.
"""
SIGNATURES: SignatureGenerator = None
def __init__(
self,
core_lib: MiliDoS,
contract_address: str,
validator: BeriCoinValidator = 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 = BeriCoinValidator(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=BeriCoin.abi()).functions
signed = SignatureGenerator(BeriCoin.abi())
validator.bindSignatures(signed)
self.SIGNATURES = signed
self._fn_admin_role = AdminRoleMethod(core_lib, contract_address, functions.ADMIN_ROLE, validator)
self._fn_default_admin_role = DefaultAdminRoleMethod(core_lib, contract_address, functions.DEFAULT_ADMIN_ROLE, validator)
self._fn_domain_typehash = DomainTypehashMethod(core_lib, contract_address, functions.DOMAIN_TYPEHASH, validator)
self._fn_permit_typehash = PermitTypehashMethod(core_lib, contract_address, functions.PERMIT_TYPEHASH, validator)
self._fn_super_role = SuperRoleMethod(core_lib, contract_address, functions.SUPER_ROLE, validator)
self._fn_add_admin = AddAdminMethod(core_lib, contract_address, functions.addAdmin, validator)
self._fn_allowance = AllowanceMethod(core_lib, contract_address, functions.allowance, validator)
self._fn_approve = ApproveMethod(core_lib, contract_address, functions.approve, validator)
self._fn_balance_of = BalanceOfMethod(core_lib, contract_address, functions.balanceOf, validator)
self._fn_candy_of = CandyOfMethod(core_lib, contract_address, functions.candyOf, validator)
self._fn_close = CloseMethod(core_lib, contract_address, functions.close, validator)
self._fn_decimals = DecimalsMethod(core_lib, contract_address, functions.decimals, validator)
self._fn_decrease_allowance = DecreaseAllowanceMethod(core_lib, contract_address, functions.decreaseAllowance, validator)
self._fn_get_role_admin = GetRoleAdminMethod(core_lib, contract_address, functions.getRoleAdmin, validator)
self._fn_get_role_member = GetRoleMemberMethod(core_lib, contract_address, functions.getRoleMember, validator)
self._fn_get_role_member_count = GetRoleMemberCountMethod(core_lib, contract_address, functions.getRoleMemberCount, validator)
self._fn_grant_role = GrantRoleMethod(core_lib, contract_address, functions.grantRole, validator)
self._fn_has_role = HasRoleMethod(core_lib, contract_address, functions.hasRole, validator)
self._fn_increase_allowance = IncreaseAllowanceMethod(core_lib, contract_address, functions.increaseAllowance, validator)
self._fn_is_admin = IsAdminMethod(core_lib, contract_address, functions.isAdmin, validator)
self._fn_me = MeMethod(core_lib, contract_address, functions.me, validator)
self._fn_name = NameMethod(core_lib, contract_address, functions.name, validator)
self._fn_nonces = NoncesMethod(core_lib, contract_address, functions.nonces, validator)
self._fn_permit = PermitMethod(core_lib, contract_address, functions.permit, validator)
self._fn_renounce_admin = RenounceAdminMethod(core_lib, contract_address, functions.renounceAdmin, validator)
self._fn_renounce_role = RenounceRoleMethod(core_lib, contract_address, functions.renounceRole, validator)
self._fn_revoke_role = RevokeRoleMethod(core_lib, contract_address, functions.revokeRole, validator)
self._fn_safe_burn = SafeBurnMethod(core_lib, contract_address, functions.safeBurn, validator)
self._fn_safe_mint = SafeMintMethod(core_lib, contract_address, functions.safeMint, validator)
self._fn_safe_refund = SafeRefundMethod(core_lib, contract_address, functions.safeRefund, validator)
self._fn_safe_transfer = SafeTransferMethod(core_lib, contract_address, functions.safeTransfer, validator)
self._fn_send_candy = SendCandyMethod(core_lib, contract_address, functions.sendCandy, validator)
self._fn_symbol = SymbolMethod(core_lib, contract_address, functions.symbol, validator)
self._fn_token_of = TokenOfMethod(core_lib, contract_address, functions.tokenOf, validator)
self._fn_token_rate = TokenRateMethod(core_lib, contract_address, functions.tokenRate, validator)
self._fn_total_supply = TotalSupplyMethod(core_lib, contract_address, functions.totalSupply, validator)
self._fn_transfer = TransferMethod(core_lib, contract_address, functions.transfer, validator)
self._fn_transfer_from = TransferFromMethod(core_lib, contract_address, functions.transferFrom, validator)
def event_admin_added(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event admin_added in contract BeriCoin
Get log entry for AdminAdded event.
:param tx_hash: hash of transaction emitting AdminAdded event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.AdminAdded().processReceipt(tx_receipt)
def event_admin_removed(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event admin_removed in contract BeriCoin
Get log entry for AdminRemoved event.
:param tx_hash: hash of transaction emitting AdminRemoved event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.AdminRemoved().processReceipt(tx_receipt)
def event_approval(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event approval in contract BeriCoin
Get log entry for Approval event.
:param tx_hash: hash of transaction emitting Approval event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Approval().processReceipt(tx_receipt)
def event_burn_candy(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event burn_candy in contract BeriCoin
Get log entry for BurnCandy event.
:param tx_hash: hash of transaction emitting BurnCandy event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.BurnCandy().processReceipt(tx_receipt)
def event_refund(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event refund in contract BeriCoin
Get log entry for Refund event.
:param tx_hash: hash of transaction emitting Refund event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Refund().processReceipt(tx_receipt)
def event_role_granted(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event role_granted in contract BeriCoin
Get log entry for RoleGranted event.
:param tx_hash: hash of transaction emitting RoleGranted event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.RoleGranted().processReceipt(tx_receipt)
def event_role_revoked(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event role_revoked in contract BeriCoin
Get log entry for RoleRevoked event.
:param tx_hash: hash of transaction emitting RoleRevoked event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.RoleRevoked().processReceipt(tx_receipt)
def event_send_candy(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event send_candy in contract BeriCoin
Get log entry for SendCandy event.
:param tx_hash: hash of transaction emitting SendCandy event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.SendCandy().processReceipt(tx_receipt)
def event_transfer(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event transfer in contract BeriCoin
Get log entry for Transfer event.
:param tx_hash: hash of transaction emitting Transfer event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Transfer().processReceipt(tx_receipt)
def event_transfer_candy(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event transfer_candy in contract BeriCoin
Get log entry for TransferCandy event.
:param tx_hash: hash of transaction emitting TransferCandy event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.TransferCandy().processReceipt(tx_receipt)
def admin_role(self) -> Union[bytes, str]:
"""
Implementation of admin_role in contract BeriCoin
Method of the function
"""
return self._fn_admin_role.block_call()
def default_admin_role(self) -> Union[bytes, str]:
"""
Implementation of default_admin_role in contract BeriCoin
Method of the function
"""
return self._fn_default_admin_role.block_call()
def domain_typehash(self) -> Union[bytes, str]:
"""
Implementation of domain_typehash in contract BeriCoin
Method of the function
"""
return self._fn_domain_typehash.block_call()
def permit_typehash(self) -> Union[bytes, str]:
"""
Implementation of permit_typehash in contract BeriCoin
Method of the function
"""
return self._fn_permit_typehash.block_call()
def super_role(self) -> Union[bytes, str]:
"""
Implementation of super_role in contract BeriCoin
Method of the function
"""
return self._fn_super_role.block_call()
def add_admin(self, account: str) -> None:
"""
Implementation of add_admin in contract BeriCoin
Method of the function
"""
return self._fn_add_admin.block_send(account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def allowance(self, owner: str, spender: str) -> int:
"""
Implementation of allowance in contract BeriCoin
Method of the function
"""
return self._fn_allowance.block_call(owner, spender)
def approve(self, spender: str, amount: int) -> bool:
"""
Implementation of approve in contract BeriCoin
Method of the function
"""
return self._fn_approve.block_send(spender, amount, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def balance_of(self, account: str) -> int:
"""
Implementation of balance_of in contract BeriCoin
Method of the function
"""
return self._fn_balance_of.block_call(account)
def candy_of(self, account: str) -> int:
"""
Implementation of candy_of in contract BeriCoin
Method of the function
"""
return self._fn_candy_of.block_call(account)
def close(self, wei: int = 0) -> None:
"""
Implementation of close in contract BeriCoin
Method of the function
"""
return self._fn_close.block_send(self.call_contract_fee_amount, self.call_contract_fee_price, wei, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def decimals(self) -> int:
"""
Implementation of decimals in contract BeriCoin
Method of the function
"""
return self._fn_decimals.block_call()
def decrease_allowance(self, spender: str, subtracted_value: int) -> bool:
"""
Implementation of decrease_allowance in contract BeriCoin
Method of the function
"""
return self._fn_decrease_allowance.block_send(spender, subtracted_value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def get_role_admin(self, role: Union[bytes, str]) -> Union[bytes, str]:
"""
Implementation of get_role_admin in contract BeriCoin
Method of the function
"""
return self._fn_get_role_admin.block_call(role)
def get_role_member(self, role: Union[bytes, str], index: int) -> str:
"""
Implementation of get_role_member in contract BeriCoin
Method of the function
"""
return self._fn_get_role_member.block_call(role, index)
def get_role_member_count(self, role: Union[bytes, str]) -> int:
"""
Implementation of get_role_member_count in contract BeriCoin
Method of the function
"""
return self._fn_get_role_member_count.block_call(role)
def grant_role(self, role: Union[bytes, str], account: str) -> None:
"""
Implementation of grant_role in contract BeriCoin
Method of the function
"""
return self._fn_grant_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def has_role(self, role: Union[bytes, str], account: str) -> bool:
"""
Implementation of has_role in contract BeriCoin
Method of the function
"""
return self._fn_has_role.block_call(role, account)
def increase_allowance(self, spender: str, added_value: int) -> bool:
"""
Implementation of increase_allowance in contract BeriCoin
Method of the function
"""
return self._fn_increase_allowance.block_send(spender, added_value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def is_admin(self, account: str) -> bool:
"""
Implementation of is_admin in contract BeriCoin
Method of the function
"""
return self._fn_is_admin.block_call(account)
def me(self) -> str:
"""
Implementation of me in contract BeriCoin
Method of the function
"""
return self._fn_me.block_call()
def name(self) -> str:
"""
Implementation of name in contract BeriCoin
Method of the function
"""
return self._fn_name.block_call()
def nonces(self, index_0: str) -> int:
"""
Implementation of nonces in contract BeriCoin
Method of the function
"""
return self._fn_nonces.block_call(index_0)
def permit(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str]) -> None:
"""
Implementation of permit in contract BeriCoin
Method of the function
"""
return self._fn_permit.block_send(owner, spender, raw_amount, deadline, v, r, s, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def renounce_admin(self) -> None:
"""
Implementation of renounce_admin in contract BeriCoin
Method of the function
"""
return self._fn_renounce_admin.block_send(self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def renounce_role(self, role: Union[bytes, str], account: str) -> None:
"""
Implementation of renounce_role in contract BeriCoin
Method of the function
"""
return self._fn_renounce_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def revoke_role(self, role: Union[bytes, str], account: str) -> None:
"""
Implementation of revoke_role in contract BeriCoin
Method of the function
"""
return self._fn_revoke_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def safe_burn(self, account: str, value: int) -> bool:
"""
Implementation of safe_burn in contract BeriCoin
Method of the function
"""
return self._fn_safe_burn.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def safe_mint(self, account: str, value: int) -> bool:
"""
Implementation of safe_mint in contract BeriCoin
Method of the function
"""
return self._fn_safe_mint.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def safe_refund(self, account: str, value: int) -> bool:
"""
Implementation of safe_refund in contract BeriCoin
Method of the function
"""
return self._fn_safe_refund.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def safe_transfer(self, _from: str, to: str, value: int) -> bool:
"""
Implementation of safe_transfer in contract BeriCoin
Method of the function
"""
return self._fn_safe_transfer.block_send(_from, to, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def send_candy(self, account: str, value: int) -> bool:
"""
Implementation of send_candy in contract BeriCoin
Method of the function
"""
return self._fn_send_candy.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def symbol(self) -> str:
"""
Implementation of symbol in contract BeriCoin
Method of the function
"""
return self._fn_symbol.block_call()
def token_of(self, account: str) -> int:
"""
Implementation of token_of in contract BeriCoin
Method of the function
"""
return self._fn_token_of.block_call(account)
def token_rate(self) -> int:
"""
Implementation of token_rate in contract BeriCoin
Method of the function
"""
return self._fn_token_rate.block_call()
def total_supply(self) -> int:
"""
Implementation of total_supply in contract BeriCoin
Method of the function
"""
return self._fn_total_supply.block_call()
def transfer(self, recipient: str, amount: int) -> bool:
"""
Implementation of transfer in contract BeriCoin
Method of the function
"""
return self._fn_transfer.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 transfer_from(self, sender: str, recipient: str, amount: int) -> bool:
"""
Implementation of transfer_from in contract BeriCoin
Method of the function
"""
return self._fn_transfer_from.block_send(sender, 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 CallContractWait(self, t_long: int) -> "BeriCoin":
self._fn_admin_role.setWait(t_long)
self._fn_default_admin_role.setWait(t_long)
self._fn_domain_typehash.setWait(t_long)
self._fn_permit_typehash.setWait(t_long)
self._fn_super_role.setWait(t_long)
self._fn_add_admin.setWait(t_long)
self._fn_allowance.setWait(t_long)
self._fn_approve.setWait(t_long)
self._fn_balance_of.setWait(t_long)
self._fn_candy_of.setWait(t_long)
self._fn_close.setWait(t_long)
self._fn_decimals.setWait(t_long)
self._fn_decrease_allowance.setWait(t_long)
self._fn_get_role_admin.setWait(t_long)
self._fn_get_role_member.setWait(t_long)
self._fn_get_role_member_count.setWait(t_long)
self._fn_grant_role.setWait(t_long)
self._fn_has_role.setWait(t_long)
self._fn_increase_allowance.setWait(t_long)
self._fn_is_admin.setWait(t_long)
self._fn_me.setWait(t_long)
self._fn_name.setWait(t_long)
self._fn_nonces.setWait(t_long)
self._fn_permit.setWait(t_long)
self._fn_renounce_admin.setWait(t_long)
self._fn_renounce_role.setWait(t_long)
self._fn_revoke_role.setWait(t_long)
self._fn_safe_burn.setWait(t_long)
self._fn_safe_mint.setWait(t_long)
self._fn_safe_refund.setWait(t_long)
self._fn_safe_transfer.setWait(t_long)
self._fn_send_candy.setWait(t_long)
self._fn_symbol.setWait(t_long)
self._fn_token_of.setWait(t_long)
self._fn_token_rate.setWait(t_long)
self._fn_total_supply.setWait(t_long)
self._fn_transfer.setWait(t_long)
self._fn_transfer_from.setWait(t_long)
return self
@staticmethod
def abi():
"""Return the ABI to the underlying contract."""
return json.loads(
'[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"AdminAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"AdminRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BurnCandy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"SendCandy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferCandy","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SUPER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"candyOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"close","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"me","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"rawAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeBurn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeRefund","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeTransfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"sendCandy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"tokenOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]'
# noqa: E501 (line-too-long)
)
# pylint: disable=too-many-lines
Classes
class AddAdminMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the addAdmin method.
Persist instance data.
Expand source code
class AddAdminMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the addAdmin 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("addAdmin") def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the addAdmin method.""" self.validator.assert_valid( method_name='addAdmin', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account) def block_send(self, account: 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(account) 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}: add_admin") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_admin: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_admin. Reason: Unknown") def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict()) def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, account: 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, account: 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(account) 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}: add_admin") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_admin: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_admin. Reason: Unknown")
def build_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
def send_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str) ‑>
-
Validate the inputs to the addAdmin method.
Expand source code
def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the addAdmin method.""" self.validator.assert_valid( method_name='addAdmin', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account)
Inherited members
class AdminRoleMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the ADMIN_ROLE method.
Persist instance data.
Expand source code
class AdminRoleMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the ADMIN_ROLE 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("ADMIN_ROLE") def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned) def block_send(self, _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() 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}: admin_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, admin_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, admin_role. 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) ‑> Union[bytes, str]
-
Expand source code
def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned)
def block_send(self, _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, _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() 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}: admin_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, admin_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, admin_role. 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 AllowanceMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the allowance method.
Persist instance data.
Expand source code
class AllowanceMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the allowance 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("allowance") def validate_and_normalize_inputs(self, owner: str, spender: str) -> any: """Validate the inputs to the allowance method.""" self.validator.assert_valid( method_name='allowance', parameter_name='owner', argument_value=owner, ) owner = self.validate_and_checksum_address(owner) self.validator.assert_valid( method_name='allowance', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) return (owner, spender) def block_call(self, owner: str, spender: str, debug: bool = False) -> int: _fn = self._underlying_method(owner, spender) returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, owner: str, spender: 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(owner, spender) 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}: allowance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, allowance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, allowance. Reason: Unknown") def send_transaction(self, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (owner, spender) = self.validate_and_normalize_inputs(owner, spender) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender).transact(tx_params.as_dict()) def build_transaction(self, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (owner, spender) = self.validate_and_normalize_inputs(owner, spender) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender).buildTransaction(tx_params.as_dict()) def estimate_gas(self, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (owner, spender) = self.validate_and_normalize_inputs(owner, spender) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, owner: str, spender: str, debug: bool = False) ‑> int
-
Expand source code
def block_call(self, owner: str, spender: str, debug: bool = False) -> int: _fn = self._underlying_method(owner, spender) returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, owner: str, spender: 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, owner: str, spender: 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(owner, spender) 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}: allowance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, allowance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, allowance. Reason: Unknown")
def build_transaction(self, owner: str, spender: 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, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (owner, spender) = self.validate_and_normalize_inputs(owner, spender) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender).buildTransaction(tx_params.as_dict())
def estimate_gas(self, owner: str, spender: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (owner, spender) = self.validate_and_normalize_inputs(owner, spender) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender).estimateGas(tx_params.as_dict())
def send_transaction(self, owner: str, spender: 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, owner: str, spender: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (owner, spender) = self.validate_and_normalize_inputs(owner, spender) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, owner: str, spender: str) ‑>
-
Validate the inputs to the allowance method.
Expand source code
def validate_and_normalize_inputs(self, owner: str, spender: str) -> any: """Validate the inputs to the allowance method.""" self.validator.assert_valid( method_name='allowance', parameter_name='owner', argument_value=owner, ) owner = self.validate_and_checksum_address(owner) self.validator.assert_valid( method_name='allowance', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) return (owner, spender)
Inherited members
class ApproveMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the approve method.
Persist instance data.
Expand source code
class ApproveMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the approve 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("approve") def validate_and_normalize_inputs(self, spender: str, amount: int) -> any: """Validate the inputs to the approve method.""" self.validator.assert_valid( method_name='approve', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) self.validator.assert_valid( method_name='approve', parameter_name='amount', argument_value=amount, ) # safeguard against fractional inputs amount = int(amount) return (spender, amount) def block_send(self, spender: str, amount: int, _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(spender, 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}: approve") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, approve: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, approve. Reason: Unknown") def send_transaction(self, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (spender, amount) = self.validate_and_normalize_inputs(spender, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, amount).transact(tx_params.as_dict()) def build_transaction(self, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (spender, amount) = self.validate_and_normalize_inputs(spender, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, amount).buildTransaction(tx_params.as_dict()) def estimate_gas(self, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (spender, amount) = self.validate_and_normalize_inputs(spender, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, amount).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, spender: str, amount: int, _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, spender: str, amount: int, _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(spender, 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}: approve") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, approve: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, approve. Reason: Unknown")
def build_transaction(self, spender: 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, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (spender, amount) = self.validate_and_normalize_inputs(spender, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, amount).buildTransaction(tx_params.as_dict())
def estimate_gas(self, spender: str, amount: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (spender, amount) = self.validate_and_normalize_inputs(spender, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, amount).estimateGas(tx_params.as_dict())
def send_transaction(self, spender: 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, spender: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (spender, amount) = self.validate_and_normalize_inputs(spender, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, amount).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, spender: str, amount: int) ‑>
-
Validate the inputs to the approve method.
Expand source code
def validate_and_normalize_inputs(self, spender: str, amount: int) -> any: """Validate the inputs to the approve method.""" self.validator.assert_valid( method_name='approve', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) self.validator.assert_valid( method_name='approve', parameter_name='amount', argument_value=amount, ) # safeguard against fractional inputs amount = int(amount) return (spender, amount)
Inherited members
class BalanceOfMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the balanceOf method.
Persist instance data.
Expand source code
class BalanceOfMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the balanceOf 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("balanceOf") def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the balanceOf method.""" self.validator.assert_valid( method_name='balanceOf', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account) def block_call(self, account: str, debug: bool = False) -> int: _fn = self._underlying_method(account) returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, account: 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(account) 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}: balance_of") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, balance_of: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, balance_of. Reason: Unknown") def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict()) def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, account: str, debug: bool = False) ‑> int
-
Expand source code
def block_call(self, account: str, debug: bool = False) -> int: _fn = self._underlying_method(account) returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, account: 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, account: 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(account) 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}: balance_of") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, balance_of: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, balance_of. Reason: Unknown")
def build_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
def send_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str) ‑>
-
Validate the inputs to the balanceOf method.
Expand source code
def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the balanceOf method.""" self.validator.assert_valid( method_name='balanceOf', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account)
Inherited members
class BeriCoin (core_lib: MiliDoS, contract_address: str, validator: BeriCoinValidator = None)
-
Wrapper class for BeriCoin Solidity contract.
Get an instance of wrapper for smart contract.
Expand source code
class BeriCoin(ContractBase): """Wrapper class for BeriCoin Solidity contract.""" _fn_admin_role: AdminRoleMethod """Constructor-initialized instance of :class:`AdminRoleMethod`. """ _fn_default_admin_role: DefaultAdminRoleMethod """Constructor-initialized instance of :class:`DefaultAdminRoleMethod`. """ _fn_domain_typehash: DomainTypehashMethod """Constructor-initialized instance of :class:`DomainTypehashMethod`. """ _fn_permit_typehash: PermitTypehashMethod """Constructor-initialized instance of :class:`PermitTypehashMethod`. """ _fn_super_role: SuperRoleMethod """Constructor-initialized instance of :class:`SuperRoleMethod`. """ _fn_add_admin: AddAdminMethod """Constructor-initialized instance of :class:`AddAdminMethod`. """ _fn_allowance: AllowanceMethod """Constructor-initialized instance of :class:`AllowanceMethod`. """ _fn_approve: ApproveMethod """Constructor-initialized instance of :class:`ApproveMethod`. """ _fn_balance_of: BalanceOfMethod """Constructor-initialized instance of :class:`BalanceOfMethod`. """ _fn_candy_of: CandyOfMethod """Constructor-initialized instance of :class:`CandyOfMethod`. """ _fn_close: CloseMethod """Constructor-initialized instance of :class:`CloseMethod`. """ _fn_decimals: DecimalsMethod """Constructor-initialized instance of :class:`DecimalsMethod`. """ _fn_decrease_allowance: DecreaseAllowanceMethod """Constructor-initialized instance of :class:`DecreaseAllowanceMethod`. """ _fn_get_role_admin: GetRoleAdminMethod """Constructor-initialized instance of :class:`GetRoleAdminMethod`. """ _fn_get_role_member: GetRoleMemberMethod """Constructor-initialized instance of :class:`GetRoleMemberMethod`. """ _fn_get_role_member_count: GetRoleMemberCountMethod """Constructor-initialized instance of :class:`GetRoleMemberCountMethod`. """ _fn_grant_role: GrantRoleMethod """Constructor-initialized instance of :class:`GrantRoleMethod`. """ _fn_has_role: HasRoleMethod """Constructor-initialized instance of :class:`HasRoleMethod`. """ _fn_increase_allowance: IncreaseAllowanceMethod """Constructor-initialized instance of :class:`IncreaseAllowanceMethod`. """ _fn_is_admin: IsAdminMethod """Constructor-initialized instance of :class:`IsAdminMethod`. """ _fn_me: MeMethod """Constructor-initialized instance of :class:`MeMethod`. """ _fn_name: NameMethod """Constructor-initialized instance of :class:`NameMethod`. """ _fn_nonces: NoncesMethod """Constructor-initialized instance of :class:`NoncesMethod`. """ _fn_permit: PermitMethod """Constructor-initialized instance of :class:`PermitMethod`. """ _fn_renounce_admin: RenounceAdminMethod """Constructor-initialized instance of :class:`RenounceAdminMethod`. """ _fn_renounce_role: RenounceRoleMethod """Constructor-initialized instance of :class:`RenounceRoleMethod`. """ _fn_revoke_role: RevokeRoleMethod """Constructor-initialized instance of :class:`RevokeRoleMethod`. """ _fn_safe_burn: SafeBurnMethod """Constructor-initialized instance of :class:`SafeBurnMethod`. """ _fn_safe_mint: SafeMintMethod """Constructor-initialized instance of :class:`SafeMintMethod`. """ _fn_safe_refund: SafeRefundMethod """Constructor-initialized instance of :class:`SafeRefundMethod`. """ _fn_safe_transfer: SafeTransferMethod """Constructor-initialized instance of :class:`SafeTransferMethod`. """ _fn_send_candy: SendCandyMethod """Constructor-initialized instance of :class:`SendCandyMethod`. """ _fn_symbol: SymbolMethod """Constructor-initialized instance of :class:`SymbolMethod`. """ _fn_token_of: TokenOfMethod """Constructor-initialized instance of :class:`TokenOfMethod`. """ _fn_token_rate: TokenRateMethod """Constructor-initialized instance of :class:`TokenRateMethod`. """ _fn_total_supply: TotalSupplyMethod """Constructor-initialized instance of :class:`TotalSupplyMethod`. """ _fn_transfer: TransferMethod """Constructor-initialized instance of :class:`TransferMethod`. """ _fn_transfer_from: TransferFromMethod """Constructor-initialized instance of :class:`TransferFromMethod`. """ SIGNATURES: SignatureGenerator = None def __init__( self, core_lib: MiliDoS, contract_address: str, validator: BeriCoinValidator = 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 = BeriCoinValidator(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=BeriCoin.abi()).functions signed = SignatureGenerator(BeriCoin.abi()) validator.bindSignatures(signed) self.SIGNATURES = signed self._fn_admin_role = AdminRoleMethod(core_lib, contract_address, functions.ADMIN_ROLE, validator) self._fn_default_admin_role = DefaultAdminRoleMethod(core_lib, contract_address, functions.DEFAULT_ADMIN_ROLE, validator) self._fn_domain_typehash = DomainTypehashMethod(core_lib, contract_address, functions.DOMAIN_TYPEHASH, validator) self._fn_permit_typehash = PermitTypehashMethod(core_lib, contract_address, functions.PERMIT_TYPEHASH, validator) self._fn_super_role = SuperRoleMethod(core_lib, contract_address, functions.SUPER_ROLE, validator) self._fn_add_admin = AddAdminMethod(core_lib, contract_address, functions.addAdmin, validator) self._fn_allowance = AllowanceMethod(core_lib, contract_address, functions.allowance, validator) self._fn_approve = ApproveMethod(core_lib, contract_address, functions.approve, validator) self._fn_balance_of = BalanceOfMethod(core_lib, contract_address, functions.balanceOf, validator) self._fn_candy_of = CandyOfMethod(core_lib, contract_address, functions.candyOf, validator) self._fn_close = CloseMethod(core_lib, contract_address, functions.close, validator) self._fn_decimals = DecimalsMethod(core_lib, contract_address, functions.decimals, validator) self._fn_decrease_allowance = DecreaseAllowanceMethod(core_lib, contract_address, functions.decreaseAllowance, validator) self._fn_get_role_admin = GetRoleAdminMethod(core_lib, contract_address, functions.getRoleAdmin, validator) self._fn_get_role_member = GetRoleMemberMethod(core_lib, contract_address, functions.getRoleMember, validator) self._fn_get_role_member_count = GetRoleMemberCountMethod(core_lib, contract_address, functions.getRoleMemberCount, validator) self._fn_grant_role = GrantRoleMethod(core_lib, contract_address, functions.grantRole, validator) self._fn_has_role = HasRoleMethod(core_lib, contract_address, functions.hasRole, validator) self._fn_increase_allowance = IncreaseAllowanceMethod(core_lib, contract_address, functions.increaseAllowance, validator) self._fn_is_admin = IsAdminMethod(core_lib, contract_address, functions.isAdmin, validator) self._fn_me = MeMethod(core_lib, contract_address, functions.me, validator) self._fn_name = NameMethod(core_lib, contract_address, functions.name, validator) self._fn_nonces = NoncesMethod(core_lib, contract_address, functions.nonces, validator) self._fn_permit = PermitMethod(core_lib, contract_address, functions.permit, validator) self._fn_renounce_admin = RenounceAdminMethod(core_lib, contract_address, functions.renounceAdmin, validator) self._fn_renounce_role = RenounceRoleMethod(core_lib, contract_address, functions.renounceRole, validator) self._fn_revoke_role = RevokeRoleMethod(core_lib, contract_address, functions.revokeRole, validator) self._fn_safe_burn = SafeBurnMethod(core_lib, contract_address, functions.safeBurn, validator) self._fn_safe_mint = SafeMintMethod(core_lib, contract_address, functions.safeMint, validator) self._fn_safe_refund = SafeRefundMethod(core_lib, contract_address, functions.safeRefund, validator) self._fn_safe_transfer = SafeTransferMethod(core_lib, contract_address, functions.safeTransfer, validator) self._fn_send_candy = SendCandyMethod(core_lib, contract_address, functions.sendCandy, validator) self._fn_symbol = SymbolMethod(core_lib, contract_address, functions.symbol, validator) self._fn_token_of = TokenOfMethod(core_lib, contract_address, functions.tokenOf, validator) self._fn_token_rate = TokenRateMethod(core_lib, contract_address, functions.tokenRate, validator) self._fn_total_supply = TotalSupplyMethod(core_lib, contract_address, functions.totalSupply, validator) self._fn_transfer = TransferMethod(core_lib, contract_address, functions.transfer, validator) self._fn_transfer_from = TransferFromMethod(core_lib, contract_address, functions.transferFrom, validator) def event_admin_added( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event admin_added in contract BeriCoin Get log entry for AdminAdded event. :param tx_hash: hash of transaction emitting AdminAdded event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.AdminAdded().processReceipt(tx_receipt) def event_admin_removed( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event admin_removed in contract BeriCoin Get log entry for AdminRemoved event. :param tx_hash: hash of transaction emitting AdminRemoved event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.AdminRemoved().processReceipt(tx_receipt) def event_approval( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event approval in contract BeriCoin Get log entry for Approval event. :param tx_hash: hash of transaction emitting Approval event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Approval().processReceipt(tx_receipt) def event_burn_candy( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event burn_candy in contract BeriCoin Get log entry for BurnCandy event. :param tx_hash: hash of transaction emitting BurnCandy event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.BurnCandy().processReceipt(tx_receipt) def event_refund( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event refund in contract BeriCoin Get log entry for Refund event. :param tx_hash: hash of transaction emitting Refund event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Refund().processReceipt(tx_receipt) def event_role_granted( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event role_granted in contract BeriCoin Get log entry for RoleGranted event. :param tx_hash: hash of transaction emitting RoleGranted event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.RoleGranted().processReceipt(tx_receipt) def event_role_revoked( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event role_revoked in contract BeriCoin Get log entry for RoleRevoked event. :param tx_hash: hash of transaction emitting RoleRevoked event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.RoleRevoked().processReceipt(tx_receipt) def event_send_candy( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event send_candy in contract BeriCoin Get log entry for SendCandy event. :param tx_hash: hash of transaction emitting SendCandy event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.SendCandy().processReceipt(tx_receipt) def event_transfer( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event transfer in contract BeriCoin Get log entry for Transfer event. :param tx_hash: hash of transaction emitting Transfer event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Transfer().processReceipt(tx_receipt) def event_transfer_candy( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event transfer_candy in contract BeriCoin Get log entry for TransferCandy event. :param tx_hash: hash of transaction emitting TransferCandy event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.TransferCandy().processReceipt(tx_receipt) def admin_role(self) -> Union[bytes, str]: """ Implementation of admin_role in contract BeriCoin Method of the function """ return self._fn_admin_role.block_call() def default_admin_role(self) -> Union[bytes, str]: """ Implementation of default_admin_role in contract BeriCoin Method of the function """ return self._fn_default_admin_role.block_call() def domain_typehash(self) -> Union[bytes, str]: """ Implementation of domain_typehash in contract BeriCoin Method of the function """ return self._fn_domain_typehash.block_call() def permit_typehash(self) -> Union[bytes, str]: """ Implementation of permit_typehash in contract BeriCoin Method of the function """ return self._fn_permit_typehash.block_call() def super_role(self) -> Union[bytes, str]: """ Implementation of super_role in contract BeriCoin Method of the function """ return self._fn_super_role.block_call() def add_admin(self, account: str) -> None: """ Implementation of add_admin in contract BeriCoin Method of the function """ return self._fn_add_admin.block_send(account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def allowance(self, owner: str, spender: str) -> int: """ Implementation of allowance in contract BeriCoin Method of the function """ return self._fn_allowance.block_call(owner, spender) def approve(self, spender: str, amount: int) -> bool: """ Implementation of approve in contract BeriCoin Method of the function """ return self._fn_approve.block_send(spender, amount, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def balance_of(self, account: str) -> int: """ Implementation of balance_of in contract BeriCoin Method of the function """ return self._fn_balance_of.block_call(account) def candy_of(self, account: str) -> int: """ Implementation of candy_of in contract BeriCoin Method of the function """ return self._fn_candy_of.block_call(account) def close(self, wei: int = 0) -> None: """ Implementation of close in contract BeriCoin Method of the function """ return self._fn_close.block_send(self.call_contract_fee_amount, self.call_contract_fee_price, wei, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def decimals(self) -> int: """ Implementation of decimals in contract BeriCoin Method of the function """ return self._fn_decimals.block_call() def decrease_allowance(self, spender: str, subtracted_value: int) -> bool: """ Implementation of decrease_allowance in contract BeriCoin Method of the function """ return self._fn_decrease_allowance.block_send(spender, subtracted_value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def get_role_admin(self, role: Union[bytes, str]) -> Union[bytes, str]: """ Implementation of get_role_admin in contract BeriCoin Method of the function """ return self._fn_get_role_admin.block_call(role) def get_role_member(self, role: Union[bytes, str], index: int) -> str: """ Implementation of get_role_member in contract BeriCoin Method of the function """ return self._fn_get_role_member.block_call(role, index) def get_role_member_count(self, role: Union[bytes, str]) -> int: """ Implementation of get_role_member_count in contract BeriCoin Method of the function """ return self._fn_get_role_member_count.block_call(role) def grant_role(self, role: Union[bytes, str], account: str) -> None: """ Implementation of grant_role in contract BeriCoin Method of the function """ return self._fn_grant_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def has_role(self, role: Union[bytes, str], account: str) -> bool: """ Implementation of has_role in contract BeriCoin Method of the function """ return self._fn_has_role.block_call(role, account) def increase_allowance(self, spender: str, added_value: int) -> bool: """ Implementation of increase_allowance in contract BeriCoin Method of the function """ return self._fn_increase_allowance.block_send(spender, added_value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def is_admin(self, account: str) -> bool: """ Implementation of is_admin in contract BeriCoin Method of the function """ return self._fn_is_admin.block_call(account) def me(self) -> str: """ Implementation of me in contract BeriCoin Method of the function """ return self._fn_me.block_call() def name(self) -> str: """ Implementation of name in contract BeriCoin Method of the function """ return self._fn_name.block_call() def nonces(self, index_0: str) -> int: """ Implementation of nonces in contract BeriCoin Method of the function """ return self._fn_nonces.block_call(index_0) def permit(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str]) -> None: """ Implementation of permit in contract BeriCoin Method of the function """ return self._fn_permit.block_send(owner, spender, raw_amount, deadline, v, r, s, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def renounce_admin(self) -> None: """ Implementation of renounce_admin in contract BeriCoin Method of the function """ return self._fn_renounce_admin.block_send(self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def renounce_role(self, role: Union[bytes, str], account: str) -> None: """ Implementation of renounce_role in contract BeriCoin Method of the function """ return self._fn_renounce_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def revoke_role(self, role: Union[bytes, str], account: str) -> None: """ Implementation of revoke_role in contract BeriCoin Method of the function """ return self._fn_revoke_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def safe_burn(self, account: str, value: int) -> bool: """ Implementation of safe_burn in contract BeriCoin Method of the function """ return self._fn_safe_burn.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def safe_mint(self, account: str, value: int) -> bool: """ Implementation of safe_mint in contract BeriCoin Method of the function """ return self._fn_safe_mint.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def safe_refund(self, account: str, value: int) -> bool: """ Implementation of safe_refund in contract BeriCoin Method of the function """ return self._fn_safe_refund.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def safe_transfer(self, _from: str, to: str, value: int) -> bool: """ Implementation of safe_transfer in contract BeriCoin Method of the function """ return self._fn_safe_transfer.block_send(_from, to, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def send_candy(self, account: str, value: int) -> bool: """ Implementation of send_candy in contract BeriCoin Method of the function """ return self._fn_send_candy.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def symbol(self) -> str: """ Implementation of symbol in contract BeriCoin Method of the function """ return self._fn_symbol.block_call() def token_of(self, account: str) -> int: """ Implementation of token_of in contract BeriCoin Method of the function """ return self._fn_token_of.block_call(account) def token_rate(self) -> int: """ Implementation of token_rate in contract BeriCoin Method of the function """ return self._fn_token_rate.block_call() def total_supply(self) -> int: """ Implementation of total_supply in contract BeriCoin Method of the function """ return self._fn_total_supply.block_call() def transfer(self, recipient: str, amount: int) -> bool: """ Implementation of transfer in contract BeriCoin Method of the function """ return self._fn_transfer.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 transfer_from(self, sender: str, recipient: str, amount: int) -> bool: """ Implementation of transfer_from in contract BeriCoin Method of the function """ return self._fn_transfer_from.block_send(sender, 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 CallContractWait(self, t_long: int) -> "BeriCoin": self._fn_admin_role.setWait(t_long) self._fn_default_admin_role.setWait(t_long) self._fn_domain_typehash.setWait(t_long) self._fn_permit_typehash.setWait(t_long) self._fn_super_role.setWait(t_long) self._fn_add_admin.setWait(t_long) self._fn_allowance.setWait(t_long) self._fn_approve.setWait(t_long) self._fn_balance_of.setWait(t_long) self._fn_candy_of.setWait(t_long) self._fn_close.setWait(t_long) self._fn_decimals.setWait(t_long) self._fn_decrease_allowance.setWait(t_long) self._fn_get_role_admin.setWait(t_long) self._fn_get_role_member.setWait(t_long) self._fn_get_role_member_count.setWait(t_long) self._fn_grant_role.setWait(t_long) self._fn_has_role.setWait(t_long) self._fn_increase_allowance.setWait(t_long) self._fn_is_admin.setWait(t_long) self._fn_me.setWait(t_long) self._fn_name.setWait(t_long) self._fn_nonces.setWait(t_long) self._fn_permit.setWait(t_long) self._fn_renounce_admin.setWait(t_long) self._fn_renounce_role.setWait(t_long) self._fn_revoke_role.setWait(t_long) self._fn_safe_burn.setWait(t_long) self._fn_safe_mint.setWait(t_long) self._fn_safe_refund.setWait(t_long) self._fn_safe_transfer.setWait(t_long) self._fn_send_candy.setWait(t_long) self._fn_symbol.setWait(t_long) self._fn_token_of.setWait(t_long) self._fn_token_rate.setWait(t_long) self._fn_total_supply.setWait(t_long) self._fn_transfer.setWait(t_long) self._fn_transfer_from.setWait(t_long) return self @staticmethod def abi(): """Return the ABI to the underlying contract.""" return json.loads( '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"AdminAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"AdminRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BurnCandy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"SendCandy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferCandy","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SUPER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"candyOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"close","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"me","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"rawAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeBurn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeRefund","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeTransfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"sendCandy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"tokenOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"AdminAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"AdminRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BurnCandy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"SendCandy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferCandy","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SUPER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"candyOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"close","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"me","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"rawAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeBurn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeRefund","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"safeTransfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"sendCandy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"tokenOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]' # noqa: E501 (line-too-long) )
Methods
def CallContractWait(self, t_long: int) ‑> BeriCoin
-
Expand source code
def CallContractWait(self, t_long: int) -> "BeriCoin": self._fn_admin_role.setWait(t_long) self._fn_default_admin_role.setWait(t_long) self._fn_domain_typehash.setWait(t_long) self._fn_permit_typehash.setWait(t_long) self._fn_super_role.setWait(t_long) self._fn_add_admin.setWait(t_long) self._fn_allowance.setWait(t_long) self._fn_approve.setWait(t_long) self._fn_balance_of.setWait(t_long) self._fn_candy_of.setWait(t_long) self._fn_close.setWait(t_long) self._fn_decimals.setWait(t_long) self._fn_decrease_allowance.setWait(t_long) self._fn_get_role_admin.setWait(t_long) self._fn_get_role_member.setWait(t_long) self._fn_get_role_member_count.setWait(t_long) self._fn_grant_role.setWait(t_long) self._fn_has_role.setWait(t_long) self._fn_increase_allowance.setWait(t_long) self._fn_is_admin.setWait(t_long) self._fn_me.setWait(t_long) self._fn_name.setWait(t_long) self._fn_nonces.setWait(t_long) self._fn_permit.setWait(t_long) self._fn_renounce_admin.setWait(t_long) self._fn_renounce_role.setWait(t_long) self._fn_revoke_role.setWait(t_long) self._fn_safe_burn.setWait(t_long) self._fn_safe_mint.setWait(t_long) self._fn_safe_refund.setWait(t_long) self._fn_safe_transfer.setWait(t_long) self._fn_send_candy.setWait(t_long) self._fn_symbol.setWait(t_long) self._fn_token_of.setWait(t_long) self._fn_token_rate.setWait(t_long) self._fn_total_supply.setWait(t_long) self._fn_transfer.setWait(t_long) self._fn_transfer_from.setWait(t_long) return self
def add_admin(self, account: str) ‑> NoneType
-
Implementation of add_admin in contract BeriCoin Method of the function
Expand source code
def add_admin(self, account: str) -> None: """ Implementation of add_admin in contract BeriCoin Method of the function """ return self._fn_add_admin.block_send(account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def admin_role(self) ‑> Union[bytes, str]
-
Implementation of admin_role in contract BeriCoin Method of the function
Expand source code
def admin_role(self) -> Union[bytes, str]: """ Implementation of admin_role in contract BeriCoin Method of the function """ return self._fn_admin_role.block_call()
def allowance(self, owner: str, spender: str) ‑> int
-
Implementation of allowance in contract BeriCoin Method of the function
Expand source code
def allowance(self, owner: str, spender: str) -> int: """ Implementation of allowance in contract BeriCoin Method of the function """ return self._fn_allowance.block_call(owner, spender)
def approve(self, spender: str, amount: int) ‑> bool
-
Implementation of approve in contract BeriCoin Method of the function
Expand source code
def approve(self, spender: str, amount: int) -> bool: """ Implementation of approve in contract BeriCoin Method of the function """ return self._fn_approve.block_send(spender, amount, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def balance_of(self, account: str) ‑> int
-
Implementation of balance_of in contract BeriCoin Method of the function
Expand source code
def balance_of(self, account: str) -> int: """ Implementation of balance_of in contract BeriCoin Method of the function """ return self._fn_balance_of.block_call(account)
def candy_of(self, account: str) ‑> int
-
Implementation of candy_of in contract BeriCoin Method of the function
Expand source code
def candy_of(self, account: str) -> int: """ Implementation of candy_of in contract BeriCoin Method of the function """ return self._fn_candy_of.block_call(account)
def close(self, wei: int = 0) ‑> NoneType
-
Implementation of close in contract BeriCoin Method of the function
Expand source code
def close(self, wei: int = 0) -> None: """ Implementation of close in contract BeriCoin Method of the function """ return self._fn_close.block_send(self.call_contract_fee_amount, self.call_contract_fee_price, wei, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def decimals(self) ‑> int
-
Implementation of decimals in contract BeriCoin Method of the function
Expand source code
def decimals(self) -> int: """ Implementation of decimals in contract BeriCoin Method of the function """ return self._fn_decimals.block_call()
def decrease_allowance(self, spender: str, subtracted_value: int) ‑> bool
-
Implementation of decrease_allowance in contract BeriCoin Method of the function
Expand source code
def decrease_allowance(self, spender: str, subtracted_value: int) -> bool: """ Implementation of decrease_allowance in contract BeriCoin Method of the function """ return self._fn_decrease_allowance.block_send(spender, subtracted_value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def default_admin_role(self) ‑> Union[bytes, str]
-
Implementation of default_admin_role in contract BeriCoin Method of the function
Expand source code
def default_admin_role(self) -> Union[bytes, str]: """ Implementation of default_admin_role in contract BeriCoin Method of the function """ return self._fn_default_admin_role.block_call()
def domain_typehash(self) ‑> Union[bytes, str]
-
Implementation of domain_typehash in contract BeriCoin Method of the function
Expand source code
def domain_typehash(self) -> Union[bytes, str]: """ Implementation of domain_typehash in contract BeriCoin Method of the function """ return self._fn_domain_typehash.block_call()
def event_admin_added(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event admin_added in contract BeriCoin Get log entry for AdminAdded event. :param tx_hash: hash of transaction emitting AdminAdded event
Expand source code
def event_admin_added( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event admin_added in contract BeriCoin Get log entry for AdminAdded event. :param tx_hash: hash of transaction emitting AdminAdded event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.AdminAdded().processReceipt(tx_receipt)
def event_admin_removed(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event admin_removed in contract BeriCoin Get log entry for AdminRemoved event. :param tx_hash: hash of transaction emitting AdminRemoved event
Expand source code
def event_admin_removed( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event admin_removed in contract BeriCoin Get log entry for AdminRemoved event. :param tx_hash: hash of transaction emitting AdminRemoved event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.AdminRemoved().processReceipt(tx_receipt)
def event_approval(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event approval in contract BeriCoin Get log entry for Approval event. :param tx_hash: hash of transaction emitting Approval event
Expand source code
def event_approval( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event approval in contract BeriCoin Get log entry for Approval event. :param tx_hash: hash of transaction emitting Approval event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Approval().processReceipt(tx_receipt)
def event_burn_candy(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event burn_candy in contract BeriCoin Get log entry for BurnCandy event. :param tx_hash: hash of transaction emitting BurnCandy event
Expand source code
def event_burn_candy( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event burn_candy in contract BeriCoin Get log entry for BurnCandy event. :param tx_hash: hash of transaction emitting BurnCandy event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.BurnCandy().processReceipt(tx_receipt)
def event_refund(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event refund in contract BeriCoin Get log entry for Refund event. :param tx_hash: hash of transaction emitting Refund event
Expand source code
def event_refund( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event refund in contract BeriCoin Get log entry for Refund event. :param tx_hash: hash of transaction emitting Refund event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Refund().processReceipt(tx_receipt)
def event_role_granted(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event role_granted in contract BeriCoin Get log entry for RoleGranted event. :param tx_hash: hash of transaction emitting RoleGranted event
Expand source code
def event_role_granted( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event role_granted in contract BeriCoin Get log entry for RoleGranted event. :param tx_hash: hash of transaction emitting RoleGranted event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.RoleGranted().processReceipt(tx_receipt)
def event_role_revoked(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event role_revoked in contract BeriCoin Get log entry for RoleRevoked event. :param tx_hash: hash of transaction emitting RoleRevoked event
Expand source code
def event_role_revoked( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event role_revoked in contract BeriCoin Get log entry for RoleRevoked event. :param tx_hash: hash of transaction emitting RoleRevoked event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.RoleRevoked().processReceipt(tx_receipt)
def event_send_candy(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event send_candy in contract BeriCoin Get log entry for SendCandy event. :param tx_hash: hash of transaction emitting SendCandy event
Expand source code
def event_send_candy( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event send_candy in contract BeriCoin Get log entry for SendCandy event. :param tx_hash: hash of transaction emitting SendCandy event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.SendCandy().processReceipt(tx_receipt)
def event_transfer(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event transfer in contract BeriCoin Get log entry for Transfer event. :param tx_hash: hash of transaction emitting Transfer event
Expand source code
def event_transfer( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event transfer in contract BeriCoin Get log entry for Transfer event. :param tx_hash: hash of transaction emitting Transfer event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.Transfer().processReceipt(tx_receipt)
def event_transfer_candy(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event transfer_candy in contract BeriCoin Get log entry for TransferCandy event. :param tx_hash: hash of transaction emitting TransferCandy event
Expand source code
def event_transfer_candy( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event transfer_candy in contract BeriCoin Get log entry for TransferCandy event. :param tx_hash: hash of transaction emitting TransferCandy event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=BeriCoin.abi()).events.TransferCandy().processReceipt(tx_receipt)
def get_role_admin(self, role: Union[bytes, str]) ‑> Union[bytes, str]
-
Implementation of get_role_admin in contract BeriCoin Method of the function
Expand source code
def get_role_admin(self, role: Union[bytes, str]) -> Union[bytes, str]: """ Implementation of get_role_admin in contract BeriCoin Method of the function """ return self._fn_get_role_admin.block_call(role)
def get_role_member(self, role: Union[bytes, str], index: int) ‑> str
-
Implementation of get_role_member in contract BeriCoin Method of the function
Expand source code
def get_role_member(self, role: Union[bytes, str], index: int) -> str: """ Implementation of get_role_member in contract BeriCoin Method of the function """ return self._fn_get_role_member.block_call(role, index)
def get_role_member_count(self, role: Union[bytes, str]) ‑> int
-
Implementation of get_role_member_count in contract BeriCoin Method of the function
Expand source code
def get_role_member_count(self, role: Union[bytes, str]) -> int: """ Implementation of get_role_member_count in contract BeriCoin Method of the function """ return self._fn_get_role_member_count.block_call(role)
def grant_role(self, role: Union[bytes, str], account: str) ‑> NoneType
-
Implementation of grant_role in contract BeriCoin Method of the function
Expand source code
def grant_role(self, role: Union[bytes, str], account: str) -> None: """ Implementation of grant_role in contract BeriCoin Method of the function """ return self._fn_grant_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def has_role(self, role: Union[bytes, str], account: str) ‑> bool
-
Implementation of has_role in contract BeriCoin Method of the function
Expand source code
def has_role(self, role: Union[bytes, str], account: str) -> bool: """ Implementation of has_role in contract BeriCoin Method of the function """ return self._fn_has_role.block_call(role, account)
def increase_allowance(self, spender: str, added_value: int) ‑> bool
-
Implementation of increase_allowance in contract BeriCoin Method of the function
Expand source code
def increase_allowance(self, spender: str, added_value: int) -> bool: """ Implementation of increase_allowance in contract BeriCoin Method of the function """ return self._fn_increase_allowance.block_send(spender, added_value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def is_admin(self, account: str) ‑> bool
-
Implementation of is_admin in contract BeriCoin Method of the function
Expand source code
def is_admin(self, account: str) -> bool: """ Implementation of is_admin in contract BeriCoin Method of the function """ return self._fn_is_admin.block_call(account)
def me(self) ‑> str
-
Implementation of me in contract BeriCoin Method of the function
Expand source code
def me(self) -> str: """ Implementation of me in contract BeriCoin Method of the function """ return self._fn_me.block_call()
def name(self) ‑> str
-
Implementation of name in contract BeriCoin Method of the function
Expand source code
def name(self) -> str: """ Implementation of name in contract BeriCoin Method of the function """ return self._fn_name.block_call()
def nonces(self, index_0: str) ‑> int
-
Implementation of nonces in contract BeriCoin Method of the function
Expand source code
def nonces(self, index_0: str) -> int: """ Implementation of nonces in contract BeriCoin Method of the function """ return self._fn_nonces.block_call(index_0)
def permit(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str]) ‑> NoneType
-
Implementation of permit in contract BeriCoin Method of the function
Expand source code
def permit(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str]) -> None: """ Implementation of permit in contract BeriCoin Method of the function """ return self._fn_permit.block_send(owner, spender, raw_amount, deadline, v, r, s, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def permit_typehash(self) ‑> Union[bytes, str]
-
Implementation of permit_typehash in contract BeriCoin Method of the function
Expand source code
def permit_typehash(self) -> Union[bytes, str]: """ Implementation of permit_typehash in contract BeriCoin Method of the function """ return self._fn_permit_typehash.block_call()
def renounce_admin(self) ‑> NoneType
-
Implementation of renounce_admin in contract BeriCoin Method of the function
Expand source code
def renounce_admin(self) -> None: """ Implementation of renounce_admin in contract BeriCoin Method of the function """ return self._fn_renounce_admin.block_send(self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def renounce_role(self, role: Union[bytes, str], account: str) ‑> NoneType
-
Implementation of renounce_role in contract BeriCoin Method of the function
Expand source code
def renounce_role(self, role: Union[bytes, str], account: str) -> None: """ Implementation of renounce_role in contract BeriCoin Method of the function """ return self._fn_renounce_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def revoke_role(self, role: Union[bytes, str], account: str) ‑> NoneType
-
Implementation of revoke_role in contract BeriCoin Method of the function
Expand source code
def revoke_role(self, role: Union[bytes, str], account: str) -> None: """ Implementation of revoke_role in contract BeriCoin Method of the function """ return self._fn_revoke_role.block_send(role, account, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def safe_burn(self, account: str, value: int) ‑> bool
-
Implementation of safe_burn in contract BeriCoin Method of the function
Expand source code
def safe_burn(self, account: str, value: int) -> bool: """ Implementation of safe_burn in contract BeriCoin Method of the function """ return self._fn_safe_burn.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def safe_mint(self, account: str, value: int) ‑> bool
-
Implementation of safe_mint in contract BeriCoin Method of the function
Expand source code
def safe_mint(self, account: str, value: int) -> bool: """ Implementation of safe_mint in contract BeriCoin Method of the function """ return self._fn_safe_mint.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def safe_refund(self, account: str, value: int) ‑> bool
-
Implementation of safe_refund in contract BeriCoin Method of the function
Expand source code
def safe_refund(self, account: str, value: int) -> bool: """ Implementation of safe_refund in contract BeriCoin Method of the function """ return self._fn_safe_refund.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def safe_transfer(self, _from: str, to: str, value: int) ‑> bool
-
Implementation of safe_transfer in contract BeriCoin Method of the function
Expand source code
def safe_transfer(self, _from: str, to: str, value: int) -> bool: """ Implementation of safe_transfer in contract BeriCoin Method of the function """ return self._fn_safe_transfer.block_send(_from, to, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def send_candy(self, account: str, value: int) ‑> bool
-
Implementation of send_candy in contract BeriCoin Method of the function
Expand source code
def send_candy(self, account: str, value: int) -> bool: """ Implementation of send_candy in contract BeriCoin Method of the function """ return self._fn_send_candy.block_send(account, value, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def super_role(self) ‑> Union[bytes, str]
-
Implementation of super_role in contract BeriCoin Method of the function
Expand source code
def super_role(self) -> Union[bytes, str]: """ Implementation of super_role in contract BeriCoin Method of the function """ return self._fn_super_role.block_call()
def symbol(self) ‑> str
-
Implementation of symbol in contract BeriCoin Method of the function
Expand source code
def symbol(self) -> str: """ Implementation of symbol in contract BeriCoin Method of the function """ return self._fn_symbol.block_call()
def token_of(self, account: str) ‑> int
-
Implementation of token_of in contract BeriCoin Method of the function
Expand source code
def token_of(self, account: str) -> int: """ Implementation of token_of in contract BeriCoin Method of the function """ return self._fn_token_of.block_call(account)
def token_rate(self) ‑> int
-
Implementation of token_rate in contract BeriCoin Method of the function
Expand source code
def token_rate(self) -> int: """ Implementation of token_rate in contract BeriCoin Method of the function """ return self._fn_token_rate.block_call()
def total_supply(self) ‑> int
-
Implementation of total_supply in contract BeriCoin Method of the function
Expand source code
def total_supply(self) -> int: """ Implementation of total_supply in contract BeriCoin Method of the function """ return self._fn_total_supply.block_call()
def transfer(self, recipient: str, amount: int) ‑> bool
-
Implementation of transfer in contract BeriCoin Method of the function
Expand source code
def transfer(self, recipient: str, amount: int) -> bool: """ Implementation of transfer in contract BeriCoin Method of the function """ return self._fn_transfer.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 transfer_from(self, sender: str, recipient: str, amount: int) ‑> bool
-
Implementation of transfer_from in contract BeriCoin Method of the function
Expand source code
def transfer_from(self, sender: str, recipient: str, amount: int) -> bool: """ Implementation of transfer_from in contract BeriCoin Method of the function """ return self._fn_transfer_from.block_send(sender, recipient, amount, self.call_contract_fee_amount, self.call_contract_fee_price, 0, self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
class BeriCoinValidator (web3_or_provider: web3.main.Web3, contract_address: str)
-
No-op input validator.
Initialize the instance.
Expand source code
class BeriCoinValidator( # type: ignore Validator ): """No-op input validator."""
Ancestors
Inherited members
class CandyOfMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the candyOf method.
Persist instance data.
Expand source code
class CandyOfMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the candyOf 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("candyOf") def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the candyOf method.""" self.validator.assert_valid( method_name='candyOf', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account) def block_call(self, account: str, debug: bool = False) -> int: _fn = self._underlying_method(account) returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, account: 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(account) 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}: candy_of") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, candy_of: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, candy_of. Reason: Unknown") def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict()) def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, account: str, debug: bool = False) ‑> int
-
Expand source code
def block_call(self, account: str, debug: bool = False) -> int: _fn = self._underlying_method(account) returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, account: 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, account: 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(account) 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}: candy_of") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, candy_of: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, candy_of. Reason: Unknown")
def build_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
def send_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str) ‑>
-
Validate the inputs to the candyOf method.
Expand source code
def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the candyOf method.""" self.validator.assert_valid( method_name='candyOf', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account)
Inherited members
class CloseMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the close method.
Persist instance data.
Expand source code
class CloseMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the close 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("close") def block_send(self, _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() 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}: close") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, close: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, close. 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_send(self, _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, _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() 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}: close") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, close: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, close. 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 DecimalsMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the decimals method.
Persist instance data.
Expand source code
class DecimalsMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the decimals 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("decimals") 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}: decimals") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decimals: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decimals. 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}: decimals") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decimals: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decimals. 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 DecreaseAllowanceMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the decreaseAllowance method.
Persist instance data.
Expand source code
class DecreaseAllowanceMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the decreaseAllowance 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("decreaseAllowance") def validate_and_normalize_inputs(self, spender: str, subtracted_value: int) -> any: """Validate the inputs to the decreaseAllowance method.""" self.validator.assert_valid( method_name='decreaseAllowance', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) self.validator.assert_valid( method_name='decreaseAllowance', parameter_name='subtractedValue', argument_value=subtracted_value, ) # safeguard against fractional inputs subtracted_value = int(subtracted_value) return (spender, subtracted_value) def block_send(self, spender: str, subtracted_value: int, _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(spender, subtracted_value) 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}: decrease_allowance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decrease_allowance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decrease_allowance. Reason: Unknown") def send_transaction(self, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, subtracted_value).transact(tx_params.as_dict()) def build_transaction(self, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, subtracted_value).buildTransaction(tx_params.as_dict()) def estimate_gas(self, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, subtracted_value).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, spender: str, subtracted_value: int, _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, spender: str, subtracted_value: int, _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(spender, subtracted_value) 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}: decrease_allowance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decrease_allowance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, decrease_allowance. Reason: Unknown")
def build_transaction(self, spender: str, subtracted_value: 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, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, subtracted_value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, spender: str, subtracted_value: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, subtracted_value).estimateGas(tx_params.as_dict())
def send_transaction(self, spender: str, subtracted_value: 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, spender: str, subtracted_value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (spender, subtracted_value) = self.validate_and_normalize_inputs(spender, subtracted_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, subtracted_value).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, spender: str, subtracted_value: int) ‑>
-
Validate the inputs to the decreaseAllowance method.
Expand source code
def validate_and_normalize_inputs(self, spender: str, subtracted_value: int) -> any: """Validate the inputs to the decreaseAllowance method.""" self.validator.assert_valid( method_name='decreaseAllowance', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) self.validator.assert_valid( method_name='decreaseAllowance', parameter_name='subtractedValue', argument_value=subtracted_value, ) # safeguard against fractional inputs subtracted_value = int(subtracted_value) return (spender, subtracted_value)
Inherited members
class DefaultAdminRoleMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the DEFAULT_ADMIN_ROLE method.
Persist instance data.
Expand source code
class DefaultAdminRoleMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the DEFAULT_ADMIN_ROLE 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("DEFAULT_ADMIN_ROLE") def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned) def block_send(self, _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() 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}: default_admin_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, default_admin_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, default_admin_role. 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) ‑> Union[bytes, str]
-
Expand source code
def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned)
def block_send(self, _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, _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() 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}: default_admin_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, default_admin_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, default_admin_role. 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 DomainTypehashMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the DOMAIN_TYPEHASH method.
Persist instance data.
Expand source code
class DomainTypehashMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the DOMAIN_TYPEHASH 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("DOMAIN_TYPEHASH") def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned) def block_send(self, _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() 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}: domain_typehash") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, domain_typehash: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, domain_typehash. 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) ‑> Union[bytes, str]
-
Expand source code
def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned)
def block_send(self, _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, _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() 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}: domain_typehash") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, domain_typehash: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, domain_typehash. 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 GetRoleAdminMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the getRoleAdmin method.
Persist instance data.
Expand source code
class GetRoleAdminMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the getRoleAdmin 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("getRoleAdmin") def validate_and_normalize_inputs(self, role: Union[bytes, str]) -> any: """Validate the inputs to the getRoleAdmin method.""" self.validator.assert_valid( method_name='getRoleAdmin', parameter_name='role', argument_value=role, ) return (role) def block_call(self, role: Union[bytes, str], debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method(role) returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned) def block_send(self, role: Union[bytes, str], _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(role) 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}: get_role_admin") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_admin: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_admin. Reason: Unknown") def send_transaction(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).transact(tx_params.as_dict()) def build_transaction(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).buildTransaction(tx_params.as_dict()) def estimate_gas(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, role: Union[bytes, str], debug: bool = False) ‑> Union[bytes, str]
-
Expand source code
def block_call(self, role: Union[bytes, str], debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method(role) returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned)
def block_send(self, role: Union[bytes, str], _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, role: Union[bytes, str], _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(role) 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}: get_role_admin") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_admin: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_admin. Reason: Unknown")
def build_transaction(self, role: 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, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).estimateGas(tx_params.as_dict())
def send_transaction(self, role: 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, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, role: Union[bytes, str]) ‑>
-
Validate the inputs to the getRoleAdmin method.
Expand source code
def validate_and_normalize_inputs(self, role: Union[bytes, str]) -> any: """Validate the inputs to the getRoleAdmin method.""" self.validator.assert_valid( method_name='getRoleAdmin', parameter_name='role', argument_value=role, ) return (role)
Inherited members
class GetRoleMemberCountMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the getRoleMemberCount method.
Persist instance data.
Expand source code
class GetRoleMemberCountMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the getRoleMemberCount 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("getRoleMemberCount") def validate_and_normalize_inputs(self, role: Union[bytes, str]) -> any: """Validate the inputs to the getRoleMemberCount method.""" self.validator.assert_valid( method_name='getRoleMemberCount', parameter_name='role', argument_value=role, ) return (role) def block_call(self, role: Union[bytes, str], debug: bool = False) -> int: _fn = self._underlying_method(role) returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, role: Union[bytes, 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(role) 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}: get_role_member_count") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member_count: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member_count. Reason: Unknown") def send_transaction(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).transact(tx_params.as_dict()) def build_transaction(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).buildTransaction(tx_params.as_dict()) def estimate_gas(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, role: Union[bytes, str], debug: bool = False) ‑> int
-
Expand source code
def block_call(self, role: Union[bytes, str], debug: bool = False) -> int: _fn = self._underlying_method(role) returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, role: Union[bytes, 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, role: Union[bytes, 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(role) 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}: get_role_member_count") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member_count: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member_count. Reason: Unknown")
def build_transaction(self, role: 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, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).estimateGas(tx_params.as_dict())
def send_transaction(self, role: 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, role: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role) = self.validate_and_normalize_inputs(role) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, role: Union[bytes, str]) ‑>
-
Validate the inputs to the getRoleMemberCount method.
Expand source code
def validate_and_normalize_inputs(self, role: Union[bytes, str]) -> any: """Validate the inputs to the getRoleMemberCount method.""" self.validator.assert_valid( method_name='getRoleMemberCount', parameter_name='role', argument_value=role, ) return (role)
Inherited members
class GetRoleMemberMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the getRoleMember method.
Persist instance data.
Expand source code
class GetRoleMemberMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the getRoleMember 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("getRoleMember") def validate_and_normalize_inputs(self, role: Union[bytes, str], index: int) -> any: """Validate the inputs to the getRoleMember method.""" self.validator.assert_valid( method_name='getRoleMember', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='getRoleMember', parameter_name='index', argument_value=index, ) # safeguard against fractional inputs index = int(index) return (role, index) def block_call(self, role: Union[bytes, str], index: int, debug: bool = False) -> str: _fn = self._underlying_method(role, index) returned = _fn.call({ 'from': self._operate }) return str(returned) def block_send(self, role: Union[bytes, str], index: int, _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(role, index) 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}: get_role_member") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member. Reason: Unknown") def send_transaction(self, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, index) = self.validate_and_normalize_inputs(role, index) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, index).transact(tx_params.as_dict()) def build_transaction(self, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, index) = self.validate_and_normalize_inputs(role, index) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, index).buildTransaction(tx_params.as_dict()) def estimate_gas(self, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, index) = self.validate_and_normalize_inputs(role, index) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, index).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, role: Union[bytes, str], index: int, debug: bool = False) ‑> str
-
Expand source code
def block_call(self, role: Union[bytes, str], index: int, debug: bool = False) -> str: _fn = self._underlying_method(role, index) returned = _fn.call({ 'from': self._operate }) return str(returned)
def block_send(self, role: Union[bytes, str], index: int, _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, role: Union[bytes, str], index: int, _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(role, index) 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}: get_role_member") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_role_member. Reason: Unknown")
def build_transaction(self, role: Union[bytes, str], index: 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, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, index) = self.validate_and_normalize_inputs(role, index) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, index).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], index: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, index) = self.validate_and_normalize_inputs(role, index) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, index).estimateGas(tx_params.as_dict())
def send_transaction(self, role: Union[bytes, str], index: 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, role: Union[bytes, str], index: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, index) = self.validate_and_normalize_inputs(role, index) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, index).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, role: Union[bytes, str], index: int) ‑>
-
Validate the inputs to the getRoleMember method.
Expand source code
def validate_and_normalize_inputs(self, role: Union[bytes, str], index: int) -> any: """Validate the inputs to the getRoleMember method.""" self.validator.assert_valid( method_name='getRoleMember', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='getRoleMember', parameter_name='index', argument_value=index, ) # safeguard against fractional inputs index = int(index) return (role, index)
Inherited members
class GrantRoleMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the grantRole method.
Persist instance data.
Expand source code
class GrantRoleMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the grantRole 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("grantRole") def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any: """Validate the inputs to the grantRole method.""" self.validator.assert_valid( method_name='grantRole', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='grantRole', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (role, account) def block_send(self, role: Union[bytes, str], account: 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(role, account) 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}: grant_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, grant_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, grant_role. Reason: Unknown") def send_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).transact(tx_params.as_dict()) def build_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: 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(role, account) 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}: grant_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, grant_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, grant_role. Reason: Unknown")
def build_transaction(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
def send_transaction(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) ‑>
-
Validate the inputs to the grantRole method.
Expand source code
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any: """Validate the inputs to the grantRole method.""" self.validator.assert_valid( method_name='grantRole', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='grantRole', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (role, account)
Inherited members
class HasRoleMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the hasRole method.
Persist instance data.
Expand source code
class HasRoleMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the hasRole 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("hasRole") def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any: """Validate the inputs to the hasRole method.""" self.validator.assert_valid( method_name='hasRole', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='hasRole', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (role, account) def block_call(self, role: Union[bytes, str], account: str, debug: bool = False) -> bool: _fn = self._underlying_method(role, account) returned = _fn.call({ 'from': self._operate }) return bool(returned) def block_send(self, role: Union[bytes, str], account: str, _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(role, account) 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}: has_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, has_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, has_role. Reason: Unknown") def send_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).transact(tx_params.as_dict()) def build_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, role: Union[bytes, str], account: str, debug: bool = False) ‑> bool
-
Expand source code
def block_call(self, role: Union[bytes, str], account: str, debug: bool = False) -> bool: _fn = self._underlying_method(role, account) returned = _fn.call({ 'from': self._operate }) return bool(returned)
def block_send(self, role: Union[bytes, str], account: str, _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, role: Union[bytes, str], account: str, _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(role, account) 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}: has_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, has_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, has_role. Reason: Unknown")
def build_transaction(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
def send_transaction(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) ‑>
-
Validate the inputs to the hasRole method.
Expand source code
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any: """Validate the inputs to the hasRole method.""" self.validator.assert_valid( method_name='hasRole', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='hasRole', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (role, account)
Inherited members
class IncreaseAllowanceMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the increaseAllowance method.
Persist instance data.
Expand source code
class IncreaseAllowanceMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the increaseAllowance 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("increaseAllowance") def validate_and_normalize_inputs(self, spender: str, added_value: int) -> any: """Validate the inputs to the increaseAllowance method.""" self.validator.assert_valid( method_name='increaseAllowance', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) self.validator.assert_valid( method_name='increaseAllowance', parameter_name='addedValue', argument_value=added_value, ) # safeguard against fractional inputs added_value = int(added_value) return (spender, added_value) def block_send(self, spender: str, added_value: int, _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(spender, added_value) 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}: increase_allowance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, increase_allowance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, increase_allowance. Reason: Unknown") def send_transaction(self, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (spender, added_value) = self.validate_and_normalize_inputs(spender, added_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, added_value).transact(tx_params.as_dict()) def build_transaction(self, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (spender, added_value) = self.validate_and_normalize_inputs(spender, added_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, added_value).buildTransaction(tx_params.as_dict()) def estimate_gas(self, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (spender, added_value) = self.validate_and_normalize_inputs(spender, added_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, added_value).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, spender: str, added_value: int, _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, spender: str, added_value: int, _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(spender, added_value) 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}: increase_allowance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, increase_allowance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, increase_allowance. Reason: Unknown")
def build_transaction(self, spender: str, added_value: 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, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (spender, added_value) = self.validate_and_normalize_inputs(spender, added_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, added_value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, spender: str, added_value: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (spender, added_value) = self.validate_and_normalize_inputs(spender, added_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, added_value).estimateGas(tx_params.as_dict())
def send_transaction(self, spender: str, added_value: 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, spender: str, added_value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (spender, added_value) = self.validate_and_normalize_inputs(spender, added_value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(spender, added_value).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, spender: str, added_value: int) ‑>
-
Validate the inputs to the increaseAllowance method.
Expand source code
def validate_and_normalize_inputs(self, spender: str, added_value: int) -> any: """Validate the inputs to the increaseAllowance method.""" self.validator.assert_valid( method_name='increaseAllowance', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) self.validator.assert_valid( method_name='increaseAllowance', parameter_name='addedValue', argument_value=added_value, ) # safeguard against fractional inputs added_value = int(added_value) return (spender, added_value)
Inherited members
class IsAdminMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the isAdmin method.
Persist instance data.
Expand source code
class IsAdminMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the isAdmin 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("isAdmin") def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the isAdmin method.""" self.validator.assert_valid( method_name='isAdmin', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account) def block_call(self, account: str, debug: bool = False) -> bool: _fn = self._underlying_method(account) returned = _fn.call({ 'from': self._operate }) return bool(returned) def block_send(self, account: str, _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(account) 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_admin") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_admin: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_admin. Reason: Unknown") def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict()) def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, account: str, debug: bool = False) ‑> bool
-
Expand source code
def block_call(self, account: str, debug: bool = False) -> bool: _fn = self._underlying_method(account) returned = _fn.call({ 'from': self._operate }) return bool(returned)
def block_send(self, account: str, _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, account: str, _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(account) 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_admin") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_admin: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_admin. Reason: Unknown")
def build_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
def send_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str) ‑>
-
Validate the inputs to the isAdmin method.
Expand source code
def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the isAdmin method.""" self.validator.assert_valid( method_name='isAdmin', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account)
Inherited members
class MeMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the me method.
Persist instance data.
Expand source code
class MeMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the me 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("me") 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}: me") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, me: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, me. 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}: me") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, me: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, me. 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 NameMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the name method.
Persist instance data.
Expand source code
class NameMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the name 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("name") 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}: name") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, name: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, name. 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}: name") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, name: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, name. 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 NoncesMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the nonces method.
Persist instance data.
Expand source code
class NoncesMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the nonces 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("nonces") def validate_and_normalize_inputs(self, index_0: str) -> any: """Validate the inputs to the nonces method.""" self.validator.assert_valid( method_name='nonces', 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}: nonces") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, nonces: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, nonces. 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}: nonces") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, nonces: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, nonces. 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 nonces method.
Expand source code
def validate_and_normalize_inputs(self, index_0: str) -> any: """Validate the inputs to the nonces method.""" self.validator.assert_valid( method_name='nonces', parameter_name='index_0', argument_value=index_0, ) index_0 = self.validate_and_checksum_address(index_0) return (index_0)
Inherited members
class PermitMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the permit method.
Persist instance data.
Expand source code
class PermitMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the permit 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("permit") def validate_and_normalize_inputs(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str]) -> any: """Validate the inputs to the permit method.""" self.validator.assert_valid( method_name='permit', parameter_name='owner', argument_value=owner, ) owner = self.validate_and_checksum_address(owner) self.validator.assert_valid( method_name='permit', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) self.validator.assert_valid( method_name='permit', parameter_name='rawAmount', argument_value=raw_amount, ) # safeguard against fractional inputs raw_amount = int(raw_amount) self.validator.assert_valid( method_name='permit', parameter_name='deadline', argument_value=deadline, ) # safeguard against fractional inputs deadline = int(deadline) self.validator.assert_valid( method_name='permit', parameter_name='v', argument_value=v, ) self.validator.assert_valid( method_name='permit', parameter_name='r', argument_value=r, ) self.validator.assert_valid( method_name='permit', parameter_name='s', argument_value=s, ) return (owner, spender, raw_amount, deadline, v, r, s) def block_send(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: 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(owner, spender, raw_amount, deadline, v, r, s) 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}: permit") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit. Reason: Unknown") def send_transaction(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).transact(tx_params.as_dict()) def build_transaction(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).buildTransaction(tx_params.as_dict()) def estimate_gas(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: 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, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: 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(owner, spender, raw_amount, deadline, v, r, s) 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}: permit") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit. Reason: Unknown")
def build_transaction(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: 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, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).buildTransaction(tx_params.as_dict())
def estimate_gas(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).estimateGas(tx_params.as_dict())
def send_transaction(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: 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, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (owner, spender, raw_amount, deadline, v, r, s) = self.validate_and_normalize_inputs(owner, spender, raw_amount, deadline, v, r, s) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(owner, spender, raw_amount, deadline, v, r, s).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str]) ‑>
-
Validate the inputs to the permit method.
Expand source code
def validate_and_normalize_inputs(self, owner: str, spender: str, raw_amount: int, deadline: int, v: int, r: Union[bytes, str], s: Union[bytes, str]) -> any: """Validate the inputs to the permit method.""" self.validator.assert_valid( method_name='permit', parameter_name='owner', argument_value=owner, ) owner = self.validate_and_checksum_address(owner) self.validator.assert_valid( method_name='permit', parameter_name='spender', argument_value=spender, ) spender = self.validate_and_checksum_address(spender) self.validator.assert_valid( method_name='permit', parameter_name='rawAmount', argument_value=raw_amount, ) # safeguard against fractional inputs raw_amount = int(raw_amount) self.validator.assert_valid( method_name='permit', parameter_name='deadline', argument_value=deadline, ) # safeguard against fractional inputs deadline = int(deadline) self.validator.assert_valid( method_name='permit', parameter_name='v', argument_value=v, ) self.validator.assert_valid( method_name='permit', parameter_name='r', argument_value=r, ) self.validator.assert_valid( method_name='permit', parameter_name='s', argument_value=s, ) return (owner, spender, raw_amount, deadline, v, r, s)
Inherited members
class PermitTypehashMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the PERMIT_TYPEHASH method.
Persist instance data.
Expand source code
class PermitTypehashMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the PERMIT_TYPEHASH 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("PERMIT_TYPEHASH") def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned) def block_send(self, _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() 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}: permit_typehash") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit_typehash: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit_typehash. 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) ‑> Union[bytes, str]
-
Expand source code
def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned)
def block_send(self, _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, _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() 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}: permit_typehash") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit_typehash: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, permit_typehash. 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 RenounceAdminMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the renounceAdmin method.
Persist instance data.
Expand source code
class RenounceAdminMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the renounceAdmin 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("renounceAdmin") def block_send(self, _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() 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}: renounce_admin") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_admin: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_admin. 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_send(self, _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, _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() 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}: renounce_admin") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_admin: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_admin. 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 RenounceRoleMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the renounceRole method.
Persist instance data.
Expand source code
class RenounceRoleMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the renounceRole 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("renounceRole") def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any: """Validate the inputs to the renounceRole method.""" self.validator.assert_valid( method_name='renounceRole', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='renounceRole', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (role, account) def block_send(self, role: Union[bytes, str], account: 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(role, account) 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}: renounce_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_role. Reason: Unknown") def send_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).transact(tx_params.as_dict()) def build_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: 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(role, account) 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}: renounce_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, renounce_role. Reason: Unknown")
def build_transaction(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
def send_transaction(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) ‑>
-
Validate the inputs to the renounceRole method.
Expand source code
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any: """Validate the inputs to the renounceRole method.""" self.validator.assert_valid( method_name='renounceRole', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='renounceRole', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (role, account)
Inherited members
class RevokeRoleMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the revokeRole method.
Persist instance data.
Expand source code
class RevokeRoleMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the revokeRole 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("revokeRole") def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any: """Validate the inputs to the revokeRole method.""" self.validator.assert_valid( method_name='revokeRole', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='revokeRole', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (role, account) def block_send(self, role: Union[bytes, str], account: 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(role, account) 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}: revoke_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, revoke_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, revoke_role. Reason: Unknown") def send_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).transact(tx_params.as_dict()) def build_transaction(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: 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(role, account) 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}: revoke_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, revoke_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, revoke_role. Reason: Unknown")
def build_transaction(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).estimateGas(tx_params.as_dict())
def send_transaction(self, role: Union[bytes, str], account: 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, role: Union[bytes, str], account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (role, account) = self.validate_and_normalize_inputs(role, account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(role, account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) ‑>
-
Validate the inputs to the revokeRole method.
Expand source code
def validate_and_normalize_inputs(self, role: Union[bytes, str], account: str) -> any: """Validate the inputs to the revokeRole method.""" self.validator.assert_valid( method_name='revokeRole', parameter_name='role', argument_value=role, ) self.validator.assert_valid( method_name='revokeRole', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (role, account)
Inherited members
class SafeBurnMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the safeBurn method.
Persist instance data.
Expand source code
class SafeBurnMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the safeBurn 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("safeBurn") def validate_and_normalize_inputs(self, account: str, value: int) -> any: """Validate the inputs to the safeBurn method.""" self.validator.assert_valid( method_name='safeBurn', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) self.validator.assert_valid( method_name='safeBurn', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (account, value) def block_send(self, account: str, value: int, _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(account, value) 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}: safe_burn") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_burn: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_burn. Reason: Unknown") def send_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).transact(tx_params.as_dict()) def build_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, account: str, value: int, _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, account: str, value: int, _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(account, value) 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}: safe_burn") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_burn: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_burn. Reason: Unknown")
def build_transaction(self, account: str, value: 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, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, value: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
def send_transaction(self, account: str, value: 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, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str, value: int) ‑>
-
Validate the inputs to the safeBurn method.
Expand source code
def validate_and_normalize_inputs(self, account: str, value: int) -> any: """Validate the inputs to the safeBurn method.""" self.validator.assert_valid( method_name='safeBurn', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) self.validator.assert_valid( method_name='safeBurn', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (account, value)
Inherited members
class SafeMintMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the safeMint method.
Persist instance data.
Expand source code
class SafeMintMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the safeMint 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("safeMint") def validate_and_normalize_inputs(self, account: str, value: int) -> any: """Validate the inputs to the safeMint method.""" self.validator.assert_valid( method_name='safeMint', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) self.validator.assert_valid( method_name='safeMint', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (account, value) def block_send(self, account: str, value: int, _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(account, value) 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}: safe_mint") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_mint: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_mint. Reason: Unknown") def send_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).transact(tx_params.as_dict()) def build_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, account: str, value: int, _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, account: str, value: int, _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(account, value) 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}: safe_mint") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_mint: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_mint. Reason: Unknown")
def build_transaction(self, account: str, value: 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, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, value: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
def send_transaction(self, account: str, value: 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, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str, value: int) ‑>
-
Validate the inputs to the safeMint method.
Expand source code
def validate_and_normalize_inputs(self, account: str, value: int) -> any: """Validate the inputs to the safeMint method.""" self.validator.assert_valid( method_name='safeMint', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) self.validator.assert_valid( method_name='safeMint', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (account, value)
Inherited members
class SafeRefundMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the safeRefund method.
Persist instance data.
Expand source code
class SafeRefundMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the safeRefund 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("safeRefund") def validate_and_normalize_inputs(self, account: str, value: int) -> any: """Validate the inputs to the safeRefund method.""" self.validator.assert_valid( method_name='safeRefund', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) self.validator.assert_valid( method_name='safeRefund', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (account, value) def block_send(self, account: str, value: int, _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(account, value) 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}: safe_refund") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_refund: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_refund. Reason: Unknown") def send_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).transact(tx_params.as_dict()) def build_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, account: str, value: int, _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, account: str, value: int, _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(account, value) 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}: safe_refund") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_refund: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_refund. Reason: Unknown")
def build_transaction(self, account: str, value: 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, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, value: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
def send_transaction(self, account: str, value: 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, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str, value: int) ‑>
-
Validate the inputs to the safeRefund method.
Expand source code
def validate_and_normalize_inputs(self, account: str, value: int) -> any: """Validate the inputs to the safeRefund method.""" self.validator.assert_valid( method_name='safeRefund', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) self.validator.assert_valid( method_name='safeRefund', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (account, value)
Inherited members
class SafeTransferMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the safeTransfer method.
Persist instance data.
Expand source code
class SafeTransferMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the safeTransfer 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("safeTransfer") def validate_and_normalize_inputs(self, _from: str, to: str, value: int) -> any: """Validate the inputs to the safeTransfer method.""" self.validator.assert_valid( method_name='safeTransfer', parameter_name='from', argument_value=_from, ) _from = self.validate_and_checksum_address(_from) self.validator.assert_valid( method_name='safeTransfer', parameter_name='to', argument_value=to, ) to = self.validate_and_checksum_address(to) self.validator.assert_valid( method_name='safeTransfer', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (_from, to, value) def block_send(self, _from: str, to: str, value: int, _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(_from, to, value) 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}: safe_transfer") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_transfer: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_transfer. Reason: Unknown") def send_transaction(self, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (_from, to, value) = self.validate_and_normalize_inputs(_from, to, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(_from, to, value).transact(tx_params.as_dict()) def build_transaction(self, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (_from, to, value) = self.validate_and_normalize_inputs(_from, to, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(_from, to, value).buildTransaction(tx_params.as_dict()) def estimate_gas(self, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (_from, to, value) = self.validate_and_normalize_inputs(_from, to, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(_from, to, value).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, _from: str, to: str, value: int, _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, _from: str, to: str, value: int, _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(_from, to, value) 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}: safe_transfer") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_transfer: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, safe_transfer. Reason: Unknown")
def build_transaction(self, _from: str, to: str, value: 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, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (_from, to, value) = self.validate_and_normalize_inputs(_from, to, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(_from, to, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, _from: str, to: str, value: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (_from, to, value) = self.validate_and_normalize_inputs(_from, to, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(_from, to, value).estimateGas(tx_params.as_dict())
def send_transaction(self, _from: str, to: str, value: 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, _from: str, to: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (_from, to, value) = self.validate_and_normalize_inputs(_from, to, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(_from, to, value).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, _from: str, to: str, value: int) ‑>
-
Validate the inputs to the safeTransfer method.
Expand source code
def validate_and_normalize_inputs(self, _from: str, to: str, value: int) -> any: """Validate the inputs to the safeTransfer method.""" self.validator.assert_valid( method_name='safeTransfer', parameter_name='from', argument_value=_from, ) _from = self.validate_and_checksum_address(_from) self.validator.assert_valid( method_name='safeTransfer', parameter_name='to', argument_value=to, ) to = self.validate_and_checksum_address(to) self.validator.assert_valid( method_name='safeTransfer', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (_from, to, value)
Inherited members
class SendCandyMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the sendCandy method.
Persist instance data.
Expand source code
class SendCandyMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the sendCandy 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("sendCandy") def validate_and_normalize_inputs(self, account: str, value: int) -> any: """Validate the inputs to the sendCandy method.""" self.validator.assert_valid( method_name='sendCandy', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) self.validator.assert_valid( method_name='sendCandy', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (account, value) def block_send(self, account: str, value: int, _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(account, value) 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}: send_candy") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_candy: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_candy. Reason: Unknown") def send_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).transact(tx_params.as_dict()) def build_transaction(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, account: str, value: int, _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, account: str, value: int, _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(account, value) 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}: send_candy") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_candy: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_candy. Reason: Unknown")
def build_transaction(self, account: str, value: 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, account: str, value: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, value: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, value: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).estimateGas(tx_params.as_dict())
def send_transaction(self, account: str, value: 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, account: str, value: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account, value) = self.validate_and_normalize_inputs(account, value) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account, value).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str, value: int) ‑>
-
Validate the inputs to the sendCandy method.
Expand source code
def validate_and_normalize_inputs(self, account: str, value: int) -> any: """Validate the inputs to the sendCandy method.""" self.validator.assert_valid( method_name='sendCandy', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) self.validator.assert_valid( method_name='sendCandy', parameter_name='value', argument_value=value, ) # safeguard against fractional inputs value = int(value) return (account, value)
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 admin_role(self) -> str: return self._function_signatures["ADMIN_ROLE"] def default_admin_role(self) -> str: return self._function_signatures["DEFAULT_ADMIN_ROLE"] def domain_typehash(self) -> str: return self._function_signatures["DOMAIN_TYPEHASH"] def permit_typehash(self) -> str: return self._function_signatures["PERMIT_TYPEHASH"] def super_role(self) -> str: return self._function_signatures["SUPER_ROLE"] def add_admin(self) -> str: return self._function_signatures["addAdmin"] def allowance(self) -> str: return self._function_signatures["allowance"] def approve(self) -> str: return self._function_signatures["approve"] def balance_of(self) -> str: return self._function_signatures["balanceOf"] def candy_of(self) -> str: return self._function_signatures["candyOf"] def close(self) -> str: return self._function_signatures["close"] def decimals(self) -> str: return self._function_signatures["decimals"] def decrease_allowance(self) -> str: return self._function_signatures["decreaseAllowance"] def get_role_admin(self) -> str: return self._function_signatures["getRoleAdmin"] def get_role_member(self) -> str: return self._function_signatures["getRoleMember"] def get_role_member_count(self) -> str: return self._function_signatures["getRoleMemberCount"] def grant_role(self) -> str: return self._function_signatures["grantRole"] def has_role(self) -> str: return self._function_signatures["hasRole"] def increase_allowance(self) -> str: return self._function_signatures["increaseAllowance"] def is_admin(self) -> str: return self._function_signatures["isAdmin"] def me(self) -> str: return self._function_signatures["me"] def name(self) -> str: return self._function_signatures["name"] def nonces(self) -> str: return self._function_signatures["nonces"] def permit(self) -> str: return self._function_signatures["permit"] def renounce_admin(self) -> str: return self._function_signatures["renounceAdmin"] def renounce_role(self) -> str: return self._function_signatures["renounceRole"] def revoke_role(self) -> str: return self._function_signatures["revokeRole"] def safe_burn(self) -> str: return self._function_signatures["safeBurn"] def safe_mint(self) -> str: return self._function_signatures["safeMint"] def safe_refund(self) -> str: return self._function_signatures["safeRefund"] def safe_transfer(self) -> str: return self._function_signatures["safeTransfer"] def send_candy(self) -> str: return self._function_signatures["sendCandy"] def symbol(self) -> str: return self._function_signatures["symbol"] def token_of(self) -> str: return self._function_signatures["tokenOf"] def token_rate(self) -> str: return self._function_signatures["tokenRate"] def total_supply(self) -> str: return self._function_signatures["totalSupply"] def transfer(self) -> str: return self._function_signatures["transfer"] def transfer_from(self) -> str: return self._function_signatures["transferFrom"]
Ancestors
Methods
def add_admin(self) ‑> str
-
Expand source code
def add_admin(self) -> str: return self._function_signatures["addAdmin"]
def admin_role(self) ‑> str
-
Expand source code
def admin_role(self) -> str: return self._function_signatures["ADMIN_ROLE"]
def allowance(self) ‑> str
-
Expand source code
def allowance(self) -> str: return self._function_signatures["allowance"]
def approve(self) ‑> str
-
Expand source code
def approve(self) -> str: return self._function_signatures["approve"]
def balance_of(self) ‑> str
-
Expand source code
def balance_of(self) -> str: return self._function_signatures["balanceOf"]
def candy_of(self) ‑> str
-
Expand source code
def candy_of(self) -> str: return self._function_signatures["candyOf"]
def close(self) ‑> str
-
Expand source code
def close(self) -> str: return self._function_signatures["close"]
def decimals(self) ‑> str
-
Expand source code
def decimals(self) -> str: return self._function_signatures["decimals"]
def decrease_allowance(self) ‑> str
-
Expand source code
def decrease_allowance(self) -> str: return self._function_signatures["decreaseAllowance"]
def default_admin_role(self) ‑> str
-
Expand source code
def default_admin_role(self) -> str: return self._function_signatures["DEFAULT_ADMIN_ROLE"]
def domain_typehash(self) ‑> str
-
Expand source code
def domain_typehash(self) -> str: return self._function_signatures["DOMAIN_TYPEHASH"]
def get_role_admin(self) ‑> str
-
Expand source code
def get_role_admin(self) -> str: return self._function_signatures["getRoleAdmin"]
def get_role_member(self) ‑> str
-
Expand source code
def get_role_member(self) -> str: return self._function_signatures["getRoleMember"]
def get_role_member_count(self) ‑> str
-
Expand source code
def get_role_member_count(self) -> str: return self._function_signatures["getRoleMemberCount"]
def grant_role(self) ‑> str
-
Expand source code
def grant_role(self) -> str: return self._function_signatures["grantRole"]
def has_role(self) ‑> str
-
Expand source code
def has_role(self) -> str: return self._function_signatures["hasRole"]
def increase_allowance(self) ‑> str
-
Expand source code
def increase_allowance(self) -> str: return self._function_signatures["increaseAllowance"]
def is_admin(self) ‑> str
-
Expand source code
def is_admin(self) -> str: return self._function_signatures["isAdmin"]
def me(self) ‑> str
-
Expand source code
def me(self) -> str: return self._function_signatures["me"]
def name(self) ‑> str
-
Expand source code
def name(self) -> str: return self._function_signatures["name"]
def nonces(self) ‑> str
-
Expand source code
def nonces(self) -> str: return self._function_signatures["nonces"]
def permit(self) ‑> str
-
Expand source code
def permit(self) -> str: return self._function_signatures["permit"]
def permit_typehash(self) ‑> str
-
Expand source code
def permit_typehash(self) -> str: return self._function_signatures["PERMIT_TYPEHASH"]
def renounce_admin(self) ‑> str
-
Expand source code
def renounce_admin(self) -> str: return self._function_signatures["renounceAdmin"]
def renounce_role(self) ‑> str
-
Expand source code
def renounce_role(self) -> str: return self._function_signatures["renounceRole"]
def revoke_role(self) ‑> str
-
Expand source code
def revoke_role(self) -> str: return self._function_signatures["revokeRole"]
def safe_burn(self) ‑> str
-
Expand source code
def safe_burn(self) -> str: return self._function_signatures["safeBurn"]
def safe_mint(self) ‑> str
-
Expand source code
def safe_mint(self) -> str: return self._function_signatures["safeMint"]
def safe_refund(self) ‑> str
-
Expand source code
def safe_refund(self) -> str: return self._function_signatures["safeRefund"]
def safe_transfer(self) ‑> str
-
Expand source code
def safe_transfer(self) -> str: return self._function_signatures["safeTransfer"]
def send_candy(self) ‑> str
-
Expand source code
def send_candy(self) -> str: return self._function_signatures["sendCandy"]
def super_role(self) ‑> str
-
Expand source code
def super_role(self) -> str: return self._function_signatures["SUPER_ROLE"]
def symbol(self) ‑> str
-
Expand source code
def symbol(self) -> str: return self._function_signatures["symbol"]
def token_of(self) ‑> str
-
Expand source code
def token_of(self) -> str: return self._function_signatures["tokenOf"]
def token_rate(self) ‑> str
-
Expand source code
def token_rate(self) -> str: return self._function_signatures["tokenRate"]
def total_supply(self) ‑> str
-
Expand source code
def total_supply(self) -> str: return self._function_signatures["totalSupply"]
def transfer(self) ‑> str
-
Expand source code
def transfer(self) -> str: return self._function_signatures["transfer"]
def transfer_from(self) ‑> str
-
Expand source code
def transfer_from(self) -> str: return self._function_signatures["transferFrom"]
class SuperRoleMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the SUPER_ROLE method.
Persist instance data.
Expand source code
class SuperRoleMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the SUPER_ROLE 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("SUPER_ROLE") def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned) def block_send(self, _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() 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}: super_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, super_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, super_role. 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) ‑> Union[bytes, str]
-
Expand source code
def block_call(self, debug: bool = False) -> Union[bytes, str]: _fn = self._underlying_method() returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned)
def block_send(self, _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, _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() 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}: super_role") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, super_role: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, super_role. 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 SymbolMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the symbol method.
Persist instance data.
Expand source code
class SymbolMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the symbol 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("symbol") 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}: symbol") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, symbol: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, symbol. 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}: symbol") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, symbol: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, symbol. 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 TokenOfMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the tokenOf method.
Persist instance data.
Expand source code
class TokenOfMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the tokenOf 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("tokenOf") def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the tokenOf method.""" self.validator.assert_valid( method_name='tokenOf', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account) def block_call(self, account: str, debug: bool = False) -> int: _fn = self._underlying_method(account) returned = _fn.call({ 'from': self._operate }) return int(returned) def block_send(self, account: 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(account) 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}: token_of") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_of: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_of. Reason: Unknown") def send_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict()) def build_transaction(self, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict()) def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, account: str, debug: bool = False) ‑> int
-
Expand source code
def block_call(self, account: str, debug: bool = False) -> int: _fn = self._underlying_method(account) returned = _fn.call({ 'from': self._operate }) return int(returned)
def block_send(self, account: 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, account: 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(account) 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}: token_of") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_of: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_of. Reason: Unknown")
def build_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).buildTransaction(tx_params.as_dict())
def estimate_gas(self, account: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, account: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).estimateGas(tx_params.as_dict())
def send_transaction(self, account: 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, account: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (account) = self.validate_and_normalize_inputs(account) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(account).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, account: str) ‑>
-
Validate the inputs to the tokenOf method.
Expand source code
def validate_and_normalize_inputs(self, account: str) -> any: """Validate the inputs to the tokenOf method.""" self.validator.assert_valid( method_name='tokenOf', parameter_name='account', argument_value=account, ) account = self.validate_and_checksum_address(account) return (account)
Inherited members
class TokenRateMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the tokenRate method.
Persist instance data.
Expand source code
class TokenRateMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the tokenRate 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("tokenRate") 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}: token_rate") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_rate: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_rate. 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}: token_rate") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_rate: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, token_rate. 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 TotalSupplyMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the totalSupply method.
Persist instance data.
Expand source code
class TotalSupplyMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the totalSupply 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("totalSupply") 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}: total_supply") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, total_supply: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, total_supply. 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}: total_supply") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, total_supply: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, total_supply. 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 TransferFromMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the transferFrom method.
Persist instance data.
Expand source code
class TransferFromMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the transferFrom 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("transferFrom") def validate_and_normalize_inputs(self, sender: str, recipient: str, amount: int) -> any: """Validate the inputs to the transferFrom method.""" self.validator.assert_valid( method_name='transferFrom', parameter_name='sender', argument_value=sender, ) sender = self.validate_and_checksum_address(sender) self.validator.assert_valid( method_name='transferFrom', parameter_name='recipient', argument_value=recipient, ) recipient = self.validate_and_checksum_address(recipient) self.validator.assert_valid( method_name='transferFrom', parameter_name='amount', argument_value=amount, ) # safeguard against fractional inputs amount = int(amount) return (sender, recipient, amount) def block_send(self, sender: str, recipient: str, amount: int, _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(sender, 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}: transfer_from") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_from: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_from. Reason: Unknown") def send_transaction(self, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, recipient, amount).transact(tx_params.as_dict()) def build_transaction(self, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, recipient, amount).buildTransaction(tx_params.as_dict()) def estimate_gas(self, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, recipient, amount).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, sender: str, recipient: str, amount: int, _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, sender: str, recipient: str, amount: int, _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(sender, 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}: transfer_from") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_from: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer_from. Reason: Unknown")
def build_transaction(self, sender: str, 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, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, recipient, amount).buildTransaction(tx_params.as_dict())
def estimate_gas(self, sender: str, recipient: str, amount: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, recipient, amount).estimateGas(tx_params.as_dict())
def send_transaction(self, sender: str, 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, sender: str, recipient: str, amount: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (sender, recipient, amount) = self.validate_and_normalize_inputs(sender, recipient, amount) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(sender, recipient, amount).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, sender: str, recipient: str, amount: int) ‑>
-
Validate the inputs to the transferFrom method.
Expand source code
def validate_and_normalize_inputs(self, sender: str, recipient: str, amount: int) -> any: """Validate the inputs to the transferFrom method.""" self.validator.assert_valid( method_name='transferFrom', parameter_name='sender', argument_value=sender, ) sender = self.validate_and_checksum_address(sender) self.validator.assert_valid( method_name='transferFrom', parameter_name='recipient', argument_value=recipient, ) recipient = self.validate_and_checksum_address(recipient) self.validator.assert_valid( method_name='transferFrom', parameter_name='amount', argument_value=amount, ) # safeguard against fractional inputs amount = int(amount) return (sender, recipient, amount)
Inherited members
class TransferMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the transfer method.
Persist instance data.
Expand source code
class TransferMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the transfer 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("transfer") def validate_and_normalize_inputs(self, recipient: str, amount: int) -> any: """Validate the inputs to the transfer method.""" self.validator.assert_valid( method_name='transfer', parameter_name='recipient', argument_value=recipient, ) recipient = self.validate_and_checksum_address(recipient) self.validator.assert_valid( method_name='transfer', 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) -> 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(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}: transfer") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer. 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) ‑> 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, recipient: str, amount: int, _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(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}: transfer") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, transfer. 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 transfer method.
Expand source code
def validate_and_normalize_inputs(self, recipient: str, amount: int) -> any: """Validate the inputs to the transfer method.""" self.validator.assert_valid( method_name='transfer', parameter_name='recipient', argument_value=recipient, ) recipient = self.validate_and_checksum_address(recipient) self.validator.assert_valid( method_name='transfer', parameter_name='amount', argument_value=amount, ) # safeguard against fractional inputs amount = int(amount) return (recipient, amount)
Inherited members