Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W37 upstream merge #396

Merged
merged 64 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a8df0a5
Fix NaN input in write contract
nikitosing Aug 30, 2021
1b08186
Merge pull request #4582 from blockscout/np-fix-nan-error-write-cntrct
vbaranov Aug 30, 2021
16a9249
Search results page: navbar menu fix
vbaranov Aug 30, 2021
801de6c
Merge pull request #4587 from blockscout/vb-search-navbar-menu-fix
vbaranov Aug 30, 2021
7deabed
Resize inputs; improve multiplier selector; add tooltip for tx value;…
nikitosing Aug 29, 2021
14e0033
Fix floating tooltips on token transfer block
nikitosing Aug 30, 2021
bec33a2
Merge pull request #4586 from blockscout/np-fix-floating-tooltips
vbaranov Aug 30, 2021
d73f310
Merge pull request #4579 from blockscout/np-fix-input-fields-write-co…
vbaranov Aug 30, 2021
541febb
Fix solid outputs on contract read page
nikitosing Aug 31, 2021
1eb7af4
Add step and min value for txValue input
nikitosing Aug 31, 2021
f9f35ba
Add status to Position pane
nikitosing Sep 1, 2021
a127155
Merge pull request #4591 from blockscout/np-add-step-and-min-args
vbaranov Sep 1, 2021
d8caa6d
Merge branch 'master' into np-fix-solid-contract-outputs
vbaranov Sep 1, 2021
84b57aa
Merge pull request #4589 from blockscout/np-fix-solid-contract-outputs
vbaranov Sep 1, 2021
928c3fc
Merge pull request #4593 from blockscout/np-add-status-for-pending-txs
vbaranov Sep 1, 2021
a1bc250
Add support EIP-1559
nikitosing Aug 12, 2021
e50f66b
Merge pull request #4520 from blockscout/1559-support
vbaranov Sep 2, 2021
a84de99
Update CHANGELOG.md
nikitosing Sep 2, 2021
3e7e113
Merge pull request #4598 from blockscout/nikitosing-patch-1
vbaranov Sep 2, 2021
5afb2b6
Change key to update cache GA
nikitosing Sep 2, 2021
7282a77
Merge pull request #4599 from blockscout/np-pr-for-pass-tests-1
vbaranov Sep 2, 2021
882830f
Change key back to update cache GA
nikitosing Sep 2, 2021
e961eee
Merge pull request #4600 from blockscout/np-pr-for-pass-tests-2
vbaranov Sep 2, 2021
24a5b1a
Fix endless Fetching tokens message on emty addresses
vbaranov Sep 2, 2021
2023b2b
Merge pull request #4601 from blockscout/vb-fix-endless-fetching-tokens
vbaranov Sep 2, 2021
0e2e1e1
Change keys of cache for update GA
nikitosing Sep 2, 2021
110e6f7
Merge pull request #4602 from blockscout/np-upd-keys-ga
vbaranov Sep 2, 2021
8ff386a
Add tooltips and names for fallback and receive functions
nikitosing Aug 31, 2021
fded776
Merge pull request #4592 from blockscout/np-fix-empty-function-names
vbaranov Sep 3, 2021
e9e7fa4
Ability to hide miner
vbaranov Sep 7, 2021
b230b4b
Merge pull request #4611 from blockscout/vb-hide-miner
vbaranov Sep 7, 2021
0a5377b
Improved style of transactions button
nikitosing Sep 6, 2021
ef321e5
Add token_tile_view_more.css to the main-page.css
nikitosing Sep 8, 2021
09acd33
Merge pull request #4608 from blockscout/np-change-txs-button
vbaranov Sep 8, 2021
ad67d53
Merge pull request #4615 from blockscout/np-fix-css-main-page
vbaranov Sep 8, 2021
82a8e26
Display token icons for tokens from TrustWallet repo
vbaranov Sep 2, 2021
bb29bda
token icon for bridged tokens in search results page fix
vbaranov Sep 9, 2021
553efba
Merge pull request #4596 from blockscout/vb-token-icon-bridged-with-m…
vbaranov Sep 9, 2021
8eac719
Hide error selector in the contract's functions list
nikitosing Sep 7, 2021
321729d
Merge pull request #4612 from blockscout/np-remove-error-selector
vbaranov Sep 9, 2021
c57e1d3
Change alpha of transactions button's background
nikitosing Sep 9, 2021
5d96530
Merge pull request #4622 from blockscout/np-change-alpha-for-txs-btn
vbaranov Sep 9, 2021
00dc48e
Support HTML tags in alert message
vbaranov Sep 9, 2021
619296b
Merge pull request #4624 from blockscout/vb-support-html-in-alert
vbaranov Sep 9, 2021
7acbf1a
Add implementation link to the overview of proxy contracts
nikitosing Sep 9, 2021
65456e0
Merge pull request #4625 from blockscout/np-add-implementation-link
vbaranov Sep 10, 2021
40e14d6
W37 upstream merge
Sep 14, 2021
6a8390f
Fixed formatting
Sep 14, 2021
2403764
Merge branch 'master' into carterqw2/w37-upstream-merge
Sep 15, 2021
691c3a7
Merge branch 'master' into carterqw2/w37-upstream-merge
Sep 15, 2021
3e834c9
Merge branch 'master' into carterqw2/w37-upstream-merge
Sep 15, 2021
7a84ca7
Merge branch 'master' into carterqw2/w37-upstream-merge
Sep 20, 2021
39f8782
Remove unused npm packages
Sep 21, 2021
19b64a8
Increased build timeout
Sep 22, 2021
2316ce0
Increased build timeout
Sep 22, 2021
51efd98
More testing
Sep 22, 2021
33ae80e
More testing
Sep 22, 2021
bcca37d
Fixed PR comments
Sep 22, 2021
0732c5f
Replaced more ETH
Sep 22, 2021
b6865e9
Merge branch 'master' into carterqw2/w37-upstream-merge
Sep 23, 2021
d899c10
Merge branch 'master' into carterqw2/w37-upstream-merge
Sep 23, 2021
53d890e
Merge branch 'master' into carterqw2/w37-upstream-merge
Oct 6, 2021
d88d257
Fix gettext
Oct 7, 2021
49436ab
CSP fix: allow only trustwallet assets repo from Github
vbaranov Sep 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird change to the hash key but ok

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`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels weird to host assets on github

} 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