Exemple #1
0
def test_compile_smc():
    compiled_smc_json = get_smc_json()

    vmc_code = get_smc_source_code()
    abi = compiler.mk_full_signature(vmc_code)
    bytecode = compiler.compile(vmc_code)
    bytecode_hex = '0x' + bytecode.hex()

    assert abi == compiled_smc_json["abi"]
    assert bytecode_hex == compiled_smc_json["bytecode"]
Exemple #2
0
from sharding.handler.utils.smc_handler_utils import (
    make_call_context,
    make_transaction_context,
)
from sharding.contracts.utils.smc_utils import (
    get_smc_json, )

from eth_keys import (
    datatypes, )
from eth_typing import (
    Address,
    Hash32,
)

smc_json = get_smc_json()


class SMC(Contract):

    logger = logging.getLogger("sharding.SMC")
    abi = smc_json["abi"]
    bytecode = decode_hex(smc_json["bytecode"])

    default_priv_key = None  # type: datatypes.PrivateKey
    default_sender_address = None  # type: Address
    config = None  # type: Dict[str, Any]

    _estimate_gas_dict = {
        entry['name']: entry['gas']
        for entry in smc_json["abi"] if entry['type'] == 'function'
Exemple #3
0
def get_event_signature_from_abi(event_name: str) -> bytes:
    for function in get_smc_json()['abi']:
        if function['name'] == event_name and function['type'] == 'event':
            return event_abi_to_log_topic(function)
    raise ValueError("Event with name {} not found".format(event_name))
Exemple #4
0
 def _extract_event_abi(self, *, event_name: str) -> Dict[str, Any]:
     for func in get_smc_json()['abi']:
         if func['name'] == event_name and func['type'] == 'event':
             return func
     raise LogParsingError("Can not find event {}".format(event_name))