Fix call to fallback function and call of GnosisProxy contract methods

pull/3477/head
Victor Baranov 4 years ago
parent 3c80a04821
commit 7a72b121c5
  1. 2
      CHANGELOG.md
  2. 30
      apps/block_scout_web/assets/js/lib/smart_contract/functions.js
  3. 3
      apps/explorer/lib/explorer/chain.ex

@ -4,6 +4,8 @@
- [#3462](https://github.com/poanetwork/blockscout/pull/3462) - Display price for bridged tokens
### Fixes
- [#3477](https://github.com/poanetwork/blockscout/pull/3477) - Contracts interaction: fix broken call of GnosisProxy contract methods with parameters
- [#3477](https://github.com/poanetwork/blockscout/pull/3477) - Contracts interaction: fix broken call of fallback function
- [#3476](https://github.com/poanetwork/blockscout/pull/3476) - Fix contract verification of precompiled contracts
- [#3467](https://github.com/poanetwork/blockscout/pull/3467) - Fix Firefox styles
- [#3464](https://github.com/poanetwork/blockscout/pull/3464) - Fix display of token transfers list at token page (fix unique identifier of a tile)

@ -133,30 +133,33 @@ function callMethod (isWalletEnabled, $functionInputs, explorerChainId, $form, f
const { chainId: walletChainIdHex } = window.ethereum
compareChainIDs(explorerChainId, walletChainIdHex)
.then(currentAccount => {
let methodToCall
if (functionName) {
const TargetContract = new window.web3.eth.Contract(contractAbi, contractAddress)
methodToCall = TargetContract.methods[functionName](...args).send({ from: currentAccount, value: txValue || 0 })
const methodToCall = TargetContract.methods[functionName](...args).send({ from: currentAccount, value: txValue || 0 })
methodToCall
.on('error', function (error) {
openErrorModal(`Error in sending transaction for method "${functionName}"`, formatError(error), false)
})
.on('transactionHash', function (txHash) {
onTransactionHash(txHash, $element, functionName)
})
} else {
const txParams = {
from: currentAccount,
to: contractAddress,
value: txValue || 0
}
methodToCall = window.ethereum.request({
window.ethereum.request({
method: 'eth_sendTransaction',
params: [txParams]
})
.then(function (txHash) {
onTransactionHash(txHash, $element, functionName)
})
.catch(function (error) {
openErrorModal('Error in sending transaction for fallback method', formatError(error), false)
})
}
methodToCall
.on('error', function (error) {
openErrorModal(`Error in sending transaction for method "${functionName}"`, formatError(error), false)
})
.on('transactionHash', function (txHash) {
onTransactionHash(txHash, $element, functionName)
})
})
.catch(error => {
openWarningModal('Unauthorized', formatError(error))
@ -167,7 +170,8 @@ 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
return txValue
const txValueStr = txValue && txValue.toString(16)
return txValueStr
}
function getContractABI ($form) {

@ -5525,7 +5525,8 @@ defmodule Explorer.Chain do
implementation_method_abi =
abi
|> Enum.find(fn method ->
Map.get(method, "name") == "implementation"
Map.get(method, "name") == "implementation" ||
master_copy_pattern?(method)
end)
if implementation_method_abi do

Loading…
Cancel
Save