예제 #1
0
    def _run_funding(self, configuration_file: RaidenConfigurationFile):
        network = configuration_file.network
        settings = network_settings[network.name]

        if not network.FAUCET_AVAILABLE:
            self._send_error_message(
                f"Can not run automatic funding for {network.capitalized_name}"
            )
            return

        account = configuration_file.account
        w3 = make_web3_provider(
            configuration_file.ethereum_client_rpc_endpoint, account)
        self._send_status_update(
            f"Obtaining {network.capitalized_name} ETH through faucet")
        network.fund(account)
        balance = account.wait_for_ethereum_funds(
            w3=w3, expected_amount=EthereumAmount(0.01))
        self._send_status_update(f"Account funded with {balance.formatted}")

        if settings.service_token.mintable:
            service_token = Erc20Token.find_by_ticker(
                settings.service_token.ticker, settings.network)
            self._send_status_update(f"Minting {service_token.ticker}")
            mint_tokens(w3, account, service_token)

        if settings.transfer_token.mintable:
            transfer_token = Erc20Token.find_by_ticker(
                settings.transfer_token.ticker, settings.network)
            self._send_status_update(f"Minting {transfer_token.ticker}")
            mint_tokens(w3, account, transfer_token)
예제 #2
0
 def test_can_mint_tokens(self):
     self.network.fund(self.account)
     self.account.wait_for_ethereum_funds(self.w3, EthereumAmount(0.01))
     tx_hash = mint_tokens(self.w3, self.account, self.svt_token)
     wait_for_transaction(self.w3, tx_hash)
     balance = get_token_balance(self.w3, self.account, self.svt_token)
     self.assertTrue(balance.as_wei >= self.svt_token.supply)
예제 #3
0
    def _deposit(self):
        network = self._get_network()
        w3 = self._get_web3()
        ethereum_balance = self.account.get_ethereum_balance(w3=w3)

        log.debug(f"Ethereum Balance: {ethereum_balance.formatted}")
        if not ethereum_balance.as_wei:
            network.fund(self.account)

        token = Erc20Token.find_by_ticker(settings.service_token.ticker)
        token_balance = get_token_balance(w3, self.account, token)
        log.debug(f"Token Balance: {token_balance.formatted}")

        if not token_balance.as_wei:
            mint_tokens(w3, self.account, token)
            token_balance = get_token_balance(w3, self.account, token)
            log.debug(f"Tokens minted. New Balance: {token_balance.formatted}")

        deposit_service_tokens(w3, self.account, token, token_balance.as_wei)
예제 #4
0
    def test_udc_deposit(self):
        self.network.fund(self.account)
        self.account.wait_for_ethereum_funds(self.w3, EthereumAmount(0.01))
        tx_hash = mint_tokens(self.w3, self.account, self.svt_token)
        wait_for_transaction(self.w3, tx_hash)

        amount = get_token_balance(self.w3, self.account, self.svt_token)
        tx_hash = deposit_service_tokens(self.w3, self.account, self.svt_token,
                                         amount.as_wei)
        wait_for_transaction(self.w3, tx_hash)

        deposited = get_token_deposit(self.w3, self.account, self.svt_token)
        self.assertEqual(deposited, amount)
예제 #5
0
def provide_liquidity(infura, create_account, uniswap):
    account = create_account()
    w3 = make_web3_provider(infura.url, account)

    fund_account(account, w3)
    tx_hash = mint_tokens(w3, account, WIZ_TOKEN)
    wait_for_transaction(w3, tx_hash)

    current_rate = uniswap.get_current_rate(TokenAmount(1000, WIZ_TOKEN))

    router_proxy = w3.eth.contract(
        abi=uniswap_contracts.UNISWAP_ROUTER02_ABI,
        address=Uniswap.ROUTER02_ADDRESS,
    )
    addLiquidity(w3, account, router_proxy, current_rate)
    yield
    removeLiquidity(w3, account, router_proxy)
    empty_account(w3, account)
예제 #6
0
 def test_cannot_mint_tokens_without_gas(self):
     with self.assertRaises(ValueError):
         mint_tokens(self.w3, self.account, self.svt_token)
예제 #7
0
    def _run_funding(self, **kw):
        try:
            configuration_file_name = kw.get("configuration_file_name")
            configuration_file = RaidenConfigurationFile.get_by_filename(
                configuration_file_name)
        except Exception as exc:
            self._send_error_message(str(exc))
            return

        network = configuration_file.network
        if not network.FAUCET_AVAILABLE:
            self._send_error_message(
                f"Can not run automatic funding for {network.capitalized_name}"
            )
            return

        account = configuration_file.account
        try_unlock(account)
        if account.passphrase is None:
            self._send_error_message(
                "Failed to unlock account! Please reload page")
            return

        w3 = make_web3_provider(
            configuration_file.ethereum_client_rpc_endpoint, account)
        self._send_status_update(
            f"Obtaining {network.capitalized_name} ETH through faucet")
        network.fund(account)
        balance = account.wait_for_ethereum_funds(
            w3=w3, expected_amount=EthereumAmount(0.01))
        self._send_status_update(f"Account funded with {balance.formatted}")

        service_token = Erc20Token.find_by_ticker(
            self.installer_settings.service_token.ticker,
            self.installer_settings.network)

        if self.installer_settings.service_token.mintable:
            self._send_next_step(
                f"Minting {service_token.ticker}",
                f"Fund Account with {service_token.ticker}",
                3,
            )
            tx_hash = mint_tokens(w3, account, service_token)
            wait_for_transaction(w3, tx_hash)

        service_token_balance = get_token_balance(w3, account, service_token)
        if service_token_balance.as_wei > 0:
            self._deposit_to_udc(w3, account, service_token,
                                 service_token_balance)

        if self.installer_settings.transfer_token.mintable:
            transfer_token = Erc20Token.find_by_ticker(
                self.installer_settings.transfer_token.ticker,
                self.installer_settings.network)
            self._send_next_step(
                f"Minting {transfer_token.ticker}",
                f"Fund Account with {transfer_token.ticker}",
                4,
            )
            tx_hash = mint_tokens(w3, account, transfer_token)
            wait_for_transaction(w3, tx_hash)

        self._send_redirect(self.reverse_url("launch",
                                             configuration_file_name))
예제 #8
0
 def test_can_mint_tokens(self):
     self.network.fund(self.account)
     mint_tokens(w3=self.w3, account=self.account, token=self.ldn_token)
예제 #9
0
 def test_can_not_mint_tokens_without_gas(self):
     with self.assertRaises(ValueError):
         mint_tokens(w3=self.w3, account=self.account, token=self.ldn_token)