From a369ce6ad024c8d470f33cfa381eec937858ea92 Mon Sep 17 00:00:00 2001 From: EggPool Date: Mon, 26 Apr 2021 20:26:17 +0200 Subject: [PATCH] Tornado 0.1.41 with Bridge Crystal --- requirements.txt | 2 +- wallet/crystals/060_ethbridge/__init__.py | 26 +++++---- wallet/crystals/060_ethbridge/about.json | 4 +- .../crystals/060_ethbridge/static/bridge.js | 53 ++++++++++++++----- .../crystals/060_ethbridge/static/wbis_abi.js | 13 +++-- .../060_ethbridge/themes/default/about.html | 27 +++++----- .../themes/default/from_eth1.html | 10 +++- .../060_ethbridge/themes/default/swaps.html | 2 +- .../060_ethbridge/themes/default/to_eth1.html | 2 +- .../060_ethbridge/themes/default/to_eth2.html | 16 ++++-- 10 files changed, 106 insertions(+), 49 deletions(-) diff --git a/requirements.txt b/requirements.txt index b453dfb..9d34003 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ tornado -bismuthclient>=0.0.51 +bismuthclient>=0.0.52 cachetools aiohttp mnemonic diff --git a/wallet/crystals/060_ethbridge/__init__.py b/wallet/crystals/060_ethbridge/__init__.py index 3d050af..65da4b5 100644 --- a/wallet/crystals/060_ethbridge/__init__.py +++ b/wallet/crystals/060_ethbridge/__init__.py @@ -13,18 +13,20 @@ MODULES = {} -__version__ = "1.0.1" +__version__ = "1.0.2" -ETH_BRIDGE_ADDRESS = "Bis1SCxtbRiDgEjwu5DZ6tb6P3PnZY2j3CJWg" # Test -# ETH_BRIDGE_ADDRESS = "Bis1UBRiDGEQc9mBywXpwFZX6LF7hN4i8Qy9m" # Prod +# ETH_BRIDGE_ADDRESS = "Bis1SCxtbRiDgEjwu5DZ6tb6P3PnZY2j3CJWg" # Test +ETH_BRIDGE_ADDRESS = "Bis1UBRiDGEQc9mBywXpwFZX6LF7hN4i8Qy9m" # Prod -ETH_ORACLE_ADDRESS = "Bis1WaEthEtHeyEbh8wckQrnZnR88XJK8xDFb" # Test -# ETH_ORACLE_ADDRESS = "" # Prod +# ETH_ORACLE_ADDRESS = "Bis1WaEthEtHeyEbh8wckQrnZnR88XJK8xDFb" # Test +ETH_ORACLE_ADDRESS = "Bis1XETHbisxnShtghYQJDbf8o5gsQczW8Gp2" # Prod -ETH_SC_ADDRESS = "0x29B3fF6d2E194ac99D4ca4356251829651D08b94" # Test v6 +# ETH_SC_ADDRESS = "0x29B3fF6d2E194ac99D4ca4356251829651D08b94" # Test v6 +ETH_SC_ADDRESS = "0xf5cB350b40726B5BcF170d12e162B6193b291B41" # Mainnet ETH_wBIS_URL = "https://raw.githubusercontent.com/bismuthfoundation/MEDIA-KIT/master/Logo_v2/wbis500x500.png" -ETH_EXPLORER = "https://goerli.etherscan.io" # test +# ETH_EXPLORER = "https://goerli.etherscan.io" # test +ETH_EXPLORER = "https://etherscan.io" # mainnet BIS_FIXED_FEES_FLOAT = 5.0 BIS_FIXED_FEES_INT = 500000000 @@ -58,6 +60,7 @@ def initialize(self): footer += f'\n' self.bismuth_vars['extra'] = {"header": '', "footer": footer, "ethbridge_address": ETH_BRIDGE_ADDRESS, + "ethoracle_address": ETH_ORACLE_ADDRESS, "eth_sc_address": ETH_SC_ADDRESS, "eth_wbis_url": ETH_wBIS_URL, "eth_explorer": ETH_EXPLORER, @@ -70,6 +73,13 @@ def sha256(txid: str): async def about(self, params=None): self.bismuth_vars['extra']["footer"] += f'\n' + self.bismuth_vars['extra']["circulating"] = "N/A" + try: + res = await async_get_with_http_fallback("https://hypernodes.bismuth.live/api/coinsupply.php") + print(res) + self.bismuth_vars['extra']["circulating"] = res["circulating"] + except: + pass self.render("about.html", bismuth=self.bismuth_vars) async def message_popup(self, params=None): @@ -174,8 +184,6 @@ async def swaps(self, params=None): pass # print("burn", bis_data) - - data['eth_transactions'] = bis_data bismuth_params = [ETH_BRIDGE_ADDRESS, data["bis_address"], 'ethbridge:signature', '0.00000000', True, 0, 9e10] diff --git a/wallet/crystals/060_ethbridge/about.json b/wallet/crystals/060_ethbridge/about.json index ece5a95..d6980d8 100644 --- a/wallet/crystals/060_ethbridge/about.json +++ b/wallet/crystals/060_ethbridge/about.json @@ -2,7 +2,7 @@ "author": "Bismuth Foundation", "description": "BIS <-> wBIS bridge Crystal", "email": "N/A", - "version": "1.0.0", - "date": "2021-04-03", + "version": "1.0.2", + "date": "2021-04-19", "url":"https://github.com/bismuthfoundation/TornadoWallet/tree/master/wallet/crystals/060_ethbridge" } diff --git a/wallet/crystals/060_ethbridge/static/bridge.js b/wallet/crystals/060_ethbridge/static/bridge.js index b76975b..bfa7237 100644 --- a/wallet/crystals/060_ethbridge/static/bridge.js +++ b/wallet/crystals/060_ethbridge/static/bridge.js @@ -57,16 +57,12 @@ Token.prototype.init = function () { this.instance = contract_interface; }; -Token.prototype.showTotal = function () { - this.instance.totalSupply(function (error, total) { - if (error) { - console.log(error); - } else { - console.log("wBIS total:", total / 1E8); - $("#wbis_total").html(total.toNumber() / 1E8); - } - }); -} +Token.prototype.showTotal = async function () { + balance = await this.instance.methods.totalSupply().call(); + console.log("wBIS total:", balance / 1E8); + $("#wbis_total").html(balance / 1E8); + +}; // Displays the token balance of an address, triggered by the "Check balance" button Token.prototype.showAddressBalance = async function (hash, cb) { @@ -110,6 +106,7 @@ Token.prototype.burnTokens = async function () { // Gets form input values var address = $("#burn_recipient").val(); var amount = $("#burn_amount").val(); + var gwei = $("#gwei").val(); console.log("start burn:", address, amount); // Validates address using utility function @@ -142,7 +139,8 @@ Token.prototype.burnTokens = async function () { bisAddressToHex(address) ).send({from: $("#user_eth_address").val(), gas: 100000, - gasPrice: 100000000000, + //gasPrice: 150000000000, + gasPrice: gwei * 1000000000, gasLimit: 200000 }); console.log(txHash.transactionHash); @@ -201,7 +199,7 @@ Token.prototype.signMint = async function () { txid ).send({from: $("#user_eth_address").val(), gas: 100000, - gasPrice: 100000000000, + gasPrice: 150000000000, gasLimit: 200000 }); console.log("tx", tx); @@ -217,6 +215,7 @@ Token.prototype.mintTokens = async function () { var amount = $("#mint_amount").val(); var txid = $("#mint_tx").val(); var auth = $("#mint_auth").val(); + var gwei = $("#gwei").val(); console.log("start mint:", address, amount, txid, auth); // Validates address using utility function @@ -251,7 +250,8 @@ Token.prototype.mintTokens = async function () { auth ).send({from: $("#user_eth_address").val(), gas: 150000, - gasPrice: 100000000000, + //gasPrice: 150000000000, + gasPrice: gwei * 1000000000, gasLimit: 150000 }); console.log(tx.transactionHash); @@ -358,6 +358,11 @@ Token.prototype.onBurnReady = async function () { //if (this.hasContractDeployed()) { // this.updateDisplayContent(); this.bindBurnButtons(); + chain_id = await window.web3.eth.getChainId(); + if (token.Contract.chain_id != chain_id) { + alert("Your Metamask is on the wrong chain. Please switch to "+token.Contract.chain_name); + } + // this.showTotal(); window.web3.eth.getAccounts( async function(error, accounts){ @@ -373,6 +378,11 @@ Token.prototype.onMintReady = async function () { //if (this.hasContractDeployed()) { // this.updateDisplayContent(); this.bindMintButtons(); + chain_id = await window.web3.eth.getChainId(); + if (token.Contract.chain_id != chain_id) { + alert("Your Metamask is on the wrong chain. Please switch to "+token.Contract.chain_name); + } + window.web3.eth.getAccounts( async function(error, accounts){ $("#user_eth_address").val(accounts[0]); @@ -399,6 +409,23 @@ Token.prototype.onAboutReady = async function () { } );*/ // this.showTotal(); + window.web3.eth.getAccounts( + async function(error, accounts){ + $("#my_ethaddress").html(accounts[0]); + + // Gets the value stored within the `balances` mapping of the contract + await token.getBalance(accounts[0], function (error, balance) { + if (error) { + console.log(error); + $("#wbis_amount").html(error.message); + } else { + //console.log(balance / 1E8); + $("#wbis_amount").html(balance / 1E8); + } + }); + } + ); + await token.showTotal(); }; diff --git a/wallet/crystals/060_ethbridge/static/wbis_abi.js b/wallet/crystals/060_ethbridge/static/wbis_abi.js index 021bee8..29bb2dd 100644 --- a/wallet/crystals/060_ethbridge/static/wbis_abi.js +++ b/wallet/crystals/060_ethbridge/static/wbis_abi.js @@ -2,11 +2,16 @@ if (typeof Contracts === "undefined") var Contracts = { Token: { abi: [] } }; var _data = { - address: "0x29B3fF6d2E194ac99D4ca4356251829651D08b94", - owner: "0xD376C7cE2baE29F3A9462C024B960512B54725Cf", - chain_id: 5, - chain_name: "Goerli network", + address6: "0x29B3fF6d2E194ac99D4ca4356251829651D08b94", + address: "0xf5cB350b40726B5BcF170d12e162B6193b291B41", + owner6: "0xD376C7cE2baE29F3A9462C024B960512B54725Cf", + owner: "0xBf56eD4F9B58Ca485563F25c17FB7183a743F288", + chain_id6: 5, + chain_name6: "Goerli network", + chain_id: 1, + chain_name: "ETH Mainnet", image_url: "https://raw.githubusercontent.com/bismuthfoundation/MEDIA-KIT/master/Logo_v2/wbis500x500.png", + image_url_no: "http://127.0.0.1:8888/crystal/ethbridge/static/wbisb.png", network: "browser", endpoint: "http://localhost:8545", diff --git a/wallet/crystals/060_ethbridge/themes/default/about.html b/wallet/crystals/060_ethbridge/themes/default/about.html index 16ecebf..545ec1c 100644 --- a/wallet/crystals/060_ethbridge/themes/default/about.html +++ b/wallet/crystals/060_ethbridge/themes/default/about.html @@ -13,8 +13,8 @@

About

BIS <-> wBIS Bridge Crystal for Bismuth Tornado Wallet
- Version 1.0.1
- TESTNET VERSION! Only use if you know what you are doing! + Version 1.0.3
+ Please read the manual! See Blog post