|
|
|
@ -1,3 +1,4 @@ |
|
|
|
|
import { BN } from 'ethereumjs-util' |
|
|
|
|
const $ = require('jquery') |
|
|
|
|
const yo = require('yo-yo') |
|
|
|
|
const remixLib = require('@remix-project/remix-lib') |
|
|
|
@ -65,14 +66,26 @@ class SettingsUI { |
|
|
|
|
|
|
|
|
|
validateValue () { |
|
|
|
|
const valueEl = this.el.querySelector('#value') |
|
|
|
|
valueEl.value = parseInt(valueEl.value) |
|
|
|
|
if (!valueEl.value) { |
|
|
|
|
// assign 0 if given value is
|
|
|
|
|
// - empty
|
|
|
|
|
valueEl.value = 0 |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let v |
|
|
|
|
try { |
|
|
|
|
v = new BN(valueEl.value, 10) |
|
|
|
|
valueEl.value = v.toString(10) |
|
|
|
|
} catch (e) { |
|
|
|
|
// assign 0 if given value is
|
|
|
|
|
// - not valid (for ex 4345-54)
|
|
|
|
|
// - contains only '0's (for ex 0000) copy past or edit
|
|
|
|
|
if (!valueEl.value) valueEl.value = 0 |
|
|
|
|
valueEl.value = 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if giveen value is negative(possible with copy-pasting) set to 0
|
|
|
|
|
if (valueEl.value < 0) valueEl.value = 0 |
|
|
|
|
if (v.lt(0)) valueEl.value = 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
|