Пример #1
0
def test_making_provider_request():
    from testrpc.rpc import RPCMethods
    provider = EthereumTesterProvider()
    rm = RequestManager(provider)

    response = rm.request_blocking(method="web3_clientVersion", params=[])

    assert response == RPCMethods.web3_clientVersion()
Пример #2
0
def test_making_provider_request():
    from testrpc.rpc import RPCMethods
    provider = TestRPCProvider(port=get_open_port())
    rm = RequestManager(provider)

    response = rm.request_blocking(method="web3_clientVersion", params=[])

    assert response == RPCMethods.web3_clientVersion()
Пример #3
0
def test_making_provider_request():
    from testrpc.testrpc import web3_clientVersion
    provider = TestRPCProvider(port=get_open_port())
    rm = RequestManager(provider)

    response = rm.request_blocking(method="web3_clientVersion", params=[])

    assert response == web3_clientVersion()
Пример #4
0
    def __init__(self, provider):
        self._requestManager = RequestManager(provider)

        self.eth = Eth(self)
        self.db = Db(self)
        self.shh = Shh(self)
        self.net = Net(self)
        self.personal = Personal(self)
        self.version = Version(self)
        self.txpool = TxPool(self)
        self.miner = Miner(self)
        self.admin = Admin(self)
Пример #5
0
    def __init__(self, provider):
        self._requestManager = RequestManager(provider)
        self.currentProvider = provider

        self.eth = Eth(self)
        self.db = Db(self._requestManager)
        self.shh = Shh(self._requestManager)
        self.net = Net(self._requestManager)
        self.personal = Personal(self._requestManager)
        self.version = Version(self._requestManager)

        self.providers = {
            'RPCProvider': RPCProvider,
            'IPCProvider': IPCProvider,
            'TestRPCProvider': TestRPCProvider,
        }

        self.RPCProvider = RPCProvider
        self.IPCProvider = IPCProvider
        self.TestRPCProvider = TestRPCProvider

        class Config:

            def __getattr__(self, key):
                if key == "defaultAccount":
                    return config.defaultAccount
                elif key == "defaultBlock":
                    return config.defaultBlock

            def __setattr__(self, key, value):
                if key == "defaultAccount":
                    config.defaultAccount = value
                elif key == "defaultBlock":
                    config.defaultBlock = value

        self.config = Config()

        # Encoding and Decoding
        self.toHex = to_hex
        self.toAscii = decode_hex
        self.toUtf8 = compose(decode_hex, force_text)
        self.fromAscii = encode_hex
        self.fromUtf8 = encode_hex
        self.toDecimal = to_decimal
        self.fromDecimal = from_decimal

        # Currency Utility
        self.toWei = to_wei
        self.fromWei = from_wei

        # Address Utility
        self.isAddress = is_address
        self.isChecksumAddress = is_checksum_address
        self.toChecksumAddress = to_checksum_address
Пример #6
0
    def __init__(self, provider):
        self._requestManager = RequestManager(provider)
        self.currentProvider = provider

        self.eth = Eth(self)
        self.db = Db(self._requestManager)
        self.shh = Shh(self._requestManager)
        self.net = Net(self._requestManager)
        self.personal = Personal(self._requestManager)
        self.version = Version(self._requestManager)
        self.txpool = TxPool(self._requestManager)
        self.miner = Miner(self._requestManager)
        self.admin = Admin(self._requestManager)

        self.providers = {
            'RPCProvider': RPCProvider,
            'IPCProvider': IPCProvider,
            'TestRPCProvider': TestRPCProvider,
        }

        self.RPCProvider = RPCProvider
        self.IPCProvider = IPCProvider
        self.TestRPCProvider = TestRPCProvider

        # Encoding and Decoding
        self.toHex = to_hex
        self.toAscii = decode_hex
        self.toUtf8 = compose(decode_hex, force_text)
        self.fromAscii = encode_hex
        self.fromUtf8 = encode_hex
        self.toDecimal = to_decimal
        self.fromDecimal = from_decimal

        # Currency Utility
        self.toWei = to_wei
        self.fromWei = from_wei

        # Address Utility
        self.isAddress = is_address
        self.isChecksumAddress = is_checksum_address
        self.toChecksumAddress = to_checksum_address
Пример #7
0
    def __init__(self, provider):
        self._requestManager = RequestManager(provider)

        self.eth = Eth(self)
        self.db = Db(self)
        self.shh = Shh(self)
        self.net = Net(self)
        self.personal = Personal(self)
        self.version = Version(self)
        self.txpool = TxPool(self)
        self.miner = Miner(self)
        self.admin = Admin(self)
Пример #8
0
class Web3(object):
    def __init__(self, provider):
        self._requestManager = RequestManager(provider)
        self.currentProvider = provider

        self.eth = Eth(self)
        self.db = Db(self._requestManager)
        self.shh = Shh(self._requestManager)
        self.net = Net(self._requestManager)
        self.personal = Personal(self._requestManager)
        self.version = Version(self._requestManager)
        self.txpool = TxPool(self._requestManager)
        self.miner = Miner(self._requestManager)
        self.admin = Admin(self._requestManager)

        self.providers = {
            'RPCProvider': RPCProvider,
            'IPCProvider': IPCProvider,
            'TestRPCProvider': TestRPCProvider,
        }

        self.RPCProvider = RPCProvider
        self.IPCProvider = IPCProvider
        self.TestRPCProvider = TestRPCProvider

        # Encoding and Decoding
        self.toHex = to_hex
        self.toAscii = decode_hex
        self.toUtf8 = compose(decode_hex, force_text)
        self.fromAscii = encode_hex
        self.fromUtf8 = encode_hex
        self.toDecimal = to_decimal
        self.fromDecimal = from_decimal

        # Currency Utility
        self.toWei = to_wei
        self.fromWei = from_wei

        # Address Utility
        self.isAddress = is_address
        self.isChecksumAddress = is_checksum_address
        self.toChecksumAddress = to_checksum_address

    def setProvider(self, provider):
        self._requestManager.setProvider(provider)
        self.currentProvider = provider

    def reset(self, keepIsSyncing):
        self._requestManager.reset(keepIsSyncing)

    def sha3(self, value, encoding="hex"):
        if encoding == 'hex':
            hex_string = value
        else:
            hex_string = encode_hex(value)
        return self._requestManager.request_blocking('web3_sha3', [hex_string])

    def isConnected(self):
        return self.currentProvider is not None and self.currentProvider.isConnected()

    def createBatch(self):
        raise NotImplementedError("Not Implemented")

    def receive(self, requestid, timeout=0, keep=False):
        return self._requestManager.receive(requestid, timeout, keep)
Пример #9
0
class Web3(object):
    RPCProvider = RPCProvider
    IPCProvider = IPCProvider
    TestRPCProvider = TestRPCProvider

    # Iban
    Iban = Iban

    # Encoding and Decoding
    toHex = staticmethod(to_hex)
    toAscii = staticmethod(decode_hex)
    toUtf8 = staticmethod(compose(decode_hex, force_text))
    fromAscii = staticmethod(encode_hex)
    fromUtf8 = staticmethod(encode_hex)
    toDecimal = staticmethod(to_decimal)
    fromDecimal = staticmethod(from_decimal)

    # Currency Utility
    toWei = staticmethod(to_wei)
    fromWei = staticmethod(from_wei)

    # Address Utility
    isAddress = staticmethod(is_address)
    isChecksumAddress = staticmethod(is_checksum_address)
    toChecksumAddress = staticmethod(to_checksum_address)

    def __init__(self, provider):
        self._requestManager = RequestManager(provider)
        self.currentProvider = provider

        self.eth = Eth(self)
        self.db = Db(self._requestManager)
        self.shh = Shh(self._requestManager)
        self.net = Net(self._requestManager)
        self.personal = Personal(self._requestManager)
        self.version = Version(self._requestManager)
        self.txpool = TxPool(self._requestManager)
        self.miner = Miner(self._requestManager)
        self.admin = Admin(self._requestManager)

    def setProvider(self, provider):
        self._requestManager.setProvider(provider)
        self.currentProvider = provider

    def reset(self, keepIsSyncing):
        self._requestManager.reset(keepIsSyncing)

    def sha3(self, value, encoding="hex"):
        if encoding == 'hex':
            hex_string = value
        else:
            hex_string = encode_hex(value)
        return self._requestManager.request_blocking('web3_sha3', [hex_string])

    def isConnected(self):
        return self.currentProvider is not None and self.currentProvider.isConnected()

    def createBatch(self):
        raise NotImplementedError("Not Implemented")

    def receive(self, requestid, timeout=0, keep=False):
        return self._requestManager.receive(requestid, timeout, keep)
Пример #10
0
class Web3(object):
    # Providers
    RPCProvider = RPCProvider
    KeepAliveRPCProvider = KeepAliveRPCProvider
    IPCProvider = IPCProvider
    TestRPCProvider = TestRPCProvider

    # Managers
    RequestManager = RequestManager
    DelegatedSigningManager = DelegatedSigningManager
    PrivateKeySigningManager = PrivateKeySigningManager

    # Iban
    Iban = Iban

    # Encoding and Decoding
    toHex = staticmethod(to_hex)
    toAscii = staticmethod(decode_hex)
    toUtf8 = staticmethod(compose(decode_hex, force_text))
    fromAscii = staticmethod(encode_hex)
    fromUtf8 = staticmethod(encode_hex)
    toDecimal = staticmethod(to_decimal)
    fromDecimal = staticmethod(from_decimal)

    # Currency Utility
    toWei = staticmethod(to_wei)
    fromWei = staticmethod(from_wei)

    # Address Utility
    isAddress = staticmethod(is_address)
    isChecksumAddress = staticmethod(is_checksum_address)
    toChecksumAddress = staticmethod(to_checksum_address)

    def __init__(self, provider):
        self._requestManager = RequestManager(provider)

        self.eth = Eth(self)
        self.db = Db(self)
        self.shh = Shh(self)
        self.net = Net(self)
        self.personal = Personal(self)
        self.version = Version(self)
        self.txpool = TxPool(self)
        self.miner = Miner(self)
        self.admin = Admin(self)

    def setProvider(self, provider):
        self._requestManager.setProvider(provider)

    def setManager(self, manager):
        self._requestManager = manager

    @property
    def currentProvider(self):
        return self._requestManager.provider

    def sha3(self, value, encoding="hex"):
        if encoding == 'hex':
            hex_string = value
        else:
            hex_string = encode_hex(value)
        return self._requestManager.request_blocking('web3_sha3', [hex_string])

    def isConnected(self):
        return self.currentProvider is not None and self.currentProvider.isConnected()

    def createBatch(self):
        raise NotImplementedError("Not Implemented")

    def receive(self, requestid, timeout=0, keep=False):
        return self._requestManager.receive(requestid, timeout, keep)
Пример #11
0
class Web3(object):
    def __init__(self, provider):
        self._requestManager = RequestManager(provider)
        self.currentProvider = provider

        self.eth = Eth(self)
        self.db = Db(self._requestManager)
        self.shh = Shh(self._requestManager)
        self.net = Net(self._requestManager)
        self.personal = Personal(self._requestManager)
        self.version = Version(self._requestManager)

        self.providers = {
            'RPCProvider': RPCProvider,
            'IPCProvider': IPCProvider,
            'TestRPCProvider': TestRPCProvider,
        }

        self.RPCProvider = RPCProvider
        self.IPCProvider = IPCProvider
        self.TestRPCProvider = TestRPCProvider

        class Config:

            def __getattr__(self, key):
                if key == "defaultAccount":
                    return config.defaultAccount
                elif key == "defaultBlock":
                    return config.defaultBlock

            def __setattr__(self, key, value):
                if key == "defaultAccount":
                    config.defaultAccount = value
                elif key == "defaultBlock":
                    config.defaultBlock = value

        self.config = Config()

        # Encoding and Decoding
        self.toHex = to_hex
        self.toAscii = decode_hex
        self.toUtf8 = compose(decode_hex, force_text)
        self.fromAscii = encode_hex
        self.fromUtf8 = encode_hex
        self.toDecimal = to_decimal
        self.fromDecimal = from_decimal

        # Currency Utility
        self.toWei = to_wei
        self.fromWei = from_wei

        # Address Utility
        self.isAddress = is_address
        self.isChecksumAddress = is_checksum_address
        self.toChecksumAddress = to_checksum_address

    def setProvider(self, provider):
        self._requestManager.setProvider(provider)
        self.currentProvider = provider

    def reset(self, keepIsSyncing):
        self._requestManager.reset(keepIsSyncing)

    def sha3(self, value, encoding="hex"):
        if encoding == 'hex':
            hex_string = value
        else:
            hex_string = encode_hex(value)
        return self._requestManager.request_blocking('web3_sha3', [hex_string])

    def isConnected(self):
        return self.currentProvider is not None and self.currentProvider.isConnected()

    def createBatch(self):
        raise NotImplementedError("Not Implemented")

    def receive(self, requestid, timeout=0, keep=False):
        return self._requestManager.receive(requestid, timeout, keep)