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
bdf77eb7
Commit
bdf77eb7
authored
Nov 28, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix string type
parent
7a2324ce
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
19 deletions
+24
-19
StringType.js
src/solidity/types/StringType.js
+10
-9
byteStorage.js
test/solidity/contracts/byteStorage.js
+12
-10
storageDecoder.js
test/solidity/storageDecoder.js
+2
-0
No files found.
src/solidity/types/StringType.js
View file @
bdf77eb7
...
...
@@ -11,17 +11,18 @@ function StringType () {
StringType
.
prototype
.
decodeFromStorage
=
function
(
location
,
storageContent
)
{
var
decoded
=
this
.
dynamicBytes
.
decodeFromStorage
(
location
,
storageContent
)
var
value
=
decoded
.
value
var
ret
=
''
value
=
value
.
replace
(
'0x'
,
''
)
for
(
var
k
=
0
;
k
<
value
.
length
;
k
+=
2
)
{
var
raw
=
value
.
substr
(
k
,
2
)
var
str
=
String
.
fromCharCode
(
parseInt
(
raw
,
16
))
ret
+=
str
value
=
value
.
replace
(
'0x'
,
''
).
replace
(
/
(
..
)
/g
,
'%$1'
)
var
ret
=
{
length
:
decoded
.
length
,
raw
:
decoded
.
value
}
return
{
value
:
ret
,
length
:
decoded
.
length
try
{
ret
.
value
=
decodeURIComponent
(
value
)
}
catch
(
e
)
{
ret
.
error
=
'Invalid UTF8 encoding'
ret
.
raw
=
decoded
.
value
}
return
ret
}
module
.
exports
=
StringType
test/solidity/contracts/byteStorage.js
View file @
bdf77eb7
...
...
@@ -44,6 +44,7 @@ module.exports = {
bytes32 stab32 = hex"324324423432543543AB";
enum1 enumDec = enum1.e240;
string str1 = 'short';
string str12 = 'шеллы';
string str2 = 'long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long';
}
`
,
...
...
@@ -73,15 +74,16 @@ module.exports = {
'0x0000000000000000000000000000000000000000000000000000000000000016'
:
'0x324324423432543543ab00000000000000000000000000000000000000000000'
,
'0x0000000000000000000000000000000000000000000000000000000000000017'
:
'0x00000000000000000000000000000000000000000000000000000000000000f0'
,
'0x0000000000000000000000000000000000000000000000000000000000000018'
:
'0x73686f727400000000000000000000000000000000000000000000000000000a'
,
'0x0000000000000000000000000000000000000000000000000000000000000019'
:
'0x000000000000000000000000000000000000000000000000000000000000023d'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c9695'
:
'0x6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c9696'
:
'0x6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e67'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c9697'
:
'0x5f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c9698'
:
'0x6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c9699'
:
'0x6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e67'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c969a'
:
'0x5f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c969b'
:
'0x6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c969c'
:
'0x6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e67'
,
'0x944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c969d'
:
'0x5f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e670000'
'0x0000000000000000000000000000000000000000000000000000000000000019'
:
'0xd188d0b5d0bbd0bbd18b00000000000000000000000000000000000000000014'
,
'0x000000000000000000000000000000000000000000000000000000000000001a'
:
'0x000000000000000000000000000000000000000000000000000000000000023d'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff63e'
:
'0x6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff63f'
:
'0x6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e67'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff640'
:
'0x5f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff641'
:
'0x6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff642'
:
'0x6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e67'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff643'
:
'0x5f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff644'
:
'0x6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff645'
:
'0x6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e67'
,
'0x057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff646'
:
'0x5f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e675f5f6c6f6e670000'
}
}
test/solidity/storageDecoder.js
View file @
bdf77eb7
...
...
@@ -96,6 +96,7 @@ function testByteStorage (st) {
st
.
equal
(
decoded
[
'stab32'
],
'0x324324423432543543AB00000000000000000000000000000000000000000000'
)
st
.
equal
(
decoded
[
'enumDec'
],
'e240'
)
st
.
equal
(
decoded
[
'str1'
].
value
,
'short'
)
st
.
equal
(
decoded
[
'str12'
].
value
,
'шеллы'
)
st
.
equal
(
decoded
[
'str2'
].
value
,
'long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long'
)
}
...
...
@@ -142,6 +143,7 @@ function testByteStorage (st) {
st
.
equal
(
decoded
[
'str1'
].
length
,
'0x0'
)
st
.
equal
(
decoded
[
'str2'
].
length
,
'0x0'
)
st
.
equal
(
decoded
[
'str1'
].
value
,
''
)
st
.
equal
(
decoded
[
'str12'
].
value
,
''
)
st
.
equal
(
decoded
[
'str2'
].
value
,
''
)
}
...
...
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