Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #72 from kjhman21/gasfix
Browse files Browse the repository at this point in the history
Gasfix
  • Loading branch information
Junghyun Colin Kim authored Mar 2, 2022
2 parents bab4276 + 6132aa5 commit 8eedd34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

14 changes: 13 additions & 1 deletion src/components/WalletTransfer2.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Props = {

}

const KLAY_GAS_PRICE = caver.utils.toWei('25', 'shannon')
var KLAY_GAS_PRICE = caver.utils.toWei('25', 'shannon')
const DEFAULT_KLAY_TRANSFER_GAS = 100000
const DEFAULT_TOKEN_TRANSFER_GAS = 100000
const MAX_INTEGER_LENGTH = 14
Expand Down Expand Up @@ -57,6 +57,8 @@ class WalletTransfer2 extends Component<Props> {
let klayAccounts = sessionStorage.getItem('address')
klayAccounts = humanReadableChange(klayAccounts)

this.updateGasPrice()

if (caver.klay.accounts.wallet[0]) {
klayAccounts = klayAccounts || caver.klay.accounts.wallet[0].address
}
Expand All @@ -74,6 +76,16 @@ class WalletTransfer2 extends Component<Props> {
}
}

updateGasPrice = async () => {
const gp = await caver.rpc.klay.getGasPrice()
KLAY_GAS_PRICE = caver.utils.toBN(gp).toString()
this.setState({
gasPrice: KLAY_GAS_PRICE,
totalGasFee: caver.utils.fromWei(`${DEFAULT_KLAY_TRANSFER_GAS * KLAY_GAS_PRICE}`) || '',
})
console.log('gas price updated', KLAY_GAS_PRICE)
}

handleChange = (e) => {
const isStartWithZero = (inputValue) => inputValue == '' && e.target.value == '0'
const isNumberStringWithDot = /^\d+(\.)?\d{0,6}$/.test(e.target.value)
Expand Down

0 comments on commit 8eedd34

Please sign in to comment.