當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。