Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
f8be36a5
Unverified
Commit
f8be36a5
authored
May 17, 2021
by
yann300
Committed by
GitHub
May 17, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1174 from ethereum/yann300-patch-32
Validate input using BigNumber
parents
816df569
47be8b01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
settings.js
apps/remix-ide/src/app/tabs/runTab/settings.js
+20
-7
txRunner.ts
libs/remix-lib/src/execution/txRunner.ts
+11
-1
No files found.
apps/remix-ide/src/app/tabs/runTab/settings.js
View file @
f8be36a5
import
{
BN
}
from
'ethereumjs-util'
const
$
=
require
(
'jquery'
)
const
$
=
require
(
'jquery'
)
const
yo
=
require
(
'yo-yo'
)
const
yo
=
require
(
'yo-yo'
)
const
remixLib
=
require
(
'@remix-project/remix-lib'
)
const
remixLib
=
require
(
'@remix-project/remix-lib'
)
...
@@ -65,14 +66,26 @@ class SettingsUI {
...
@@ -65,14 +66,26 @@ class SettingsUI {
validateValue
()
{
validateValue
()
{
const
valueEl
=
this
.
el
.
querySelector
(
'#value'
)
const
valueEl
=
this
.
el
.
querySelector
(
'#value'
)
valueEl
.
value
=
parseInt
(
valueEl
.
value
)
if
(
!
valueEl
.
value
)
{
// assign 0 if given value is
// assign 0 if given value is
// - empty
// - empty
// - not valid (for ex 4345-54)
valueEl
.
value
=
0
// - contains only '0's (for ex 0000) copy past or edit
return
if
(
!
valueEl
.
value
)
valueEl
.
value
=
0
}
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
valueEl
.
value
=
0
}
// if giveen value is negative(possible with copy-pasting) set to 0
// if giveen value is negative(possible with copy-pasting) set to 0
if
(
v
alueEl
.
value
<
0
)
valueEl
.
value
=
0
if
(
v
.
lt
(
0
)
)
valueEl
.
value
=
0
}
}
render
()
{
render
()
{
...
...
libs/remix-lib/src/execution/txRunner.ts
View file @
f8be36a5
...
@@ -118,7 +118,17 @@ export class TxRunner {
...
@@ -118,7 +118,17 @@ export class TxRunner {
this
.
executionContext
.
vm
().
stateManager
.
getAccount
(
Address
.
fromString
(
from
)).
then
((
res
)
=>
{
this
.
executionContext
.
vm
().
stateManager
.
getAccount
(
Address
.
fromString
(
from
)).
then
((
res
)
=>
{
// See https://github.com/ethereumjs/ethereumjs-tx/blob/master/docs/classes/transaction.md#constructor
// See https://github.com/ethereumjs/ethereumjs-tx/blob/master/docs/classes/transaction.md#constructor
// for initialization fields and their types
// for initialization fields and their types
value
=
value
?
parseInt
(
value
)
:
0
if
(
!
value
)
value
=
0
if
(
typeof
value
===
'string'
)
{
if
(
value
.
startsWith
(
'0x'
))
value
=
new
BN
(
value
.
replace
(
'0x'
,
''
),
'hex'
)
else
{
try
{
value
=
new
BN
(
value
,
10
)
}
catch
(
e
)
{
return
callback
(
'Unable to parse the value '
+
e
.
message
)
}
}
}
const
tx
=
Transaction
.
fromTxData
({
const
tx
=
Transaction
.
fromTxData
({
nonce
:
new
BN
(
res
.
nonce
),
nonce
:
new
BN
(
res
.
nonce
),
gasPrice
:
'0x1'
,
gasPrice
:
'0x1'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment