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
eb76cbb8
Commit
eb76cbb8
authored
Sep 17, 2019
by
aniket-engg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string with comma handled
parent
30719524
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
5 deletions
+32
-5
txFormat.js
remix-lib/src/execution/txFormat.js
+27
-4
txFormat.js
remix-lib/test/txFormat.js
+5
-1
tasks.todo
tasks.todo
+0
-0
No files found.
remix-lib/src/execution/txFormat.js
View file @
eb76cbb8
...
...
@@ -169,7 +169,7 @@ module.exports = {
* @param {Function} callbackDeployLibrary - callbackDeployLibrary
*/
buildData
:
function
(
contractName
,
contract
,
contracts
,
isConstructor
,
funAbi
,
params
,
callback
,
callbackStep
,
callbackDeployLibrary
)
{
var
funArgs
=
''
var
funArgs
=
[]
var
data
=
''
var
dataHex
=
''
...
...
@@ -179,9 +179,32 @@ module.exports = {
data
=
Buffer
.
from
(
dataHex
,
'hex'
)
}
else
{
try
{
params
=
params
.
replace
(
/
(
^|,
\s
+|,
)(\d
+
)(\s
+,|,|$
)
/g
,
'$1"$2"$3'
)
// replace non quoted number by quoted number
params
=
params
.
replace
(
/
(
^|,
\s
+|,
)(
0
[
xX
][
0-9a-fA-F
]
+
)(\s
+,|,|$
)
/g
,
'$1"$2"$3'
)
// replace non quoted hex string by quoted hex string
funArgs
=
JSON
.
parse
(
'['
+
params
+
']'
)
if
(
params
.
length
>
0
)
{
params
=
params
.
split
(
','
)
for
(
let
i
=
0
;
i
<
params
.
length
;
i
++
)
{
let
param
=
params
[
i
].
trim
()
if
(
param
.
charAt
(
0
)
===
'"'
)
{
if
(
param
.
charAt
(
param
.
length
-
1
)
===
'"'
)
{
funArgs
.
push
(
param
.
slice
(
1
,
param
.
length
-
1
))
}
else
{
let
lastIndex
=
false
let
paramStr
=
param
.
slice
(
1
,
param
.
length
)
for
(
let
j
=
i
+
1
;
!
lastIndex
;
j
++
)
{
if
(
params
[
j
].
charAt
(
params
[
j
].
length
-
1
)
===
'"'
)
{
paramStr
+=
','
+
params
[
j
].
slice
(
0
,
params
[
j
].
length
-
1
)
i
=
j
funArgs
.
push
(
paramStr
)
lastIndex
=
true
}
else
{
paramStr
+=
','
+
params
[
j
]
}
}
}
}
else
{
funArgs
.
push
(
param
)
}
}
}
}
catch
(
e
)
{
callback
(
'Error encoding arguments: '
+
e
)
return
...
...
remix-lib/test/txFormat.js
View file @
eb76cbb8
...
...
@@ -35,8 +35,12 @@ tape('ContractParameters - (TxFormat.buildData) - format input parameters', func
})
function
testWithInput
(
st
,
params
,
expected
)
{
console
.
log
(
'params-----'
,
params
)
txFormat
.
buildData
(
'uintContractTest'
,
context
.
contract
,
context
.
output
.
contracts
,
true
,
context
.
contract
.
abi
[
0
],
params
,
(
error
,
data
)
=>
{
if
(
error
)
{
return
st
.
fails
(
error
)
}
if
(
error
)
{
console
.
log
(
'------'
,
error
)
return
st
.
fails
(
error
)
}
console
.
log
(
data
)
if
(
!
data
.
dataHex
.
endsWith
(
expected
))
{
st
.
fail
(
`result of buildData
${
data
.
dataHex
}
should end with
${
expected
}
. `
)
...
...
remix-analyzer/
tasks.todo
→
tasks.todo
View file @
eb76cbb8
File moved
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