当前位置: 首页>>代码示例>>Python>>正文


Python tester.ABIContract方法代码示例

本文整理汇总了Python中ethereum.tester.ABIContract方法的典型用法代码示例。如果您正苦于以下问题:Python tester.ABIContract方法的具体用法?Python tester.ABIContract怎么用?Python tester.ABIContract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ethereum.tester的用法示例。


在下文中一共展示了tester.ABIContract方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def __init__(self, tester_state, private_key, address):
        if len(tester_state.block.get_code(address)) == 0:
            raise Exception('Contract code empty')

        self.address = address
        self.tester_state = tester_state
        self.private_key = private_key

        self.registry_proxy = tester.ABIContract(
            self.tester_state,
            CONTRACT_MANAGER.get_abi(CONTRACT_REGISTRY),
            self.address,
            default_key=private_key,
        )
        self.tokenadded_filters = list()

        self.address_to_channelmanager = dict()
        self.token_to_channelmanager = dict() 
开发者ID:raiden-network,项目名称:raiden,代码行数:20,代码来源:tester_client.py

示例2: test_abicontract_interface

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def test_abicontract_interface():
    """ Test for issue #370. """
    tester_state = state()

    contract_path = path.join(CONTRACTS_DIR, 'simple_contract.sol')
    simple_compiled = compile_file(contract_path)
    simple_address = tester_state.evm(simple_compiled['Simple']['bin'])

    # ABIContract class must accept json_abi
    abi_json = json.dumps(simple_compiled['Simple']['abi']).encode('utf-8')

    abi = ABIContract(
        _state=tester_state,
        _abi=abi_json,
        address=simple_address,
        listen=False,
        log_listener=None,
        default_key=None,
    )

    assert abi.test() == 1  # pylint: disable=no-member 
开发者ID:ethereumproject,项目名称:pyethereum,代码行数:23,代码来源:test_tester.py

示例3: create_contract

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def create_contract(self, path, params=None, libraries=None, sender=None):
        path, extra_args = self.get_dirs(path)
        if params:
            params = [x.address if isinstance(x, t.ABIContract) else x for x in params]
        if libraries:
            for name, address in libraries.items():
                if type(address) == str:
                    if self.is_hex(address):
                        libraries[name] = address
                    else:
                        libraries[name] = encode(address, 'hex')
                elif isinstance(address, t.ABIContract):
                    libraries[name] = encode(address.address, 'hex')
                else:
                    raise ValueError
        return self.s.abi_contract(None,
                                   path=path,
                                   constructor_parameters=params,
                                   libraries=libraries,
                                   language='solidity',
                                   extra_args=extra_args,
                                   sender=keys[sender if sender else 0]) 
开发者ID:gnosis,项目名称:gnosis-contracts,代码行数:24,代码来源:abstract_test.py

示例4: create_tokenproxy

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def create_tokenproxy(tester_state, tester_token_address, log_listener):
    translator = tester.ContractTranslator(
        CONTRACT_MANAGER.get_abi(CONTRACT_HUMAN_STANDARD_TOKEN)
    )
    token_abi = tester.ABIContract(
        tester_state,
        translator,
        tester_token_address,
        log_listener=log_listener,
        default_key=INVALID_KEY,
    )
    return token_abi 
开发者ID:raiden-network,项目名称:raiden,代码行数:14,代码来源:tester.py

示例5: create_registryproxy

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def create_registryproxy(tester_state, tester_registry_address, log_listener):
    translator = tester.ContractTranslator(CONTRACT_MANAGER.get_abi(CONTRACT_REGISTRY))
    registry_abi = tester.ABIContract(
        tester_state,
        translator,
        tester_registry_address,
        log_listener=log_listener,
        default_key=INVALID_KEY,
    )
    return registry_abi 
开发者ID:raiden-network,项目名称:raiden,代码行数:12,代码来源:tester.py

示例6: create_channelmanager_proxy

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def create_channelmanager_proxy(tester_state, tester_channelmanager_address, log_listener):
    translator = tester.ContractTranslator(
        CONTRACT_MANAGER.get_abi(CONTRACT_CHANNEL_MANAGER)
    )
    channel_manager_abi = tester.ABIContract(
        tester_state,
        translator,
        tester_channelmanager_address,
        log_listener=log_listener,
        default_key=INVALID_KEY,
    )
    return channel_manager_abi 
开发者ID:raiden-network,项目名称:raiden,代码行数:14,代码来源:tester.py

示例7: create_nettingchannel_proxy

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def create_nettingchannel_proxy(tester_state, tester_nettingchannel_address, log_listener):
    translator = tester.ContractTranslator(
        CONTRACT_MANAGER.get_abi(CONTRACT_NETTING_CHANNEL)
    )
    netting_channel_abi = tester.ABIContract(
        tester_state,
        translator,
        tester_nettingchannel_address,
        log_listener=log_listener,
        default_key=INVALID_KEY,
    )
    return netting_channel_abi 
开发者ID:raiden-network,项目名称:raiden,代码行数:14,代码来源:tester.py

示例8: deploy_contract

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def deploy_contract(self, start, end, creator_idx=9, migration_master=None, founder=None):
        if founder is None:
            founder = tester.accounts[creator_idx]
        if migration_master is None:
            migration_master = founder

        t = abi.ContractTranslator(GNT_ABI)
        args = t.encode_constructor_arguments((founder, migration_master,
                                               self.state.block.number + start,
                                               self.state.block.number + end))
        addr = self.state.evm(GNT_INIT + args,
                              sender=tester.keys[creator_idx])
        return tester.ABIContract(self.state, GNT_ABI, addr), t 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:15,代码来源:test_wallet.py

示例9: __deploy_contract

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def __deploy_contract(self, _bin, _abi, creator_idx, *args):
        gas_before = self.state.block.gas_used

        t = abi.ContractTranslator(_abi)
        args = t.encode_constructor_arguments(args)
        addr = self.state.evm(_bin + args,
                              sender=tester.keys[creator_idx])
        contract = tester.ABIContract(self.state, _abi, addr)

        return contract, addr, self.state.block.gas_used - gas_before 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:12,代码来源:test_wallet.py

示例10: __deploy_wallet

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def __deploy_wallet(self, owner_key, owners, required=1):
        t = abi.ContractTranslator(WALLET_ABI)
        args = t.encode_constructor_arguments((owners, required))
        addr = self.state.evm(WALLET_INIT + args,
                              sender=owner_key)
        return tester.ABIContract(self.state, WALLET_ABI, addr), t 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:8,代码来源:test_wallet.py

示例11: deploy_contract

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def deploy_contract(self, start, end, creator_idx=9, migration_master=None):
        founder = tester.accounts[creator_idx]
        if migration_master is None:
            migration_master = founder

        t = abi.ContractTranslator(GNT_ABI)
        args = t.encode_constructor_arguments((founder, migration_master, start, end))
        addr = self.state.evm(GNT_INIT + args,
                              sender=tester.keys[creator_idx])
        return tester.ABIContract(self.state, GNT_ABI, addr), t 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:12,代码来源:test_allowance_wallet.py

示例12: deploy_contract

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def deploy_contract(self, founder, start, end,
                        creator_idx=9, migration_master=None):
        if migration_master is None:
            migration_master = founder
        owner = self.monitor(creator_idx)
        t = abi.ContractTranslator(GNT_ABI)
        args = t.encode_constructor_arguments((founder, migration_master,
                                               self.starting_block + start,
                                               self.starting_block + end))
        addr = self.state.evm(GNT_INIT + args,
                              sender=owner.key)
        self.c = tester.ABIContract(self.state, GNT_ABI, addr)
        return addr, owner.gas() 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:15,代码来源:test_gnt.py

示例13: deploy_wallet

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def deploy_wallet(self, _founder, creator_idx=9):
        assert not hasattr(self, 'c')
        owner = self.monitor(creator_idx)
        t = abi.ContractTranslator(WALLET_ABI)
        args = t.encode_constructor_arguments([])
        addr = self.state.evm(WALLET_INIT + args,
                              sender=owner.key)
        self.wallet = tester.ABIContract(self.state, WALLET_ABI, addr)

        return addr, owner.gas() 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:12,代码来源:test_gnt.py

示例14: deploy_contract_on_wallet

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def deploy_contract_on_wallet(self, wallet_addr, start, end):
        c_addr = self.wallet.deploy_contract(wallet_addr,
                                             self.starting_block + start,
                                             self.starting_block + end)
        self.c = tester.ABIContract(self.state, GNT_ABI, c_addr)
        return c_addr 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:8,代码来源:test_gnt.py

示例15: deploy_migration_contract

# 需要导入模块: from ethereum import tester [as 别名]
# 或者: from ethereum.tester import ABIContract [as 别名]
def deploy_migration_contract(self, source_contract, creator_idx=9):
        owner = self.monitor(creator_idx)
        t = abi.ContractTranslator(MIGRATION_ABI)
        args = t.encode_constructor_arguments([source_contract])
        addr = self.state.evm(MIGRATION_INIT + args,
                              sender=owner.key)
        self.m = tester.ABIContract(self.state, MIGRATION_ABI, addr)
        return addr, owner.gas() 
开发者ID:golemfactory,项目名称:golem-crowdfunding,代码行数:10,代码来源:test_gnt.py


注:本文中的ethereum.tester.ABIContract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。