From 35cd54389f5a8382b5f8f8c3c8fbe9a12e886c72 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Wed, 24 Jul 2019 16:38:54 +0530 Subject: [PATCH] bug: fix grant owner address etherscan link (#4854) --- app/assets/v2/js/abi.js | 20 ++++++++++++------- .../v2/js/grants/cancel_subscription.js | 2 +- app/assets/v2/js/grants/detail.js | 4 ++-- app/assets/v2/js/grants/fund.js | 4 ++-- app/assets/v2/js/grants/index.js | 2 +- app/assets/v2/js/grants/new.js | 2 +- app/assets/v2/js/pages/bounty_details.js | 2 +- app/grants/templates/grants/detail/index.html | 7 ++++++- 8 files changed, 27 insertions(+), 16 deletions(-) diff --git a/app/assets/v2/js/abi.js b/app/assets/v2/js/abi.js index 8c13dc628d8..3bcd322478d 100644 --- a/app/assets/v2/js/abi.js +++ b/app/assets/v2/js/abi.js @@ -46,21 +46,27 @@ var kudos_address = function() { } }; -var etherscan_tx_url = function(txid, network) { +/** + * Returns etherscan link of transaction / + * @param {string} id + * @param {string} network + * @param {enum} type tx | address + */ +var get_etherscan_url = function(id, network, type = 'tx') { let _network = network ? network : document.web3network; switch (_network) { case 'mainnet': - return 'https://etherscan.io/tx/' + txid; + return 'https://etherscan.io/' + type + '/' + id; case 'ropsten': - return 'https://ropsten.etherscan.io/tx/' + txid; + return 'https://ropsten.etherscan.io/' + type + '/' + id; case 'kovan': - return 'https://kovan.etherscan.io/tx/' + txid; + return 'https://kovan.etherscan.io/' + type + '/' + id; case 'rinkeby': - return 'https://rinkeby.etherscan.io/tx/' + txid; + return 'https://rinkeby.etherscan.io/' + type + '/' + id; case 'custom network': - return 'https://localhost/tx/' + txid; + return 'https://localhost/' + type + '/' + id; default: - return 'https://etherscan.io/tx/' + txid; + return 'https://etherscan.io/' + type + '/' + id; } }; diff --git a/app/assets/v2/js/grants/cancel_subscription.js b/app/assets/v2/js/grants/cancel_subscription.js index 44dcb119388..8744777cb0e 100644 --- a/app/assets/v2/js/grants/cancel_subscription.js +++ b/app/assets/v2/js/grants/cancel_subscription.js @@ -40,7 +40,7 @@ $(document).ready(() => { deployedToken.methods.approve(data.contract_address, web3.utils.toTwosComplement(0)).send({from: accounts[0], gasPrice: realGasPrice}) .on('transactionHash', function(transactionHash) { $('#sub_end_approve_tx_id').val(transactionHash); - const linkURL = etherscan_tx_url(transactionHash); + const linkURL = get_etherscan_url(transactionHash); document.issueURL = linkURL; $('#transaction_url').attr('href', linkURL); diff --git a/app/assets/v2/js/grants/detail.js b/app/assets/v2/js/grants/detail.js index 7a6e4247d4c..b98d4160e68 100644 --- a/app/assets/v2/js/grants/detail.js +++ b/app/assets/v2/js/grants/detail.js @@ -143,7 +143,7 @@ $(document).ready(function() { gasPrice: web3.utils.toHex($('#gasPrice').val() * Math.pow(10, 9)) }).on('transactionHash', function(transactionHash) { grant_cancel_tx_id = $('#grant_cancel_tx_id').val(); - const linkURL = etherscan_tx_url(transactionHash); + const linkURL = get_etherscan_url(transactionHash); document.issueURL = linkURL; $('#transaction_url').attr('href', linkURL); @@ -182,7 +182,7 @@ $(document).ready(function() { from: accounts[0], gasPrice: 8000000000 }).on('transactionHash', function(transactionHash) { - const linkURL = etherscan_tx_url(transactionHash); + const linkURL = get_etherscan_url(transactionHash); document.issueURL = linkURL; $('#transaction_url').attr('href', linkURL); diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index c7f8180b1b1..c0f996d139b 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -262,7 +262,7 @@ const donationPayment = (token, account, donationAmountString) => { const subscribeToGrant = (transactionHash) => { web3.eth.getAccounts(function(err, accounts) { deployedToken.methods.decimals().call(function(err, decimals) { - const linkURL = etherscan_tx_url(transactionHash); + const linkURL = get_etherscan_url(transactionHash); let token_address = $('#js-token').length ? $('#js-token').val() : $('#sub_token_address').val(); let data = { 'contributor_address': $('#contributor_address').val(), @@ -393,7 +393,7 @@ const splitPayment = (account, toFirst, toSecond, valueFirst, valueSecond) => { window.location = redirectURL; }); - const linkURL = etherscan_tx_url(transactionHash); + const linkURL = get_etherscan_url(transactionHash); document.issueURL = linkURL; diff --git a/app/assets/v2/js/grants/index.js b/app/assets/v2/js/grants/index.js index fcca2ecfcc5..6b6fe44e036 100644 --- a/app/assets/v2/js/grants/index.js +++ b/app/assets/v2/js/grants/index.js @@ -39,7 +39,7 @@ $(document).ready(() => { const etherscanUrlConvert = (elem, network) => { elem.each(function() { - $(this).attr('href', etherscan_tx_url($(this).attr('href'), network)); + $(this).attr('href', get_etherscan_url($(this).attr('href'), network)); }); }; diff --git a/app/assets/v2/js/grants/new.js b/app/assets/v2/js/grants/new.js index 49c720447a8..cb2cbc8562b 100644 --- a/app/assets/v2/js/grants/new.js +++ b/app/assets/v2/js/grants/new.js @@ -149,7 +149,7 @@ const init = () => { }).on('transactionHash', function(transactionHash) { console.log('2', transactionHash); $('#transaction_hash').val(transactionHash); - const linkURL = etherscan_tx_url(transactionHash); + const linkURL = get_etherscan_url(transactionHash); let file = $('#img-project')[0].files[0]; let formData = new FormData(); diff --git a/app/assets/v2/js/pages/bounty_details.js b/app/assets/v2/js/pages/bounty_details.js index 694c923952a..def1efb4140 100644 --- a/app/assets/v2/js/pages/bounty_details.js +++ b/app/assets/v2/js/pages/bounty_details.js @@ -512,7 +512,7 @@ var showWarningMessage = function(txid) { if (typeof txid != 'undefined' && txid.indexOf('0x') != -1) { waitforWeb3(function() { clearInterval(interval); - var link_url = etherscan_tx_url(txid); + var link_url = get_etherscan_url(txid); $('#transaction_url').attr('href', link_url); }); diff --git a/app/grants/templates/grants/detail/index.html b/app/grants/templates/grants/detail/index.html index e5d160e8d99..2103153ce14 100644 --- a/app/grants/templates/grants/detail/index.html +++ b/app/grants/templates/grants/detail/index.html @@ -87,7 +87,12 @@