Merge pull request #5047 from blockscout/theqp-patch-1

At contract write use wei precision
pull/4861/head
Victor Baranov 3 years ago committed by GitHub
commit cdcba15072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 13
      apps/block_scout_web/assets/js/lib/smart_contract/interact.js

@ -25,6 +25,7 @@
- [#4867](https://github.com/blockscout/blockscout/pull/4867) - Fix bug in quering contracts method and improve contracts interactions - [#4867](https://github.com/blockscout/blockscout/pull/4867) - Fix bug in quering contracts method and improve contracts interactions
### Chore ### Chore
- [#5047](https://github.com/blockscout/blockscout/pull/5047) - At contract write use wei precision
- [#5023](https://github.com/blockscout/blockscout/pull/5023) - Capability to leave an empty logo - [#5023](https://github.com/blockscout/blockscout/pull/5023) - Capability to leave an empty logo
- [#5018](https://github.com/blockscout/blockscout/pull/5018) - Resolve npm vulnerabilities via npm audix fix - [#5018](https://github.com/blockscout/blockscout/pull/5018) - Resolve npm vulnerabilities via npm audix fix
- [#5014](https://github.com/blockscout/blockscout/pull/5014) - Separate FIRST_BLOCK and TRACE_FIRST_BLOCK option for blocks import and tracing methods - [#5014](https://github.com/blockscout/blockscout/pull/5014) - Separate FIRST_BLOCK and TRACE_FIRST_BLOCK option for blocks import and tracing methods

@ -1,6 +1,7 @@
import $ from 'jquery' import $ from 'jquery'
import { openErrorModal, openWarningModal, openSuccessModal, openModalWithMessage } from '../modals' import { openErrorModal, openWarningModal, openSuccessModal, openModalWithMessage } from '../modals'
import { compareChainIDs, formatError, formatTitleAndError, getContractABI, getCurrentAccountPromise, getMethodInputs, prepareMethodArgs } from './common_helpers' import { compareChainIDs, formatError, formatTitleAndError, getContractABI, getCurrentAccountPromise, getMethodInputs, prepareMethodArgs } from './common_helpers'
import BigNumber from 'bignumber.js'
export const queryMethod = (isWalletEnabled, url, $methodId, args, type, functionName, $responseContainer) => { export const queryMethod = (isWalletEnabled, url, $methodId, args, type, functionName, $responseContainer) => {
let data = { let data = {
@ -104,13 +105,9 @@ function onTransactionHash (txHash, $element, functionName) {
const txReceiptPollingIntervalId = setInterval(() => { getTxReceipt(txHash) }, 5 * 1000) const txReceiptPollingIntervalId = setInterval(() => { getTxReceipt(txHash) }, 5 * 1000)
} }
const ethStrToWeiBn = ethStr => BigNumber(ethStr).multipliedBy(10 ** 18)
function getTxValue ($functionInputs) { function getTxValue ($functionInputs) {
const WEI_MULTIPLIER = 10 ** 18 const txValueEth = $functionInputs.filter('[tx-value]:first')?.val() || '0'
const $txValue = $functionInputs.filter('[tx-value]:first') return `0x${ethStrToWeiBn(txValueEth).toString(16)}`
const txValue = $txValue && $txValue.val() && parseFloat($txValue.val()) * WEI_MULTIPLIER
let txValueStr = txValue && txValue.toString(16)
if (!txValueStr) {
txValueStr = '0'
}
return '0x' + txValueStr
} }

Loading…
Cancel
Save