Skip to content

Commit

Permalink
W37 upstream merge (#396)
Browse files Browse the repository at this point in the history
* Fix NaN input in write contract

* Search results page: navbar menu fix

* Resize inputs; improve multiplier selector; add tooltip for tx value; txValue field's type: text -> number

* Fix floating tooltips on token transfer block

* Fix solid outputs on contract read page

* Add step and min value for txValue input

* Add status to Position pane

* Add support EIP-1559

* Update CHANGELOG.md

* Change key to update cache GA

* Change key back to update cache GA

* Fix endless Fetching tokens message on emty addresses

* Change keys of cache for update GA

* Add tooltips and names for fallback and receive functions

* Ability to hide miner

* Improved style of transactions button

* Add token_tile_view_more.css to the main-page.css

* Display token icons for tokens from TrustWallet repo

* token icon for bridged tokens in search results page fix

* Hide error selector in the contract's functions list

* Change alpha of transactions button's background

* Support HTML tags in alert message

* Add implementation link to the overview of proxy contracts

* Fixed formatting

* Remove unused npm packages

* Increased build timeout

* Increased build timeout

* More testing

* More testing

* Fixed PR comments

* Replaced more ETH

* Fix gettext

* CSP fix: allow only trustwallet assets repo from Github

Co-authored-by: nikitosing <[email protected]>
Co-authored-by: Victor Baranov <[email protected]>
Co-authored-by: nikitosing <[email protected]>
Co-authored-by: Enrique Ruiz <[email protected]>
  • Loading branch information
5 people authored Oct 7, 2021
1 parent 816e0e1 commit 5900c7c
Show file tree
Hide file tree
Showing 55 changed files with 1,632 additions and 461 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand All @@ -122,7 +122,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand All @@ -145,7 +145,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand All @@ -154,7 +154,7 @@ jobs:
id: dialyzer-cache
with:
path: priv/plts
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-dialyzer-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-dialyzer-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-dialyzer-"
Expand Down Expand Up @@ -185,7 +185,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand All @@ -211,7 +211,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand Down Expand Up @@ -288,7 +288,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand Down Expand Up @@ -350,7 +350,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand Down Expand Up @@ -413,7 +413,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand Down Expand Up @@ -487,7 +487,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand Down Expand Up @@ -555,7 +555,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_1-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
## Current

### Features
- [#4625](https://github.com/blockscout/blockscout/pull/4625) - Contract address page: Add implementation link to the overview of proxy contracts
- [#4624](https://github.com/blockscout/blockscout/pull/4624) - Support HTML tags in alert message
- [#4608](https://github.com/blockscout/blockscout/pull/4608), [#4622](https://github.com/blockscout/blockscout/pull/4622) - Block Details page: Improved style of transactions button
- [#4596](https://github.com/blockscout/blockscout/pull/4596), [#4681](https://github.com/blockscout/blockscout/pull/4681), [#4693](https://github.com/blockscout/blockscout/pull/4693) - Display token icon for bridged with Mainnet tokens or identicons for other tokens
- [#4520](https://github.com/blockscout/blockscout/pull/4520) - Add support for EIP-1559
- [#4593](https://github.com/blockscout/blockscout/pull/4593) - Add status in `Position` pane for txs have no block
- [#4579](https://github.com/blockscout/blockscout/pull/4579) - Write contract page: Resize inputs; Improve multiplier selector

### Fixes
- [#4713](https://github.com/blockscout/blockscout/pull/4713) - Search input field: sanitize input
- [#4612](https://github.com/blockscout/blockscout/pull/4612) - Hide error selector in the contract's functions list
- [#4615](https://github.com/blockscout/blockscout/pull/4615) - Fix broken style for `View more transfers` button
- [#4592](https://github.com/blockscout/blockscout/pull/4592) - Add `type` field for `receive` and `fallback` entities of a Smart Contract
- [#4601](https://github.com/blockscout/blockscout/pull/4601) - Fix endless Fetching tokens... message on empty addresses
- [#4591](https://github.com/blockscout/blockscout/pull/4591) - Add step and min value for txValue input field
- [#4589](https://github.com/blockscout/blockscout/pull/4589) - Fix solid outputs on contract read page
- [#4586](https://github.com/blockscout/blockscout/pull/4586) - Fix floating tooltips on the token transfer family blocks
- [#4587](https://github.com/blockscout/blockscout/pull/4587) - Enable navbar menu on Search results page
- [#4582](https://github.com/blockscout/blockscout/pull/4582) - Fix NaN input on write contract page


### Chore
- [#4611](https://github.com/blockscout/blockscout/pull/4611) - Ability to hide miner in block views


## 3.7.3-beta
Expand Down
18 changes: 18 additions & 0 deletions apps/block_scout_web/assets/css/components/_btn_no_border.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,21 @@ $btn-no-border-color: $primary !default;
border-color: $btn-no-border-color;
}
}

.btn-no-border-transactions {
background-color: rgba($primary, 0.1) !important;
border-color: $btn-no-border-bg;
align-items: center;
border-radius: 2px;
display: flex;
font-size: 12px;
position: relative;
user-select: none;
text-align: center;
white-space: nowrap;
color: $primary !important;

&:hover {
border-color: #f5f6fa;
}
}
3 changes: 2 additions & 1 deletion apps/block_scout_web/assets/css/components/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ $navbar-logo-width: auto !default;

.logo-text {
color: #333;
font-size: 0.7rem;
font-size: 1rem;
font-weight: 700;
margin-left: 5px;
line-height: 28px;

Expand Down
1 change: 1 addition & 0 deletions apps/block_scout_web/assets/css/components/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
font-weight: 100;
text-transform: uppercase;
color: rgb(33,33,33);
margin-left: auto;
}

.autoComplete_highlight {
Expand Down
2 changes: 1 addition & 1 deletion apps/block_scout_web/assets/css/main-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
@import "components/label";
@import "components/ad";
@import "components/_search";

@import "components/token_tile_view_more";
// Font Awesome
@import "components/_fontawesome_icon";

Expand Down
34 changes: 23 additions & 11 deletions apps/block_scout_web/assets/js/lib/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import AutoComplete from '@tarekraafat/autocomplete.js/dist/autoComplete.js'
import { getTextAdData, fetchTextAdData } from './ad.js'
import $ from 'jquery'
import AutoComplete from '@tarekraafat/autocomplete.js/dist/autoComplete'
import { getTextAdData, fetchTextAdData } from './ad'
import { DateTime } from 'luxon'
import { appendTokenIcon } from './token_icon'
import xss from 'xss'

const placeHolder = 'Search by address, token symbol, name, transaction hash, or block number'
Expand Down Expand Up @@ -52,11 +54,13 @@ const searchEngine = (query, record) => {
(record.block_hash && record.block_hash.toLowerCase().includes(query.toLowerCase()))
)
) {
var searchResult = `${record.address_hash || record.tx_hash || record.block_hash}<br/>`
var searchResult = '<div>'
searchResult += `<div>${record.address_hash || record.tx_hash || record.block_hash}</div>`

if (record.type === 'label') {
searchResult += `<div class="fontawesome-icon tag"></div><span> <b>${record.name}</b></span>`
} else {
searchResult += '<div>'
if (record.name) {
searchResult += `<b>${record.name}</b>`
}
Expand All @@ -69,23 +73,31 @@ const searchEngine = (query, record) => {
if (record.inserted_at) {
searchResult += ` (${DateTime.fromISO(record.inserted_at).toLocaleString(DateTime.DATETIME_SHORT)})`
}
searchResult += '</div>'
}
searchResult += '</div>'
var re = new RegExp(query, 'ig')
searchResult = searchResult.replace(re, '<mark class=\'autoComplete_highlight\'>$&</mark>')
return searchResult
}
}
const resultItemElement = (item, data) => {
// Modify Results Item Style
item.style = 'display: flex; justify-content: space-between;'
// Modify Results Item Content
const resultItemElement = async (item, data) => {
item.style = 'display: flex;'

item.innerHTML = `
<span style="text-overflow: ellipsis; white-space: nowrap; overflow: hidden;">
<div id='token-icon-${data.value.address_hash}' style='margin-top: -1px;'></div>
<div style="padding-left: 10px; padding-right: 10px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;">
${data.match}
</span>
<span class="autocomplete-category">
</div>
<div class="autocomplete-category">
${data.value.type}
</span>`
</div>`

const $tokenIconContainer = $(item).find(`#token-icon-${data.value.address_hash}`)
const $searchInput = $('#main-search-autocomplete')
const chainID = $searchInput.data('chain-id')
const displayTokenIcons = $searchInput.data('display-token-icons')
appendTokenIcon($tokenIconContainer, chainID, data.value.address_hash, data.value.foreign_chain_id, data.value.foreign_token_hash, displayTokenIcons, 15)
}
const config = (id) => {
return {
Expand Down
7 changes: 5 additions & 2 deletions apps/block_scout_web/assets/js/lib/smart_contract/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ function getTxValue ($functionInputs) {
const WEI_MULTIPLIER = 10 ** 18
const $txValue = $functionInputs.filter('[tx-value]:first')
const txValue = $txValue && $txValue.val() && parseFloat($txValue.val()) * WEI_MULTIPLIER
const txValueStr = txValue && txValue.toString(16)
return txValueStr
var txValueStr = txValue && txValue.toString(16)
if (!txValueStr) {
txValueStr = '0'
}
return '0x' + txValueStr
}
59 changes: 59 additions & 0 deletions apps/block_scout_web/assets/js/lib/token_icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function getTokenIconUrl (chainID, addressHash) {
var chainName = null
switch (chainID) {
case '1':
chainName = 'ethereum'
break
case '99':
chainName = 'poa'
break
case '100':
chainName = 'xdai'
break
default:
chainName = null
break
}
if (chainName) {
return `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${chainName}/assets/${addressHash}/logo.png`
} else {
return null
}
}

function appendTokenIcon ($tokenIconContainer, chainID, addressHash, foreignChainID, foreignAddressHash, displayTokenIcons, size) {
const iconSize = size || 20
var tokenIconURL = null
if (foreignChainID) {
tokenIconURL = getTokenIconUrl(foreignChainID.toString(), foreignAddressHash)
} else if (chainID) {
tokenIconURL = getTokenIconUrl(chainID.toString(), addressHash)
}
if (displayTokenIcons) {
checkLink(tokenIconURL)
.then(checkTokenIconLink => {
if (checkTokenIconLink) {
if ($tokenIconContainer) {
var img = new Image(iconSize, iconSize)
img.src = tokenIconURL
$tokenIconContainer.append(img)
}
}
})
}
}

async function checkLink (url) {
if (url) {
try {
const res = await fetch(url)
return res.ok
} catch (_error) {
return false
}
} else {
return false
}
}

export { appendTokenIcon, checkLink, getTokenIconUrl }
6 changes: 4 additions & 2 deletions apps/block_scout_web/assets/js/pages/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ export function reducer (state = initialState, action) {

let fetchedTokenBalanceBlockNumber = 0
function loadTokenBalance (blockNumber) {
if (blockNumber >= fetchedTokenBalanceBlockNumber) {
if (blockNumber > fetchedTokenBalanceBlockNumber) {
fetchedTokenBalanceBlockNumber = blockNumber
setTimeout(loadTokenBalanceDropdown, 1000)
} else if (fetchedTokenBalanceBlockNumber === 0 && blockNumber === null) {
setTimeout(loadTokenBalanceDropdown, 1000)
}
}

Expand All @@ -94,7 +96,7 @@ const elements = {
return { balanceCard: $el.html(), balance: parseFloat($el.find('.current-balance-in-wei').attr('data-wei-value')) }
},
render ($el, state, oldState) {
if (oldState.balance === state.balance || isNaN(state.balance)) return
if (oldState.balance === state.balance || (isNaN(oldState.balance) && isNaN(state.balance))) return
$el.empty().append(state.balanceCard)
loadTokenBalance(state.fetchedCoinBalanceBlockNumber)
updateAllCalculatedUsdValues()
Expand Down
13 changes: 13 additions & 0 deletions apps/block_scout_web/assets/js/pages/token/overview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import $ from 'jquery'
import { appendTokenIcon } from '../../lib/token_icon'

if ($('[data-page="token-details"]').length) {
const $tokenIconContainer = $('#token-icon')
const chainID = $tokenIconContainer.data('chain-id')
const addressHash = $tokenIconContainer.data('address-hash')
const foreignChainID = $tokenIconContainer.data('foreign-chain-id')
const foreignAddressHash = $tokenIconContainer.data('foreign-address-hash')
const displayTokenIcons = $tokenIconContainer.data('display-token-icons')

appendTokenIcon($tokenIconContainer, chainID, addressHash, foreignChainID, foreignAddressHash, displayTokenIcons)
}
6 changes: 3 additions & 3 deletions apps/block_scout_web/assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion apps/block_scout_web/assets/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ const appJs =
'text_ad': './js/lib/text_ad.js',
'banner': './js/lib/banner.js',
'autocomplete': './js/lib/autocomplete.js',
'search-results': './js/pages/search-results/search.js'
'search-results': './js/pages/search-results/search.js',
'token-overview': './js/pages/token/overview.js'
},
output: {
filename: '[name].js',
Expand Down
Loading

0 comments on commit 5900c7c

Please sign in to comment.