def test_contract_wrapper__execute_method(
    accounts,
    contract_wrapper,  # pylint: disable=redefined-outer-name
    erc20_proxy_address,
):
    """Test :function:`BaseContractWrapper.execute` method."""
    acc1_allowance = contract_wrapper.execute_method(
        abi=abi_by_name("WETH9"),
        method="allowance",
        view_only=True,
        args=(
            to_checksum_address(accounts[3]),
            to_checksum_address(erc20_proxy_address),
        ),
    )
    assert acc1_allowance == 0

    with pytest.raises(Exception):
        contract_wrapper.execute_method(
            abi=abi_by_name("WETH9"),
            method="send",
            view_only=True,
            args=[
                to_checksum_address(accounts[3]),
                to_checksum_address(erc20_proxy_address),
            ],
        )
Ejemplo n.º 2
0
def weth_instance(web3_eth):  # pylint: disable=redefined-outer-name
    """Get an instance of the WrapperEther contract."""
    return web3_eth.contract(
        address=to_checksum_address(
            NETWORK_TO_ADDRESSES[NetworkId.GANACHE].ether_token),
        abi=abi_by_name("WETH9"),
    )
Ejemplo n.º 3
0
 def zx_exchange(self):
     """Returns an instance of the 0x Exchange contract"""
     if self._zx_exchange is None:
         self._zx_exchange = self._web3_eth.contract(
             address=self.exchange_address_checksumed,
             abi=abi_by_name("exchange"))
     return self._zx_exchange
Ejemplo n.º 4
0
def weth_instance(web3_eth):  # pylint: disable=redefined-outer-name
    """Get an instance of the WrapperEther contract."""
    return web3_eth.contract(
        address=to_checksum_address(
            chain_to_addresses(ChainId.GANACHE).ether_token),
        abi=abi_by_name("WETH9"),
    )
Ejemplo n.º 5
0
    def __init__(
        self,
        provider: BaseProvider,
        contract_address: str,
        private_key: str = None,
    ):
        """Get an instance of the 0x Exchange smart contract wrapper.

        :param provider: instance of :class:`web3.providers.base.BaseProvider`
        :param private_key: str of private_key
        """
        super(Exchange, self).__init__(
            provider=provider,
            contract_address=contract_address,
            private_key=private_key,
        )
        self._web3_net = self._web3.net  # pylint: disable=no-member
        self.address = NETWORK_TO_ADDRESSES[NetworkId(
            int(self._web3_net.version))].exchange
        self._exchange = self._contract_instance(address=self.address,
                                                 abi=abi_by_name("Exchange"))