harmony-one / explorer-v2-frontend

19 stars 23 forks source link

PR for #119, #133 and #134 #135

Closed victaphu closed 2 years ago

victaphu commented 2 years ago

@hypnagonia #119 and #133 are front end issues for #119 I added a new chart library (react-chartjs) which gives more config options and a much friendlier user interface. Grommet was not configurable

@sophoah #134 adds support for multiple environments; I added .env.testnet, .env.devnet and updated package.json so build uses the different environments. as discussed I also added env-cmd to the package.json so we can launch these using different yarn run commands (e.g. yarn run start:testnet, yarn run build:testnet, etc)

Also there was a bug that hardcoded the RPC to mainnet, hence we saw the issue in discord. This has been fixed to load the RPC for shard 0.

Please approve. I also spoke with MirrorMirrage and once this is in place he will merge to POPS and release as well.

netlify[bot] commented 2 years ago

✔️ Deploy Preview for explorer-devnet ready!

🔨 Explore the source changes: 420abed46d72c4c20d8bd2097c6993957881b4a5

🔍 Inspect the deploy log: https://app.netlify.com/sites/explorer-devnet/deploys/6205f087d6ea350007a07966

😎 Browse the preview: https://deploy-preview-135--explorer-devnet.netlify.app

victaphu commented 2 years ago

You can test this here: https://explorer-2.netlify.app/

victaphu commented 2 years ago

Should we check #code suffix in page url?

From the issue #133 description it seems like:

  1. client understands that address belongs to contract
  2. and after this set initial tab to 7 (like etherscan redirects to #code tab)

Harmony-etherscan auto-generates a link: https://explorer.harmony.one/address/0x4eBb2a1714384d54Dc287B9FbA1c8D4639717d43#code

This is something we can't avoid because hardhat-etherscan verifies source code and prints this in the terminal for users to review the verification results. When this was printed for user to review they could not click this link to review the smart contract verification.

I've made the code accept #code (it rejected the URL previously) and if it is a contract the code should transfer the user view to Contract view. #code is parsed into the document.location.hash automatically parameter which I check. Prior to changes to file src/App.tsx when # was present in the URL it did something weird and redirect back to the main explorer page. The changes are as follows: if (document.location.hash && document.location.hash !== "#code") { document.location.href = ${ document.location.origin }/${document.location.hash.slice(2)}; } Note: to reduce impact of my code change I aded an ignore condition (above) so if the hash is #code it will let the flow pass into the next section which will redirect the users' selected tab into the contract view if (activeTab === 0 && history.location.hash === "#code") { activeTab = 7; }

One thing that might need to be addressed is that activeTab should only be set to 7 if #code is in the URL and the address is a contract. This bit of functionality is added for support of hardhat-etherscan

ArtemKolodko commented 2 years ago

Thanks for detailed explanation, didn't know about auto-generated link. I think we can merge PR