Module moody.m.layer_zero_u_s_d_t
Generated wrapper for LayerZeroUSDT Solidity contract.
Expand source code
"""Generated wrapper for LayerZeroUSDT 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 LayerZeroUSDT 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
LayerZeroUSDTValidator,
)
except ImportError:
class LayerZeroUSDTValidator( # type: ignore
Validator
):
"""No-op input validator."""
try:
from .middleware import MIDDLEWARE # type: ignore
except ImportError:
pass
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 AddBlackListMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the addBlackList 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("addBlackList")
def validate_and_normalize_inputs(self, evil: str)->any:
"""Validate the inputs to the addBlackList method."""
self.validator.assert_valid(
method_name='addBlackList',
parameter_name='evil',
argument_value=evil,
)
evil = self.validate_and_checksum_address(evil)
return (evil)
def block_send(self, evil: 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(evil)
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_black_list")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_black_list: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_black_list. Reason: Unknown")
def send_transaction(self, evil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(evil) = self.validate_and_normalize_inputs(evil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(evil).transact(tx_params.as_dict())
def build_transaction(self, evil: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(evil) = self.validate_and_normalize_inputs(evil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(evil).buildTransaction(tx_params.as_dict())
def estimate_gas(self, evil: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(evil) = self.validate_and_normalize_inputs(evil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(evil).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 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 DestroyBlackFundsMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the destroyBlackFunds 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("destroyBlackFunds")
def validate_and_normalize_inputs(self, evil: str)->any:
"""Validate the inputs to the destroyBlackFunds method."""
self.validator.assert_valid(
method_name='destroyBlackFunds',
parameter_name='evil',
argument_value=evil,
)
evil = self.validate_and_checksum_address(evil)
return (evil)
def block_send(self, evil: 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(evil)
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}: destroy_black_funds")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, destroy_black_funds: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, destroy_black_funds. Reason: Unknown")
def send_transaction(self, evil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(evil) = self.validate_and_normalize_inputs(evil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(evil).transact(tx_params.as_dict())
def build_transaction(self, evil: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(evil) = self.validate_and_normalize_inputs(evil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(evil).buildTransaction(tx_params.as_dict())
def estimate_gas(self, evil: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(evil) = self.validate_and_normalize_inputs(evil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(evil).estimateGas(tx_params.as_dict())
class EndpointMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the endpoint 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("endpoint")
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}: endpoint")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, endpoint: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, endpoint. 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 GetBlackListStatusMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the getBlackListStatus 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("getBlackListStatus")
def validate_and_normalize_inputs(self, maker: str)->any:
"""Validate the inputs to the getBlackListStatus method."""
self.validator.assert_valid(
method_name='getBlackListStatus',
parameter_name='_maker',
argument_value=maker,
)
maker = self.validate_and_checksum_address(maker)
return (maker)
def block_call(self,maker: str, debug:bool=False) -> bool:
_fn = self._underlying_method(maker)
returned = _fn.call({
'from': self._operate
})
return bool(returned)
def block_send(self, maker: 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(maker)
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_black_list_status")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_black_list_status: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_black_list_status. Reason: Unknown")
def send_transaction(self, maker: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(maker) = self.validate_and_normalize_inputs(maker)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(maker).transact(tx_params.as_dict())
def build_transaction(self, maker: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(maker) = self.validate_and_normalize_inputs(maker)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(maker).buildTransaction(tx_params.as_dict())
def estimate_gas(self, maker: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(maker) = self.validate_and_normalize_inputs(maker)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(maker).estimateGas(tx_params.as_dict())
class GovernanceMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the governance 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("governance")
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}: governance")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, governance: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, governance. 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 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 IsBlackListedMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the isBlackListed 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("isBlackListed")
def validate_and_normalize_inputs(self, index_0: str)->any:
"""Validate the inputs to the isBlackListed method."""
self.validator.assert_valid(
method_name='isBlackListed',
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) -> bool:
_fn = self._underlying_method(index_0)
returned = _fn.call({
'from': self._operate
})
return bool(returned)
def block_send(self, index_0: 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(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}: is_black_listed")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_black_listed: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_black_listed. 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 LzReceiveMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the lzReceive 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("lzReceive")
def validate_and_normalize_inputs(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str])->any:
"""Validate the inputs to the lzReceive method."""
self.validator.assert_valid(
method_name='lzReceive',
parameter_name='_srcChainId',
argument_value=src_chain_id,
)
self.validator.assert_valid(
method_name='lzReceive',
parameter_name='_srcAddress',
argument_value=src_address,
)
self.validator.assert_valid(
method_name='lzReceive',
parameter_name='index_2',
argument_value=index_2,
)
self.validator.assert_valid(
method_name='lzReceive',
parameter_name='_payload',
argument_value=payload,
)
return (src_chain_id, src_address, index_2, payload)
def block_send(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: 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(src_chain_id, src_address, index_2, payload)
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}: lz_receive")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, lz_receive: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, lz_receive. Reason: Unknown")
def send_transaction(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(src_chain_id, src_address, index_2, payload).transact(tx_params.as_dict())
def build_transaction(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(src_chain_id, src_address, index_2, payload).buildTransaction(tx_params.as_dict())
def estimate_gas(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(src_chain_id, src_address, index_2, payload).estimateGas(tx_params.as_dict())
class MintersMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the minters 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("minters")
def validate_and_normalize_inputs(self, index_0: str)->any:
"""Validate the inputs to the minters method."""
self.validator.assert_valid(
method_name='minters',
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) -> bool:
_fn = self._underlying_method(index_0)
returned = _fn.call({
'from': self._operate
})
return bool(returned)
def block_send(self, index_0: 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(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}: minters")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, minters: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, minters. 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 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 RemotesMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the remotes 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("remotes")
def validate_and_normalize_inputs(self, index_0: int)->any:
"""Validate the inputs to the remotes method."""
self.validator.assert_valid(
method_name='remotes',
parameter_name='index_0',
argument_value=index_0,
)
return (index_0)
def block_call(self,index_0: int, debug:bool=False) -> Union[bytes, str]:
_fn = self._underlying_method(index_0)
returned = _fn.call({
'from': self._operate
})
return Union[bytes, str](returned)
def block_send(self, index_0: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Union[bytes, str]:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(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}: remotes")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remotes: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remotes. Reason: Unknown")
def send_transaction(self, index_0: int, 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: int, 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: int, 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 RemoveBlackListMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the removeBlackList 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("removeBlackList")
def validate_and_normalize_inputs(self, noevil: str)->any:
"""Validate the inputs to the removeBlackList method."""
self.validator.assert_valid(
method_name='removeBlackList',
parameter_name='noevil',
argument_value=noevil,
)
noevil = self.validate_and_checksum_address(noevil)
return (noevil)
def block_send(self, noevil: 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(noevil)
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}: remove_black_list")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remove_black_list: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remove_black_list. Reason: Unknown")
def send_transaction(self, noevil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(noevil) = self.validate_and_normalize_inputs(noevil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(noevil).transact(tx_params.as_dict())
def build_transaction(self, noevil: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(noevil) = self.validate_and_normalize_inputs(noevil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(noevil).buildTransaction(tx_params.as_dict())
def estimate_gas(self, noevil: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(noevil) = self.validate_and_normalize_inputs(noevil)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(noevil).estimateGas(tx_params.as_dict())
class SendTokensMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the sendTokens 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("sendTokens")
def validate_and_normalize_inputs(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int)->any:
"""Validate the inputs to the sendTokens method."""
self.validator.assert_valid(
method_name='sendTokens',
parameter_name='_chainId',
argument_value=chain_id,
)
self.validator.assert_valid(
method_name='sendTokens',
parameter_name='_dstOmniChainTokenAddr',
argument_value=dst_omni_chain_token_addr,
)
self.validator.assert_valid(
method_name='sendTokens',
parameter_name='_qty',
argument_value=qty,
)
# safeguard against fractional inputs
qty = int(qty)
return (chain_id, dst_omni_chain_token_addr, qty)
def block_send(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None:
"""Execute underlying contract method via eth_call.
:param tx_params: transaction parameters
:returns: the return value of the underlying method.
"""
_fn = self._underlying_method(chain_id, dst_omni_chain_token_addr, qty)
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_tokens")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_tokens: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_tokens. Reason: Unknown")
def send_transaction(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).transact(tx_params.as_dict())
def build_transaction(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).buildTransaction(tx_params.as_dict())
def estimate_gas(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).estimateGas(tx_params.as_dict())
class SetGovernanceMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the setGovernance 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("setGovernance")
def validate_and_normalize_inputs(self, governance: str)->any:
"""Validate the inputs to the setGovernance method."""
self.validator.assert_valid(
method_name='setGovernance',
parameter_name='_governance',
argument_value=governance,
)
governance = self.validate_and_checksum_address(governance)
return (governance)
def block_send(self, governance: 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(governance)
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}: set_governance")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_governance: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_governance. Reason: Unknown")
def send_transaction(self, governance: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(governance) = self.validate_and_normalize_inputs(governance)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(governance).transact(tx_params.as_dict())
def build_transaction(self, governance: str, tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(governance) = self.validate_and_normalize_inputs(governance)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(governance).buildTransaction(tx_params.as_dict())
def estimate_gas(self, governance: str, tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(governance) = self.validate_and_normalize_inputs(governance)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(governance).estimateGas(tx_params.as_dict())
class SetRemoteMethod(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the setRemote 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("setRemote")
def validate_and_normalize_inputs(self, chain_id: int, remote_address: Union[bytes, str])->any:
"""Validate the inputs to the setRemote method."""
self.validator.assert_valid(
method_name='setRemote',
parameter_name='_chainId',
argument_value=chain_id,
)
self.validator.assert_valid(
method_name='setRemote',
parameter_name='_remoteAddress',
argument_value=remote_address,
)
return (chain_id, remote_address)
def block_send(self, chain_id: int, remote_address: 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(chain_id, remote_address)
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}: set_remote")
except ValueError as err:
if "message" in err.args[0]:
message = err.args[0]["message"]
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_remote: {message}")
else:
print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_remote. Reason: Unknown")
def send_transaction(self, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.
:param tx_params: transaction parameters
"""
(chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(chain_id, remote_address).transact(tx_params.as_dict())
def build_transaction(self, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
"""Construct calldata to be used as input to the method."""
(chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(chain_id, remote_address).buildTransaction(tx_params.as_dict())
def estimate_gas(self, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
"""Estimate gas consumption of method call."""
(chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address)
tx_params = super().normalize_tx_params(tx_params)
return self._underlying_method(chain_id, remote_address).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 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 domain_typehash(self) -> str:
return self._function_signatures["DOMAIN_TYPEHASH"]
def permit_typehash(self) -> str:
return self._function_signatures["PERMIT_TYPEHASH"]
def add_black_list(self) -> str:
return self._function_signatures["addBlackList"]
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 decimals(self) -> str:
return self._function_signatures["decimals"]
def decrease_allowance(self) -> str:
return self._function_signatures["decreaseAllowance"]
def destroy_black_funds(self) -> str:
return self._function_signatures["destroyBlackFunds"]
def endpoint(self) -> str:
return self._function_signatures["endpoint"]
def get_black_list_status(self) -> str:
return self._function_signatures["getBlackListStatus"]
def governance(self) -> str:
return self._function_signatures["governance"]
def increase_allowance(self) -> str:
return self._function_signatures["increaseAllowance"]
def is_black_listed(self) -> str:
return self._function_signatures["isBlackListed"]
def lz_receive(self) -> str:
return self._function_signatures["lzReceive"]
def minters(self) -> str:
return self._function_signatures["minters"]
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 remotes(self) -> str:
return self._function_signatures["remotes"]
def remove_black_list(self) -> str:
return self._function_signatures["removeBlackList"]
def send_tokens(self) -> str:
return self._function_signatures["sendTokens"]
def set_governance(self) -> str:
return self._function_signatures["setGovernance"]
def set_remote(self) -> str:
return self._function_signatures["setRemote"]
def symbol(self) -> str:
return self._function_signatures["symbol"]
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 LayerZeroUSDT(ContractBase):
"""Wrapper class for LayerZeroUSDT Solidity contract.
All method parameters of type `bytes`:code: should be encoded as UTF-8,
which can be accomplished via `str.encode("utf_8")`:code:.
"""
_fn_domain_typehash: DomainTypehashMethod
"""Constructor-initialized instance of
:class:`DomainTypehashMethod`.
"""
_fn_permit_typehash: PermitTypehashMethod
"""Constructor-initialized instance of
:class:`PermitTypehashMethod`.
"""
_fn_add_black_list: AddBlackListMethod
"""Constructor-initialized instance of
:class:`AddBlackListMethod`.
"""
_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_decimals: DecimalsMethod
"""Constructor-initialized instance of
:class:`DecimalsMethod`.
"""
_fn_decrease_allowance: DecreaseAllowanceMethod
"""Constructor-initialized instance of
:class:`DecreaseAllowanceMethod`.
"""
_fn_destroy_black_funds: DestroyBlackFundsMethod
"""Constructor-initialized instance of
:class:`DestroyBlackFundsMethod`.
"""
_fn_endpoint: EndpointMethod
"""Constructor-initialized instance of
:class:`EndpointMethod`.
"""
_fn_get_black_list_status: GetBlackListStatusMethod
"""Constructor-initialized instance of
:class:`GetBlackListStatusMethod`.
"""
_fn_governance: GovernanceMethod
"""Constructor-initialized instance of
:class:`GovernanceMethod`.
"""
_fn_increase_allowance: IncreaseAllowanceMethod
"""Constructor-initialized instance of
:class:`IncreaseAllowanceMethod`.
"""
_fn_is_black_listed: IsBlackListedMethod
"""Constructor-initialized instance of
:class:`IsBlackListedMethod`.
"""
_fn_lz_receive: LzReceiveMethod
"""Constructor-initialized instance of
:class:`LzReceiveMethod`.
"""
_fn_minters: MintersMethod
"""Constructor-initialized instance of
:class:`MintersMethod`.
"""
_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_remotes: RemotesMethod
"""Constructor-initialized instance of
:class:`RemotesMethod`.
"""
_fn_remove_black_list: RemoveBlackListMethod
"""Constructor-initialized instance of
:class:`RemoveBlackListMethod`.
"""
_fn_send_tokens: SendTokensMethod
"""Constructor-initialized instance of
:class:`SendTokensMethod`.
"""
_fn_set_governance: SetGovernanceMethod
"""Constructor-initialized instance of
:class:`SetGovernanceMethod`.
"""
_fn_set_remote: SetRemoteMethod
"""Constructor-initialized instance of
:class:`SetRemoteMethod`.
"""
_fn_symbol: SymbolMethod
"""Constructor-initialized instance of
:class:`SymbolMethod`.
"""
_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: LayerZeroUSDTValidator = 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 = LayerZeroUSDTValidator(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=LayerZeroUSDT.abi()).functions
signed = SignatureGenerator(LayerZeroUSDT.abi())
validator.bindSignatures(signed)
self.SIGNATURES = signed
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_add_black_list = AddBlackListMethod(core_lib, contract_address, functions.addBlackList, 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_decimals = DecimalsMethod(core_lib, contract_address, functions.decimals, validator)
self._fn_decrease_allowance = DecreaseAllowanceMethod(core_lib, contract_address, functions.decreaseAllowance, validator)
self._fn_destroy_black_funds = DestroyBlackFundsMethod(core_lib, contract_address, functions.destroyBlackFunds, validator)
self._fn_endpoint = EndpointMethod(core_lib, contract_address, functions.endpoint, validator)
self._fn_get_black_list_status = GetBlackListStatusMethod(core_lib, contract_address, functions.getBlackListStatus, validator)
self._fn_governance = GovernanceMethod(core_lib, contract_address, functions.governance, validator)
self._fn_increase_allowance = IncreaseAllowanceMethod(core_lib, contract_address, functions.increaseAllowance, validator)
self._fn_is_black_listed = IsBlackListedMethod(core_lib, contract_address, functions.isBlackListed, validator)
self._fn_lz_receive = LzReceiveMethod(core_lib, contract_address, functions.lzReceive, validator)
self._fn_minters = MintersMethod(core_lib, contract_address, functions.minters, 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_remotes = RemotesMethod(core_lib, contract_address, functions.remotes, validator)
self._fn_remove_black_list = RemoveBlackListMethod(core_lib, contract_address, functions.removeBlackList, validator)
self._fn_send_tokens = SendTokensMethod(core_lib, contract_address, functions.sendTokens, validator)
self._fn_set_governance = SetGovernanceMethod(core_lib, contract_address, functions.setGovernance, validator)
self._fn_set_remote = SetRemoteMethod(core_lib, contract_address, functions.setRemote, validator)
self._fn_symbol = SymbolMethod(core_lib, contract_address, functions.symbol, 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_added_black_list(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event added_black_list in contract LayerZeroUSDT
Get log entry for AddedBlackList event.
:param tx_hash: hash of transaction emitting AddedBlackList event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.AddedBlackList().processReceipt(tx_receipt)
def event_approval(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event approval in contract LayerZeroUSDT
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=LayerZeroUSDT.abi()).events.Approval().processReceipt(tx_receipt)
def event_destroyed_black_funds(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event destroyed_black_funds in contract LayerZeroUSDT
Get log entry for DestroyedBlackFunds event.
:param tx_hash: hash of transaction emitting DestroyedBlackFunds event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.DestroyedBlackFunds().processReceipt(tx_receipt)
def event_removed_black_list(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event removed_black_list in contract LayerZeroUSDT
Get log entry for RemovedBlackList event.
:param tx_hash: hash of transaction emitting RemovedBlackList event
"""
tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash)
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.RemovedBlackList().processReceipt(tx_receipt)
def event_transfer(
self, tx_hash: Union[HexBytes, bytes]
) -> Tuple[AttributeDict]:
"""
Implementation of event transfer in contract LayerZeroUSDT
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=LayerZeroUSDT.abi()).events.Transfer().processReceipt(tx_receipt)
def domain_typehash(self) -> Union[bytes, str]:
"""
Implementation of domain_typehash in contract LayerZeroUSDT
Method of the function
"""
return self._fn_domain_typehash.block_call()
def permit_typehash(self) -> Union[bytes, str]:
"""
Implementation of permit_typehash in contract LayerZeroUSDT
Method of the function
"""
return self._fn_permit_typehash.block_call()
def add_black_list(self, evil: str) -> None:
"""
Implementation of add_black_list in contract LayerZeroUSDT
Method of the function
"""
return self._fn_add_black_list.block_send(evil, 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 LayerZeroUSDT
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 LayerZeroUSDT
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 LayerZeroUSDT
Method of the function
"""
return self._fn_balance_of.block_call(account)
def decimals(self) -> int:
"""
Implementation of decimals in contract LayerZeroUSDT
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 LayerZeroUSDT
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 destroy_black_funds(self, evil: str) -> None:
"""
Implementation of destroy_black_funds in contract LayerZeroUSDT
Method of the function
"""
return self._fn_destroy_black_funds.block_send(evil, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def endpoint(self) -> str:
"""
Implementation of endpoint in contract LayerZeroUSDT
Method of the function
"""
return self._fn_endpoint.block_call()
def get_black_list_status(self, maker: str) -> bool:
"""
Implementation of get_black_list_status in contract LayerZeroUSDT
Method of the function
"""
return self._fn_get_black_list_status.block_call(maker)
def governance(self) -> str:
"""
Implementation of governance in contract LayerZeroUSDT
Method of the function
"""
return self._fn_governance.block_call()
def increase_allowance(self, spender: str, added_value: int) -> bool:
"""
Implementation of increase_allowance in contract LayerZeroUSDT
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_black_listed(self, index_0: str) -> bool:
"""
Implementation of is_black_listed in contract LayerZeroUSDT
Method of the function
"""
return self._fn_is_black_listed.block_call(index_0)
def lz_receive(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str]) -> None:
"""
Implementation of lz_receive in contract LayerZeroUSDT
Method of the function
"""
return self._fn_lz_receive.block_send(src_chain_id, src_address, index_2, payload, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def minters(self, index_0: str) -> bool:
"""
Implementation of minters in contract LayerZeroUSDT
Method of the function
"""
return self._fn_minters.block_call(index_0)
def name(self) -> str:
"""
Implementation of name in contract LayerZeroUSDT
Method of the function
"""
return self._fn_name.block_call()
def nonces(self, index_0: str) -> int:
"""
Implementation of nonces in contract LayerZeroUSDT
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 LayerZeroUSDT
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 remotes(self, index_0: int) -> Union[bytes, str]:
"""
Implementation of remotes in contract LayerZeroUSDT
Method of the function
"""
return self._fn_remotes.block_call(index_0)
def remove_black_list(self, noevil: str) -> None:
"""
Implementation of remove_black_list in contract LayerZeroUSDT
Method of the function
"""
return self._fn_remove_black_list.block_send(noevil, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def send_tokens(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, wei:int=0) -> None:
"""
Implementation of send_tokens in contract LayerZeroUSDT
Method of the function
"""
return self._fn_send_tokens.block_send(chain_id, dst_omni_chain_token_addr, qty, self.call_contract_fee_amount,self.call_contract_fee_price,wei,self.call_contract_debug_flag,self.call_contract_enforce_tx_receipt)
def set_governance(self, governance: str) -> None:
"""
Implementation of set_governance in contract LayerZeroUSDT
Method of the function
"""
return self._fn_set_governance.block_send(governance, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def set_remote(self, chain_id: int, remote_address: Union[bytes, str]) -> None:
"""
Implementation of set_remote in contract LayerZeroUSDT
Method of the function
"""
return self._fn_set_remote.block_send(chain_id, remote_address, 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 LayerZeroUSDT
Method of the function
"""
return self._fn_symbol.block_call()
def total_supply(self) -> int:
"""
Implementation of total_supply in contract LayerZeroUSDT
Method of the function
"""
return self._fn_total_supply.block_call()
def transfer(self, recipient: str, amount: int) -> bool:
"""
Implementation of transfer in contract LayerZeroUSDT
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 LayerZeroUSDT
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)-> "LayerZeroUSDT":
self._fn_domain_typehash.setWait(t_long)
self._fn_permit_typehash.setWait(t_long)
self._fn_add_black_list.setWait(t_long)
self._fn_allowance.setWait(t_long)
self._fn_approve.setWait(t_long)
self._fn_balance_of.setWait(t_long)
self._fn_decimals.setWait(t_long)
self._fn_decrease_allowance.setWait(t_long)
self._fn_destroy_black_funds.setWait(t_long)
self._fn_endpoint.setWait(t_long)
self._fn_get_black_list_status.setWait(t_long)
self._fn_governance.setWait(t_long)
self._fn_increase_allowance.setWait(t_long)
self._fn_is_black_listed.setWait(t_long)
self._fn_lz_receive.setWait(t_long)
self._fn_minters.setWait(t_long)
self._fn_name.setWait(t_long)
self._fn_nonces.setWait(t_long)
self._fn_permit.setWait(t_long)
self._fn_remotes.setWait(t_long)
self._fn_remove_black_list.setWait(t_long)
self._fn_send_tokens.setWait(t_long)
self._fn_set_governance.setWait(t_long)
self._fn_set_remote.setWait(t_long)
self._fn_symbol.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":[{"internalType":"address","name":"_layerZeroEndpoint","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"}],"name":"AddedBlackList","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":false,"internalType":"address","name":"_blackListedUser","type":"address"},{"indexed":false,"internalType":"uint256","name":"_balance","type":"uint256"}],"name":"DestroyedBlackFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"}],"name":"RemovedBlackList","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"},{"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":[{"internalType":"address","name":"evil","type":"address"}],"name":"addBlackList","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":[],"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":"address","name":"evil","type":"address"}],"name":"destroyBlackFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endpoint","outputs":[{"internalType":"contract ILayerZeroEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_maker","type":"address"}],"name":"getBlackListStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"index_0","type":"address"}],"name":"isBlackListed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"index_2","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"minters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[{"internalType":"uint16","name":"index_0","type":"uint16"}],"name":"remotes","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"noevil","type":"address"}],"name":"removeBlackList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"bytes","name":"_dstOmniChainTokenAddr","type":"bytes"},{"internalType":"uint256","name":"_qty","type":"uint256"}],"name":"sendTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"setRemote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"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 AddBlackListMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the addBlackList method.
Persist instance data.
Expand source code
class AddBlackListMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the addBlackList 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("addBlackList") def validate_and_normalize_inputs(self, evil: str)->any: """Validate the inputs to the addBlackList method.""" self.validator.assert_valid( method_name='addBlackList', parameter_name='evil', argument_value=evil, ) evil = self.validate_and_checksum_address(evil) return (evil) def block_send(self, evil: 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(evil) 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_black_list") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_black_list: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_black_list. Reason: Unknown") def send_transaction(self, evil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).transact(tx_params.as_dict()) def build_transaction(self, evil: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).buildTransaction(tx_params.as_dict()) def estimate_gas(self, evil: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, evil: 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, evil: 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(evil) 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_black_list") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_black_list: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, add_black_list. Reason: Unknown")
def build_transaction(self, evil: 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, evil: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).buildTransaction(tx_params.as_dict())
def estimate_gas(self, evil: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, evil: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).estimateGas(tx_params.as_dict())
def send_transaction(self, evil: 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, evil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, evil: str) ‑>
-
Validate the inputs to the addBlackList method.
Expand source code
def validate_and_normalize_inputs(self, evil: str)->any: """Validate the inputs to the addBlackList method.""" self.validator.assert_valid( method_name='addBlackList', parameter_name='evil', argument_value=evil, ) evil = self.validate_and_checksum_address(evil) return (evil)
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 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 DestroyBlackFundsMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the destroyBlackFunds method.
Persist instance data.
Expand source code
class DestroyBlackFundsMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the destroyBlackFunds 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("destroyBlackFunds") def validate_and_normalize_inputs(self, evil: str)->any: """Validate the inputs to the destroyBlackFunds method.""" self.validator.assert_valid( method_name='destroyBlackFunds', parameter_name='evil', argument_value=evil, ) evil = self.validate_and_checksum_address(evil) return (evil) def block_send(self, evil: 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(evil) 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}: destroy_black_funds") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, destroy_black_funds: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, destroy_black_funds. Reason: Unknown") def send_transaction(self, evil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).transact(tx_params.as_dict()) def build_transaction(self, evil: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).buildTransaction(tx_params.as_dict()) def estimate_gas(self, evil: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, evil: 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, evil: 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(evil) 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}: destroy_black_funds") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, destroy_black_funds: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, destroy_black_funds. Reason: Unknown")
def build_transaction(self, evil: 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, evil: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).buildTransaction(tx_params.as_dict())
def estimate_gas(self, evil: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, evil: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).estimateGas(tx_params.as_dict())
def send_transaction(self, evil: 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, evil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (evil) = self.validate_and_normalize_inputs(evil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(evil).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, evil: str) ‑>
-
Validate the inputs to the destroyBlackFunds method.
Expand source code
def validate_and_normalize_inputs(self, evil: str)->any: """Validate the inputs to the destroyBlackFunds method.""" self.validator.assert_valid( method_name='destroyBlackFunds', parameter_name='evil', argument_value=evil, ) evil = self.validate_and_checksum_address(evil) return (evil)
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 EndpointMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the endpoint method.
Persist instance data.
Expand source code
class EndpointMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the endpoint 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("endpoint") 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}: endpoint") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, endpoint: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, endpoint. 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}: endpoint") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, endpoint: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, endpoint. 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 GetBlackListStatusMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the getBlackListStatus method.
Persist instance data.
Expand source code
class GetBlackListStatusMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the getBlackListStatus 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("getBlackListStatus") def validate_and_normalize_inputs(self, maker: str)->any: """Validate the inputs to the getBlackListStatus method.""" self.validator.assert_valid( method_name='getBlackListStatus', parameter_name='_maker', argument_value=maker, ) maker = self.validate_and_checksum_address(maker) return (maker) def block_call(self,maker: str, debug:bool=False) -> bool: _fn = self._underlying_method(maker) returned = _fn.call({ 'from': self._operate }) return bool(returned) def block_send(self, maker: 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(maker) 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_black_list_status") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_black_list_status: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_black_list_status. Reason: Unknown") def send_transaction(self, maker: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (maker) = self.validate_and_normalize_inputs(maker) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(maker).transact(tx_params.as_dict()) def build_transaction(self, maker: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (maker) = self.validate_and_normalize_inputs(maker) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(maker).buildTransaction(tx_params.as_dict()) def estimate_gas(self, maker: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (maker) = self.validate_and_normalize_inputs(maker) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(maker).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_call(self, maker: str, debug: bool = False) ‑> bool
-
Expand source code
def block_call(self,maker: str, debug:bool=False) -> bool: _fn = self._underlying_method(maker) returned = _fn.call({ 'from': self._operate }) return bool(returned)
def block_send(self, maker: 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, maker: 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(maker) 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_black_list_status") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_black_list_status: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, get_black_list_status. Reason: Unknown")
def build_transaction(self, maker: 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, maker: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (maker) = self.validate_and_normalize_inputs(maker) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(maker).buildTransaction(tx_params.as_dict())
def estimate_gas(self, maker: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, maker: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (maker) = self.validate_and_normalize_inputs(maker) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(maker).estimateGas(tx_params.as_dict())
def send_transaction(self, maker: 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, maker: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (maker) = self.validate_and_normalize_inputs(maker) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(maker).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, maker: str) ‑>
-
Validate the inputs to the getBlackListStatus method.
Expand source code
def validate_and_normalize_inputs(self, maker: str)->any: """Validate the inputs to the getBlackListStatus method.""" self.validator.assert_valid( method_name='getBlackListStatus', parameter_name='_maker', argument_value=maker, ) maker = self.validate_and_checksum_address(maker) return (maker)
Inherited members
class GovernanceMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the governance method.
Persist instance data.
Expand source code
class GovernanceMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the governance 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("governance") 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}: governance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, governance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, governance. 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}: governance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, governance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, governance. 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 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 IsBlackListedMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the isBlackListed method.
Persist instance data.
Expand source code
class IsBlackListedMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the isBlackListed 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("isBlackListed") def validate_and_normalize_inputs(self, index_0: str)->any: """Validate the inputs to the isBlackListed method.""" self.validator.assert_valid( method_name='isBlackListed', 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) -> bool: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return bool(returned) def block_send(self, index_0: 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(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}: is_black_listed") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_black_listed: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_black_listed. 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) ‑> bool
-
Expand source code
def block_call(self,index_0: str, debug:bool=False) -> bool: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return bool(returned)
def block_send(self, index_0: 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, index_0: 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(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}: is_black_listed") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_black_listed: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, is_black_listed. 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 isBlackListed method.
Expand source code
def validate_and_normalize_inputs(self, index_0: str)->any: """Validate the inputs to the isBlackListed method.""" self.validator.assert_valid( method_name='isBlackListed', parameter_name='index_0', argument_value=index_0, ) index_0 = self.validate_and_checksum_address(index_0) return (index_0)
Inherited members
class LayerZeroUSDT (core_lib: MiliDoS, contract_address: str, validator: LayerZeroUSDTValidator = None)
-
Wrapper class for LayerZeroUSDT Solidity contract.
All method parameters of type
bytes
:code: should be encoded as UTF-8, which can be accomplished viastr.encode("utf_8")
:code:.Get an instance of wrapper for smart contract.
Expand source code
class LayerZeroUSDT(ContractBase): """Wrapper class for LayerZeroUSDT Solidity contract. All method parameters of type `bytes`:code: should be encoded as UTF-8, which can be accomplished via `str.encode("utf_8")`:code:. """ _fn_domain_typehash: DomainTypehashMethod """Constructor-initialized instance of :class:`DomainTypehashMethod`. """ _fn_permit_typehash: PermitTypehashMethod """Constructor-initialized instance of :class:`PermitTypehashMethod`. """ _fn_add_black_list: AddBlackListMethod """Constructor-initialized instance of :class:`AddBlackListMethod`. """ _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_decimals: DecimalsMethod """Constructor-initialized instance of :class:`DecimalsMethod`. """ _fn_decrease_allowance: DecreaseAllowanceMethod """Constructor-initialized instance of :class:`DecreaseAllowanceMethod`. """ _fn_destroy_black_funds: DestroyBlackFundsMethod """Constructor-initialized instance of :class:`DestroyBlackFundsMethod`. """ _fn_endpoint: EndpointMethod """Constructor-initialized instance of :class:`EndpointMethod`. """ _fn_get_black_list_status: GetBlackListStatusMethod """Constructor-initialized instance of :class:`GetBlackListStatusMethod`. """ _fn_governance: GovernanceMethod """Constructor-initialized instance of :class:`GovernanceMethod`. """ _fn_increase_allowance: IncreaseAllowanceMethod """Constructor-initialized instance of :class:`IncreaseAllowanceMethod`. """ _fn_is_black_listed: IsBlackListedMethod """Constructor-initialized instance of :class:`IsBlackListedMethod`. """ _fn_lz_receive: LzReceiveMethod """Constructor-initialized instance of :class:`LzReceiveMethod`. """ _fn_minters: MintersMethod """Constructor-initialized instance of :class:`MintersMethod`. """ _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_remotes: RemotesMethod """Constructor-initialized instance of :class:`RemotesMethod`. """ _fn_remove_black_list: RemoveBlackListMethod """Constructor-initialized instance of :class:`RemoveBlackListMethod`. """ _fn_send_tokens: SendTokensMethod """Constructor-initialized instance of :class:`SendTokensMethod`. """ _fn_set_governance: SetGovernanceMethod """Constructor-initialized instance of :class:`SetGovernanceMethod`. """ _fn_set_remote: SetRemoteMethod """Constructor-initialized instance of :class:`SetRemoteMethod`. """ _fn_symbol: SymbolMethod """Constructor-initialized instance of :class:`SymbolMethod`. """ _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: LayerZeroUSDTValidator = 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 = LayerZeroUSDTValidator(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=LayerZeroUSDT.abi()).functions signed = SignatureGenerator(LayerZeroUSDT.abi()) validator.bindSignatures(signed) self.SIGNATURES = signed 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_add_black_list = AddBlackListMethod(core_lib, contract_address, functions.addBlackList, 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_decimals = DecimalsMethod(core_lib, contract_address, functions.decimals, validator) self._fn_decrease_allowance = DecreaseAllowanceMethod(core_lib, contract_address, functions.decreaseAllowance, validator) self._fn_destroy_black_funds = DestroyBlackFundsMethod(core_lib, contract_address, functions.destroyBlackFunds, validator) self._fn_endpoint = EndpointMethod(core_lib, contract_address, functions.endpoint, validator) self._fn_get_black_list_status = GetBlackListStatusMethod(core_lib, contract_address, functions.getBlackListStatus, validator) self._fn_governance = GovernanceMethod(core_lib, contract_address, functions.governance, validator) self._fn_increase_allowance = IncreaseAllowanceMethod(core_lib, contract_address, functions.increaseAllowance, validator) self._fn_is_black_listed = IsBlackListedMethod(core_lib, contract_address, functions.isBlackListed, validator) self._fn_lz_receive = LzReceiveMethod(core_lib, contract_address, functions.lzReceive, validator) self._fn_minters = MintersMethod(core_lib, contract_address, functions.minters, 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_remotes = RemotesMethod(core_lib, contract_address, functions.remotes, validator) self._fn_remove_black_list = RemoveBlackListMethod(core_lib, contract_address, functions.removeBlackList, validator) self._fn_send_tokens = SendTokensMethod(core_lib, contract_address, functions.sendTokens, validator) self._fn_set_governance = SetGovernanceMethod(core_lib, contract_address, functions.setGovernance, validator) self._fn_set_remote = SetRemoteMethod(core_lib, contract_address, functions.setRemote, validator) self._fn_symbol = SymbolMethod(core_lib, contract_address, functions.symbol, 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_added_black_list( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event added_black_list in contract LayerZeroUSDT Get log entry for AddedBlackList event. :param tx_hash: hash of transaction emitting AddedBlackList event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.AddedBlackList().processReceipt(tx_receipt) def event_approval( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event approval in contract LayerZeroUSDT 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=LayerZeroUSDT.abi()).events.Approval().processReceipt(tx_receipt) def event_destroyed_black_funds( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event destroyed_black_funds in contract LayerZeroUSDT Get log entry for DestroyedBlackFunds event. :param tx_hash: hash of transaction emitting DestroyedBlackFunds event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.DestroyedBlackFunds().processReceipt(tx_receipt) def event_removed_black_list( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event removed_black_list in contract LayerZeroUSDT Get log entry for RemovedBlackList event. :param tx_hash: hash of transaction emitting RemovedBlackList event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.RemovedBlackList().processReceipt(tx_receipt) def event_transfer( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event transfer in contract LayerZeroUSDT 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=LayerZeroUSDT.abi()).events.Transfer().processReceipt(tx_receipt) def domain_typehash(self) -> Union[bytes, str]: """ Implementation of domain_typehash in contract LayerZeroUSDT Method of the function """ return self._fn_domain_typehash.block_call() def permit_typehash(self) -> Union[bytes, str]: """ Implementation of permit_typehash in contract LayerZeroUSDT Method of the function """ return self._fn_permit_typehash.block_call() def add_black_list(self, evil: str) -> None: """ Implementation of add_black_list in contract LayerZeroUSDT Method of the function """ return self._fn_add_black_list.block_send(evil, 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 LayerZeroUSDT 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 LayerZeroUSDT 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 LayerZeroUSDT Method of the function """ return self._fn_balance_of.block_call(account) def decimals(self) -> int: """ Implementation of decimals in contract LayerZeroUSDT 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 LayerZeroUSDT 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 destroy_black_funds(self, evil: str) -> None: """ Implementation of destroy_black_funds in contract LayerZeroUSDT Method of the function """ return self._fn_destroy_black_funds.block_send(evil, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def endpoint(self) -> str: """ Implementation of endpoint in contract LayerZeroUSDT Method of the function """ return self._fn_endpoint.block_call() def get_black_list_status(self, maker: str) -> bool: """ Implementation of get_black_list_status in contract LayerZeroUSDT Method of the function """ return self._fn_get_black_list_status.block_call(maker) def governance(self) -> str: """ Implementation of governance in contract LayerZeroUSDT Method of the function """ return self._fn_governance.block_call() def increase_allowance(self, spender: str, added_value: int) -> bool: """ Implementation of increase_allowance in contract LayerZeroUSDT 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_black_listed(self, index_0: str) -> bool: """ Implementation of is_black_listed in contract LayerZeroUSDT Method of the function """ return self._fn_is_black_listed.block_call(index_0) def lz_receive(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str]) -> None: """ Implementation of lz_receive in contract LayerZeroUSDT Method of the function """ return self._fn_lz_receive.block_send(src_chain_id, src_address, index_2, payload, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def minters(self, index_0: str) -> bool: """ Implementation of minters in contract LayerZeroUSDT Method of the function """ return self._fn_minters.block_call(index_0) def name(self) -> str: """ Implementation of name in contract LayerZeroUSDT Method of the function """ return self._fn_name.block_call() def nonces(self, index_0: str) -> int: """ Implementation of nonces in contract LayerZeroUSDT 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 LayerZeroUSDT 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 remotes(self, index_0: int) -> Union[bytes, str]: """ Implementation of remotes in contract LayerZeroUSDT Method of the function """ return self._fn_remotes.block_call(index_0) def remove_black_list(self, noevil: str) -> None: """ Implementation of remove_black_list in contract LayerZeroUSDT Method of the function """ return self._fn_remove_black_list.block_send(noevil, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def send_tokens(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, wei:int=0) -> None: """ Implementation of send_tokens in contract LayerZeroUSDT Method of the function """ return self._fn_send_tokens.block_send(chain_id, dst_omni_chain_token_addr, qty, self.call_contract_fee_amount,self.call_contract_fee_price,wei,self.call_contract_debug_flag,self.call_contract_enforce_tx_receipt) def set_governance(self, governance: str) -> None: """ Implementation of set_governance in contract LayerZeroUSDT Method of the function """ return self._fn_set_governance.block_send(governance, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt) def set_remote(self, chain_id: int, remote_address: Union[bytes, str]) -> None: """ Implementation of set_remote in contract LayerZeroUSDT Method of the function """ return self._fn_set_remote.block_send(chain_id, remote_address, 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 LayerZeroUSDT Method of the function """ return self._fn_symbol.block_call() def total_supply(self) -> int: """ Implementation of total_supply in contract LayerZeroUSDT Method of the function """ return self._fn_total_supply.block_call() def transfer(self, recipient: str, amount: int) -> bool: """ Implementation of transfer in contract LayerZeroUSDT 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 LayerZeroUSDT 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)-> "LayerZeroUSDT": self._fn_domain_typehash.setWait(t_long) self._fn_permit_typehash.setWait(t_long) self._fn_add_black_list.setWait(t_long) self._fn_allowance.setWait(t_long) self._fn_approve.setWait(t_long) self._fn_balance_of.setWait(t_long) self._fn_decimals.setWait(t_long) self._fn_decrease_allowance.setWait(t_long) self._fn_destroy_black_funds.setWait(t_long) self._fn_endpoint.setWait(t_long) self._fn_get_black_list_status.setWait(t_long) self._fn_governance.setWait(t_long) self._fn_increase_allowance.setWait(t_long) self._fn_is_black_listed.setWait(t_long) self._fn_lz_receive.setWait(t_long) self._fn_minters.setWait(t_long) self._fn_name.setWait(t_long) self._fn_nonces.setWait(t_long) self._fn_permit.setWait(t_long) self._fn_remotes.setWait(t_long) self._fn_remove_black_list.setWait(t_long) self._fn_send_tokens.setWait(t_long) self._fn_set_governance.setWait(t_long) self._fn_set_remote.setWait(t_long) self._fn_symbol.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":[{"internalType":"address","name":"_layerZeroEndpoint","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"}],"name":"AddedBlackList","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":false,"internalType":"address","name":"_blackListedUser","type":"address"},{"indexed":false,"internalType":"uint256","name":"_balance","type":"uint256"}],"name":"DestroyedBlackFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"}],"name":"RemovedBlackList","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"},{"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":[{"internalType":"address","name":"evil","type":"address"}],"name":"addBlackList","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":[],"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":"address","name":"evil","type":"address"}],"name":"destroyBlackFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endpoint","outputs":[{"internalType":"contract ILayerZeroEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_maker","type":"address"}],"name":"getBlackListStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"index_0","type":"address"}],"name":"isBlackListed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"index_2","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"minters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[{"internalType":"uint16","name":"index_0","type":"uint16"}],"name":"remotes","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"noevil","type":"address"}],"name":"removeBlackList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"bytes","name":"_dstOmniChainTokenAddr","type":"bytes"},{"internalType":"uint256","name":"_qty","type":"uint256"}],"name":"sendTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"setRemote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"address","name":"_layerZeroEndpoint","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"}],"name":"AddedBlackList","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":false,"internalType":"address","name":"_blackListedUser","type":"address"},{"indexed":false,"internalType":"uint256","name":"_balance","type":"uint256"}],"name":"DestroyedBlackFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_user","type":"address"}],"name":"RemovedBlackList","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"},{"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":[{"internalType":"address","name":"evil","type":"address"}],"name":"addBlackList","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":[],"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":"address","name":"evil","type":"address"}],"name":"destroyBlackFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endpoint","outputs":[{"internalType":"contract ILayerZeroEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_maker","type":"address"}],"name":"getBlackListStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"index_0","type":"address"}],"name":"isBlackListed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"index_2","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"index_0","type":"address"}],"name":"minters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[{"internalType":"uint16","name":"index_0","type":"uint16"}],"name":"remotes","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"noevil","type":"address"}],"name":"removeBlackList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"bytes","name":"_dstOmniChainTokenAddr","type":"bytes"},{"internalType":"uint256","name":"_qty","type":"uint256"}],"name":"sendTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"setRemote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"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) ‑> LayerZeroUSDT
-
Expand source code
def CallContractWait(self, t_long:int)-> "LayerZeroUSDT": self._fn_domain_typehash.setWait(t_long) self._fn_permit_typehash.setWait(t_long) self._fn_add_black_list.setWait(t_long) self._fn_allowance.setWait(t_long) self._fn_approve.setWait(t_long) self._fn_balance_of.setWait(t_long) self._fn_decimals.setWait(t_long) self._fn_decrease_allowance.setWait(t_long) self._fn_destroy_black_funds.setWait(t_long) self._fn_endpoint.setWait(t_long) self._fn_get_black_list_status.setWait(t_long) self._fn_governance.setWait(t_long) self._fn_increase_allowance.setWait(t_long) self._fn_is_black_listed.setWait(t_long) self._fn_lz_receive.setWait(t_long) self._fn_minters.setWait(t_long) self._fn_name.setWait(t_long) self._fn_nonces.setWait(t_long) self._fn_permit.setWait(t_long) self._fn_remotes.setWait(t_long) self._fn_remove_black_list.setWait(t_long) self._fn_send_tokens.setWait(t_long) self._fn_set_governance.setWait(t_long) self._fn_set_remote.setWait(t_long) self._fn_symbol.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_black_list(self, evil: str) ‑> NoneType
-
Implementation of add_black_list in contract LayerZeroUSDT Method of the function
Expand source code
def add_black_list(self, evil: str) -> None: """ Implementation of add_black_list in contract LayerZeroUSDT Method of the function """ return self._fn_add_black_list.block_send(evil, 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 LayerZeroUSDT Method of the function
Expand source code
def allowance(self, owner: str, spender: str) -> int: """ Implementation of allowance in contract LayerZeroUSDT 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 LayerZeroUSDT Method of the function
Expand source code
def approve(self, spender: str, amount: int) -> bool: """ Implementation of approve in contract LayerZeroUSDT 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 LayerZeroUSDT Method of the function
Expand source code
def balance_of(self, account: str) -> int: """ Implementation of balance_of in contract LayerZeroUSDT Method of the function """ return self._fn_balance_of.block_call(account)
def decimals(self) ‑> int
-
Implementation of decimals in contract LayerZeroUSDT Method of the function
Expand source code
def decimals(self) -> int: """ Implementation of decimals in contract LayerZeroUSDT 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 LayerZeroUSDT Method of the function
Expand source code
def decrease_allowance(self, spender: str, subtracted_value: int) -> bool: """ Implementation of decrease_allowance in contract LayerZeroUSDT 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 destroy_black_funds(self, evil: str) ‑> NoneType
-
Implementation of destroy_black_funds in contract LayerZeroUSDT Method of the function
Expand source code
def destroy_black_funds(self, evil: str) -> None: """ Implementation of destroy_black_funds in contract LayerZeroUSDT Method of the function """ return self._fn_destroy_black_funds.block_send(evil, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def domain_typehash(self) ‑> Union[bytes, str]
-
Implementation of domain_typehash in contract LayerZeroUSDT Method of the function
Expand source code
def domain_typehash(self) -> Union[bytes, str]: """ Implementation of domain_typehash in contract LayerZeroUSDT Method of the function """ return self._fn_domain_typehash.block_call()
def endpoint(self) ‑> str
-
Implementation of endpoint in contract LayerZeroUSDT Method of the function
Expand source code
def endpoint(self) -> str: """ Implementation of endpoint in contract LayerZeroUSDT Method of the function """ return self._fn_endpoint.block_call()
def event_added_black_list(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event added_black_list in contract LayerZeroUSDT Get log entry for AddedBlackList event. :param tx_hash: hash of transaction emitting AddedBlackList event
Expand source code
def event_added_black_list( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event added_black_list in contract LayerZeroUSDT Get log entry for AddedBlackList event. :param tx_hash: hash of transaction emitting AddedBlackList event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.AddedBlackList().processReceipt(tx_receipt)
def event_approval(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event approval in contract LayerZeroUSDT 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 LayerZeroUSDT 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=LayerZeroUSDT.abi()).events.Approval().processReceipt(tx_receipt)
def event_destroyed_black_funds(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event destroyed_black_funds in contract LayerZeroUSDT Get log entry for DestroyedBlackFunds event. :param tx_hash: hash of transaction emitting DestroyedBlackFunds event
Expand source code
def event_destroyed_black_funds( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event destroyed_black_funds in contract LayerZeroUSDT Get log entry for DestroyedBlackFunds event. :param tx_hash: hash of transaction emitting DestroyedBlackFunds event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.DestroyedBlackFunds().processReceipt(tx_receipt)
def event_removed_black_list(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event removed_black_list in contract LayerZeroUSDT Get log entry for RemovedBlackList event. :param tx_hash: hash of transaction emitting RemovedBlackList event
Expand source code
def event_removed_black_list( self, tx_hash: Union[HexBytes, bytes] ) -> Tuple[AttributeDict]: """ Implementation of event removed_black_list in contract LayerZeroUSDT Get log entry for RemovedBlackList event. :param tx_hash: hash of transaction emitting RemovedBlackList event """ tx_receipt = self._web3_eth.getTransactionReceipt(tx_hash) return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=LayerZeroUSDT.abi()).events.RemovedBlackList().processReceipt(tx_receipt)
def event_transfer(self, tx_hash: Union[hexbytes.main.HexBytes, bytes]) ‑> Tuple[web3.datastructures.AttributeDict]
-
Implementation of event transfer in contract LayerZeroUSDT 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 LayerZeroUSDT 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=LayerZeroUSDT.abi()).events.Transfer().processReceipt(tx_receipt)
def get_black_list_status(self, maker: str) ‑> bool
-
Implementation of get_black_list_status in contract LayerZeroUSDT Method of the function
Expand source code
def get_black_list_status(self, maker: str) -> bool: """ Implementation of get_black_list_status in contract LayerZeroUSDT Method of the function """ return self._fn_get_black_list_status.block_call(maker)
def governance(self) ‑> str
-
Implementation of governance in contract LayerZeroUSDT Method of the function
Expand source code
def governance(self) -> str: """ Implementation of governance in contract LayerZeroUSDT Method of the function """ return self._fn_governance.block_call()
def increase_allowance(self, spender: str, added_value: int) ‑> bool
-
Implementation of increase_allowance in contract LayerZeroUSDT Method of the function
Expand source code
def increase_allowance(self, spender: str, added_value: int) -> bool: """ Implementation of increase_allowance in contract LayerZeroUSDT 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_black_listed(self, index_0: str) ‑> bool
-
Implementation of is_black_listed in contract LayerZeroUSDT Method of the function
Expand source code
def is_black_listed(self, index_0: str) -> bool: """ Implementation of is_black_listed in contract LayerZeroUSDT Method of the function """ return self._fn_is_black_listed.block_call(index_0)
def lz_receive(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str]) ‑> NoneType
-
Implementation of lz_receive in contract LayerZeroUSDT Method of the function
Expand source code
def lz_receive(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str]) -> None: """ Implementation of lz_receive in contract LayerZeroUSDT Method of the function """ return self._fn_lz_receive.block_send(src_chain_id, src_address, index_2, payload, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def minters(self, index_0: str) ‑> bool
-
Implementation of minters in contract LayerZeroUSDT Method of the function
Expand source code
def minters(self, index_0: str) -> bool: """ Implementation of minters in contract LayerZeroUSDT Method of the function """ return self._fn_minters.block_call(index_0)
def name(self) ‑> str
-
Implementation of name in contract LayerZeroUSDT Method of the function
Expand source code
def name(self) -> str: """ Implementation of name in contract LayerZeroUSDT Method of the function """ return self._fn_name.block_call()
def nonces(self, index_0: str) ‑> int
-
Implementation of nonces in contract LayerZeroUSDT Method of the function
Expand source code
def nonces(self, index_0: str) -> int: """ Implementation of nonces in contract LayerZeroUSDT 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 LayerZeroUSDT 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 LayerZeroUSDT 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 LayerZeroUSDT Method of the function
Expand source code
def permit_typehash(self) -> Union[bytes, str]: """ Implementation of permit_typehash in contract LayerZeroUSDT Method of the function """ return self._fn_permit_typehash.block_call()
def remotes(self, index_0: int) ‑> Union[bytes, str]
-
Implementation of remotes in contract LayerZeroUSDT Method of the function
Expand source code
def remotes(self, index_0: int) -> Union[bytes, str]: """ Implementation of remotes in contract LayerZeroUSDT Method of the function """ return self._fn_remotes.block_call(index_0)
def remove_black_list(self, noevil: str) ‑> NoneType
-
Implementation of remove_black_list in contract LayerZeroUSDT Method of the function
Expand source code
def remove_black_list(self, noevil: str) -> None: """ Implementation of remove_black_list in contract LayerZeroUSDT Method of the function """ return self._fn_remove_black_list.block_send(noevil, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def send_tokens(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, wei: int = 0) ‑> NoneType
-
Implementation of send_tokens in contract LayerZeroUSDT Method of the function
Expand source code
def send_tokens(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, wei:int=0) -> None: """ Implementation of send_tokens in contract LayerZeroUSDT Method of the function """ return self._fn_send_tokens.block_send(chain_id, dst_omni_chain_token_addr, qty, self.call_contract_fee_amount,self.call_contract_fee_price,wei,self.call_contract_debug_flag,self.call_contract_enforce_tx_receipt)
def set_governance(self, governance: str) ‑> NoneType
-
Implementation of set_governance in contract LayerZeroUSDT Method of the function
Expand source code
def set_governance(self, governance: str) -> None: """ Implementation of set_governance in contract LayerZeroUSDT Method of the function """ return self._fn_set_governance.block_send(governance, self.call_contract_fee_amount,self.call_contract_fee_price,0,self.call_contract_debug_flag, self.call_contract_enforce_tx_receipt)
def set_remote(self, chain_id: int, remote_address: Union[bytes, str]) ‑> NoneType
-
Implementation of set_remote in contract LayerZeroUSDT Method of the function
Expand source code
def set_remote(self, chain_id: int, remote_address: Union[bytes, str]) -> None: """ Implementation of set_remote in contract LayerZeroUSDT Method of the function """ return self._fn_set_remote.block_send(chain_id, remote_address, 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 LayerZeroUSDT Method of the function
Expand source code
def symbol(self) -> str: """ Implementation of symbol in contract LayerZeroUSDT Method of the function """ return self._fn_symbol.block_call()
def total_supply(self) ‑> int
-
Implementation of total_supply in contract LayerZeroUSDT Method of the function
Expand source code
def total_supply(self) -> int: """ Implementation of total_supply in contract LayerZeroUSDT Method of the function """ return self._fn_total_supply.block_call()
def transfer(self, recipient: str, amount: int) ‑> bool
-
Implementation of transfer in contract LayerZeroUSDT Method of the function
Expand source code
def transfer(self, recipient: str, amount: int) -> bool: """ Implementation of transfer in contract LayerZeroUSDT 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 LayerZeroUSDT Method of the function
Expand source code
def transfer_from(self, sender: str, recipient: str, amount: int) -> bool: """ Implementation of transfer_from in contract LayerZeroUSDT 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 LayerZeroUSDTValidator (web3_or_provider: web3.main.Web3, contract_address: str)
-
No-op input validator.
Initialize the instance.
Expand source code
class LayerZeroUSDTValidator( # type: ignore Validator ): """No-op input validator."""
Ancestors
Inherited members
class LzReceiveMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the lzReceive method.
Persist instance data.
Expand source code
class LzReceiveMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the lzReceive 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("lzReceive") def validate_and_normalize_inputs(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str])->any: """Validate the inputs to the lzReceive method.""" self.validator.assert_valid( method_name='lzReceive', parameter_name='_srcChainId', argument_value=src_chain_id, ) self.validator.assert_valid( method_name='lzReceive', parameter_name='_srcAddress', argument_value=src_address, ) self.validator.assert_valid( method_name='lzReceive', parameter_name='index_2', argument_value=index_2, ) self.validator.assert_valid( method_name='lzReceive', parameter_name='_payload', argument_value=payload, ) return (src_chain_id, src_address, index_2, payload) def block_send(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: 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(src_chain_id, src_address, index_2, payload) 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}: lz_receive") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, lz_receive: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, lz_receive. Reason: Unknown") def send_transaction(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(src_chain_id, src_address, index_2, payload).transact(tx_params.as_dict()) def build_transaction(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(src_chain_id, src_address, index_2, payload).buildTransaction(tx_params.as_dict()) def estimate_gas(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(src_chain_id, src_address, index_2, payload).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: 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, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: 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(src_chain_id, src_address, index_2, payload) 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}: lz_receive") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, lz_receive: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, lz_receive. Reason: Unknown")
def build_transaction(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: 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, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(src_chain_id, src_address, index_2, payload).buildTransaction(tx_params.as_dict())
def estimate_gas(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(src_chain_id, src_address, index_2, payload).estimateGas(tx_params.as_dict())
def send_transaction(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: 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, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (src_chain_id, src_address, index_2, payload) = self.validate_and_normalize_inputs(src_chain_id, src_address, index_2, payload) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(src_chain_id, src_address, index_2, payload).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str]) ‑>
-
Validate the inputs to the lzReceive method.
Expand source code
def validate_and_normalize_inputs(self, src_chain_id: int, src_address: Union[bytes, str], index_2: int, payload: Union[bytes, str])->any: """Validate the inputs to the lzReceive method.""" self.validator.assert_valid( method_name='lzReceive', parameter_name='_srcChainId', argument_value=src_chain_id, ) self.validator.assert_valid( method_name='lzReceive', parameter_name='_srcAddress', argument_value=src_address, ) self.validator.assert_valid( method_name='lzReceive', parameter_name='index_2', argument_value=index_2, ) self.validator.assert_valid( method_name='lzReceive', parameter_name='_payload', argument_value=payload, ) return (src_chain_id, src_address, index_2, payload)
Inherited members
class MintersMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the minters method.
Persist instance data.
Expand source code
class MintersMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the minters 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("minters") def validate_and_normalize_inputs(self, index_0: str)->any: """Validate the inputs to the minters method.""" self.validator.assert_valid( method_name='minters', 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) -> bool: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return bool(returned) def block_send(self, index_0: 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(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}: minters") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, minters: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, minters. 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) ‑> bool
-
Expand source code
def block_call(self,index_0: str, debug:bool=False) -> bool: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return bool(returned)
def block_send(self, index_0: 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, index_0: 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(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}: minters") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, minters: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, minters. 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 minters method.
Expand source code
def validate_and_normalize_inputs(self, index_0: str)->any: """Validate the inputs to the minters method.""" self.validator.assert_valid( method_name='minters', parameter_name='index_0', argument_value=index_0, ) index_0 = self.validate_and_checksum_address(index_0) return (index_0)
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 RemotesMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the remotes method.
Persist instance data.
Expand source code
class RemotesMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the remotes 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("remotes") def validate_and_normalize_inputs(self, index_0: int)->any: """Validate the inputs to the remotes method.""" self.validator.assert_valid( method_name='remotes', parameter_name='index_0', argument_value=index_0, ) return (index_0) def block_call(self,index_0: int, debug:bool=False) -> Union[bytes, str]: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned) def block_send(self, index_0: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Union[bytes, str]: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(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}: remotes") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remotes: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remotes. Reason: Unknown") def send_transaction(self, index_0: int, 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: int, 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: int, 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: int, debug: bool = False) ‑> Union[bytes, str]
-
Expand source code
def block_call(self,index_0: int, debug:bool=False) -> Union[bytes, str]: _fn = self._underlying_method(index_0) returned = _fn.call({ 'from': self._operate }) return Union[bytes, str](returned)
def block_send(self, index_0: int, _gaswei: int, _pricewei: int) ‑> Union[bytes, str]
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, index_0: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> Union[bytes, str]: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(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}: remotes") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remotes: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remotes. Reason: Unknown")
def build_transaction(self, index_0: 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, index_0: int, 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: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, index_0: int, 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: 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, index_0: int, 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: int) ‑>
-
Validate the inputs to the remotes method.
Expand source code
def validate_and_normalize_inputs(self, index_0: int)->any: """Validate the inputs to the remotes method.""" self.validator.assert_valid( method_name='remotes', parameter_name='index_0', argument_value=index_0, ) return (index_0)
Inherited members
class RemoveBlackListMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the removeBlackList method.
Persist instance data.
Expand source code
class RemoveBlackListMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the removeBlackList 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("removeBlackList") def validate_and_normalize_inputs(self, noevil: str)->any: """Validate the inputs to the removeBlackList method.""" self.validator.assert_valid( method_name='removeBlackList', parameter_name='noevil', argument_value=noevil, ) noevil = self.validate_and_checksum_address(noevil) return (noevil) def block_send(self, noevil: 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(noevil) 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}: remove_black_list") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remove_black_list: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remove_black_list. Reason: Unknown") def send_transaction(self, noevil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (noevil) = self.validate_and_normalize_inputs(noevil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(noevil).transact(tx_params.as_dict()) def build_transaction(self, noevil: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (noevil) = self.validate_and_normalize_inputs(noevil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(noevil).buildTransaction(tx_params.as_dict()) def estimate_gas(self, noevil: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (noevil) = self.validate_and_normalize_inputs(noevil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(noevil).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, noevil: 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, noevil: 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(noevil) 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}: remove_black_list") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remove_black_list: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, remove_black_list. Reason: Unknown")
def build_transaction(self, noevil: 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, noevil: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (noevil) = self.validate_and_normalize_inputs(noevil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(noevil).buildTransaction(tx_params.as_dict())
def estimate_gas(self, noevil: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, noevil: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (noevil) = self.validate_and_normalize_inputs(noevil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(noevil).estimateGas(tx_params.as_dict())
def send_transaction(self, noevil: 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, noevil: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (noevil) = self.validate_and_normalize_inputs(noevil) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(noevil).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, noevil: str) ‑>
-
Validate the inputs to the removeBlackList method.
Expand source code
def validate_and_normalize_inputs(self, noevil: str)->any: """Validate the inputs to the removeBlackList method.""" self.validator.assert_valid( method_name='removeBlackList', parameter_name='noevil', argument_value=noevil, ) noevil = self.validate_and_checksum_address(noevil) return (noevil)
Inherited members
class SendTokensMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the sendTokens method.
Persist instance data.
Expand source code
class SendTokensMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the sendTokens 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("sendTokens") def validate_and_normalize_inputs(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int)->any: """Validate the inputs to the sendTokens method.""" self.validator.assert_valid( method_name='sendTokens', parameter_name='_chainId', argument_value=chain_id, ) self.validator.assert_valid( method_name='sendTokens', parameter_name='_dstOmniChainTokenAddr', argument_value=dst_omni_chain_token_addr, ) self.validator.assert_valid( method_name='sendTokens', parameter_name='_qty', argument_value=qty, ) # safeguard against fractional inputs qty = int(qty) return (chain_id, dst_omni_chain_token_addr, qty) def block_send(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(chain_id, dst_omni_chain_token_addr, qty) 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_tokens") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_tokens: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_tokens. Reason: Unknown") def send_transaction(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).transact(tx_params.as_dict()) def build_transaction(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).buildTransaction(tx_params.as_dict()) def estimate_gas(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, _gaswei: int, _pricewei: int) ‑> NoneType
-
Execute underlying contract method via eth_call.
:param tx_params: transaction parameters :returns: the return value of the underlying method.
Expand source code
def block_send(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int,_gaswei:int,_pricewei:int,_valeth:int=0,_debugtx: bool = False,_receipList: bool = False) -> None: """Execute underlying contract method via eth_call. :param tx_params: transaction parameters :returns: the return value of the underlying method. """ _fn = self._underlying_method(chain_id, dst_omni_chain_token_addr, qty) 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_tokens") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_tokens: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, send_tokens. Reason: Unknown")
def build_transaction(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: 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, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).buildTransaction(tx_params.as_dict())
def estimate_gas(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).estimateGas(tx_params.as_dict())
def send_transaction(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: 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, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (chain_id, dst_omni_chain_token_addr, qty) = self.validate_and_normalize_inputs(chain_id, dst_omni_chain_token_addr, qty) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, dst_omni_chain_token_addr, qty).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int) ‑>
-
Validate the inputs to the sendTokens method.
Expand source code
def validate_and_normalize_inputs(self, chain_id: int, dst_omni_chain_token_addr: Union[bytes, str], qty: int)->any: """Validate the inputs to the sendTokens method.""" self.validator.assert_valid( method_name='sendTokens', parameter_name='_chainId', argument_value=chain_id, ) self.validator.assert_valid( method_name='sendTokens', parameter_name='_dstOmniChainTokenAddr', argument_value=dst_omni_chain_token_addr, ) self.validator.assert_valid( method_name='sendTokens', parameter_name='_qty', argument_value=qty, ) # safeguard against fractional inputs qty = int(qty) return (chain_id, dst_omni_chain_token_addr, qty)
Inherited members
class SetGovernanceMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the setGovernance method.
Persist instance data.
Expand source code
class SetGovernanceMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the setGovernance 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("setGovernance") def validate_and_normalize_inputs(self, governance: str)->any: """Validate the inputs to the setGovernance method.""" self.validator.assert_valid( method_name='setGovernance', parameter_name='_governance', argument_value=governance, ) governance = self.validate_and_checksum_address(governance) return (governance) def block_send(self, governance: 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(governance) 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}: set_governance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_governance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_governance. Reason: Unknown") def send_transaction(self, governance: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (governance) = self.validate_and_normalize_inputs(governance) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(governance).transact(tx_params.as_dict()) def build_transaction(self, governance: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (governance) = self.validate_and_normalize_inputs(governance) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(governance).buildTransaction(tx_params.as_dict()) def estimate_gas(self, governance: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (governance) = self.validate_and_normalize_inputs(governance) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(governance).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, governance: 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, governance: 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(governance) 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}: set_governance") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_governance: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_governance. Reason: Unknown")
def build_transaction(self, governance: 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, governance: str, tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (governance) = self.validate_and_normalize_inputs(governance) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(governance).buildTransaction(tx_params.as_dict())
def estimate_gas(self, governance: str, tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, governance: str, tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (governance) = self.validate_and_normalize_inputs(governance) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(governance).estimateGas(tx_params.as_dict())
def send_transaction(self, governance: 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, governance: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (governance) = self.validate_and_normalize_inputs(governance) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(governance).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, governance: str) ‑>
-
Validate the inputs to the setGovernance method.
Expand source code
def validate_and_normalize_inputs(self, governance: str)->any: """Validate the inputs to the setGovernance method.""" self.validator.assert_valid( method_name='setGovernance', parameter_name='_governance', argument_value=governance, ) governance = self.validate_and_checksum_address(governance) return (governance)
Inherited members
class SetRemoteMethod (elib: MiliDoS, contract_address: str, contract_function: web3.contract.ContractFunction, validator: Validator = None)
-
Various interfaces to the setRemote method.
Persist instance data.
Expand source code
class SetRemoteMethod(ContractMethod): # pylint: disable=invalid-name """Various interfaces to the setRemote 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("setRemote") def validate_and_normalize_inputs(self, chain_id: int, remote_address: Union[bytes, str])->any: """Validate the inputs to the setRemote method.""" self.validator.assert_valid( method_name='setRemote', parameter_name='_chainId', argument_value=chain_id, ) self.validator.assert_valid( method_name='setRemote', parameter_name='_remoteAddress', argument_value=remote_address, ) return (chain_id, remote_address) def block_send(self, chain_id: int, remote_address: 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(chain_id, remote_address) 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}: set_remote") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_remote: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_remote. Reason: Unknown") def send_transaction(self, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, remote_address).transact(tx_params.as_dict()) def build_transaction(self, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, remote_address).buildTransaction(tx_params.as_dict()) def estimate_gas(self, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, remote_address).estimateGas(tx_params.as_dict())
Ancestors
Methods
def block_send(self, chain_id: int, remote_address: 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, chain_id: int, remote_address: 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(chain_id, remote_address) 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}: set_remote") except ValueError as err: if "message" in err.args[0]: message = err.args[0]["message"] print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_remote: {message}") else: print(f"{Bolors.FAIL}Error Revert {Bolors.RESET}, set_remote. Reason: Unknown")
def build_transaction(self, chain_id: int, remote_address: 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, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict: """Construct calldata to be used as input to the method.""" (chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, remote_address).buildTransaction(tx_params.as_dict())
def estimate_gas(self, chain_id: int, remote_address: Union[bytes, str], tx_params: Union[TxParams, NoneType] = None) ‑> int
-
Estimate gas consumption of method call.
Expand source code
def estimate_gas(self, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int: """Estimate gas consumption of method call.""" (chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, remote_address).estimateGas(tx_params.as_dict())
def send_transaction(self, chain_id: int, remote_address: 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, chain_id: int, remote_address: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]: """Execute underlying contract method via eth_sendTransaction. :param tx_params: transaction parameters """ (chain_id, remote_address) = self.validate_and_normalize_inputs(chain_id, remote_address) tx_params = super().normalize_tx_params(tx_params) return self._underlying_method(chain_id, remote_address).transact(tx_params.as_dict())
def validate_and_normalize_inputs(self, chain_id: int, remote_address: Union[bytes, str]) ‑>
-
Validate the inputs to the setRemote method.
Expand source code
def validate_and_normalize_inputs(self, chain_id: int, remote_address: Union[bytes, str])->any: """Validate the inputs to the setRemote method.""" self.validator.assert_valid( method_name='setRemote', parameter_name='_chainId', argument_value=chain_id, ) self.validator.assert_valid( method_name='setRemote', parameter_name='_remoteAddress', argument_value=remote_address, ) return (chain_id, remote_address)
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 domain_typehash(self) -> str: return self._function_signatures["DOMAIN_TYPEHASH"] def permit_typehash(self) -> str: return self._function_signatures["PERMIT_TYPEHASH"] def add_black_list(self) -> str: return self._function_signatures["addBlackList"] 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 decimals(self) -> str: return self._function_signatures["decimals"] def decrease_allowance(self) -> str: return self._function_signatures["decreaseAllowance"] def destroy_black_funds(self) -> str: return self._function_signatures["destroyBlackFunds"] def endpoint(self) -> str: return self._function_signatures["endpoint"] def get_black_list_status(self) -> str: return self._function_signatures["getBlackListStatus"] def governance(self) -> str: return self._function_signatures["governance"] def increase_allowance(self) -> str: return self._function_signatures["increaseAllowance"] def is_black_listed(self) -> str: return self._function_signatures["isBlackListed"] def lz_receive(self) -> str: return self._function_signatures["lzReceive"] def minters(self) -> str: return self._function_signatures["minters"] 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 remotes(self) -> str: return self._function_signatures["remotes"] def remove_black_list(self) -> str: return self._function_signatures["removeBlackList"] def send_tokens(self) -> str: return self._function_signatures["sendTokens"] def set_governance(self) -> str: return self._function_signatures["setGovernance"] def set_remote(self) -> str: return self._function_signatures["setRemote"] def symbol(self) -> str: return self._function_signatures["symbol"] 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_black_list(self) ‑> str
-
Expand source code
def add_black_list(self) -> str: return self._function_signatures["addBlackList"]
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 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 destroy_black_funds(self) ‑> str
-
Expand source code
def destroy_black_funds(self) -> str: return self._function_signatures["destroyBlackFunds"]
def domain_typehash(self) ‑> str
-
Expand source code
def domain_typehash(self) -> str: return self._function_signatures["DOMAIN_TYPEHASH"]
def endpoint(self) ‑> str
-
Expand source code
def endpoint(self) -> str: return self._function_signatures["endpoint"]
def get_black_list_status(self) ‑> str
-
Expand source code
def get_black_list_status(self) -> str: return self._function_signatures["getBlackListStatus"]
def governance(self) ‑> str
-
Expand source code
def governance(self) -> str: return self._function_signatures["governance"]
def increase_allowance(self) ‑> str
-
Expand source code
def increase_allowance(self) -> str: return self._function_signatures["increaseAllowance"]
def is_black_listed(self) ‑> str
-
Expand source code
def is_black_listed(self) -> str: return self._function_signatures["isBlackListed"]
def lz_receive(self) ‑> str
-
Expand source code
def lz_receive(self) -> str: return self._function_signatures["lzReceive"]
def minters(self) ‑> str
-
Expand source code
def minters(self) -> str: return self._function_signatures["minters"]
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 remotes(self) ‑> str
-
Expand source code
def remotes(self) -> str: return self._function_signatures["remotes"]
def remove_black_list(self) ‑> str
-
Expand source code
def remove_black_list(self) -> str: return self._function_signatures["removeBlackList"]
def send_tokens(self) ‑> str
-
Expand source code
def send_tokens(self) -> str: return self._function_signatures["sendTokens"]
def set_governance(self) ‑> str
-
Expand source code
def set_governance(self) -> str: return self._function_signatures["setGovernance"]
def set_remote(self) ‑> str
-
Expand source code
def set_remote(self) -> str: return self._function_signatures["setRemote"]
def symbol(self) ‑> str
-
Expand source code
def symbol(self) -> str: return self._function_signatures["symbol"]
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 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 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