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
93b9dc6f
Commit
93b9dc6f
authored
Sep 19, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test array of tuple
parent
a31fd10b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
txFormat.js
remix-lib/test/txFormat.js
+47
-0
No files found.
remix-lib/test/txFormat.js
View file @
93b9dc6f
...
@@ -184,6 +184,35 @@ tape('test abiEncoderV2', function (t) {
...
@@ -184,6 +184,35 @@ tape('test abiEncoderV2', function (t) {
})
})
})
})
tape
(
'test abiEncoderV2 array of tuple'
,
function
(
t
)
{
t
.
test
(
'(abiEncoderV2)'
,
function
(
st
)
{
/*
{
"685e37ad": "addStructs((uint256,string))",
"e5cb65f9": "addStructs((uint256,string)[])"
}
*/
st
.
plan
(
2
)
var
output
=
compiler
.
compileStandardWrapper
(
compilerInput
(
abiEncoderV2ArrayOfTuple
))
output
=
JSON
.
parse
(
output
)
var
contract
=
output
.
contracts
[
'test.sol'
][
'test'
]
txFormat
.
encodeParams
(
'[34, "test"]'
,
contract
.
abi
[
0
],
(
error
,
encoded
)
=>
{
console
.
log
(
error
)
var
decoded
=
txFormat
.
decodeResponse
(
util
.
hexToIntArray
(
encoded
.
dataHex
),
contract
.
abi
[
0
])
console
.
log
(
decoded
)
st
.
equal
(
decoded
[
0
],
'tuple(uint256,string): _strucmts 34,test'
)
})
txFormat
.
encodeParams
(
'[[34, "test"], [123, "test2"]]'
,
contract
.
abi
[
1
],
(
error
,
encoded
)
=>
{
console
.
log
(
error
)
var
decoded
=
txFormat
.
decodeResponse
(
util
.
hexToIntArray
(
encoded
.
dataHex
),
contract
.
abi
[
1
])
console
.
log
(
decoded
)
st
.
equal
(
decoded
[
0
],
'tuple(uint256,string)[]: strucmts 34,test,123,test2'
)
})
})
})
var
uintContract
=
`contract uintContractTest {
var
uintContract
=
`contract uintContractTest {
uint _tp;
uint _tp;
address _ap;
address _ap;
...
@@ -251,3 +280,21 @@ contract test {
...
@@ -251,3 +280,21 @@ contract test {
return mm;
return mm;
}
}
}`
}`
var
abiEncoderV2ArrayOfTuple
=
`pragma experimental ABIEncoderV2;
contract test {
struct MyStruct {uint256 num; string _string;}
constructor (MyStruct[] _structs, string _str) {
}
function addStructs(MyStruct[] _structs) public returns (MyStruct[] strucmts) {
strucmts = _structs;
}
function addStructs(MyStruct _structs) public returns (MyStruct _strucmts) {
_strucmts = _structs;
}
}`
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