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
e24d28c8
Commit
e24d28c8
authored
Nov 24, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix int, uint
parent
aec6f8c9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
21 deletions
+13
-21
Int.js
src/solidity/types/Int.js
+1
-1
Uint.js
src/solidity/types/Uint.js
+1
-1
util.js
src/solidity/types/util.js
+3
-1
intStorage.js
test/solidity/contracts/intStorage.js
+4
-16
storageDecoder.js
test/solidity/storageDecoder.js
+4
-2
No files found.
src/solidity/types/Int.js
View file @
e24d28c8
...
...
@@ -8,7 +8,7 @@ function Int (storageBytes) {
}
Int
.
prototype
.
decodeFromStorage
=
function
(
location
,
storageContent
)
{
return
util
.
decodeInt
(
location
,
storageContent
,
this
.
storageBytes
)
return
util
.
decodeInt
(
location
,
storageContent
,
this
.
storageBytes
,
true
)
}
module
.
exports
=
Int
src/solidity/types/Uint.js
View file @
e24d28c8
...
...
@@ -10,7 +10,7 @@ function Uint (storageBytes) {
}
Uint
.
prototype
.
decodeFromStorage
=
function
(
location
,
storageContent
)
{
return
util
.
decodeInt
(
location
,
storageContent
,
this
.
storageBytes
)
return
util
.
decodeInt
(
location
,
storageContent
,
this
.
storageBytes
,
false
)
}
module
.
exports
=
Uint
src/solidity/types/util.js
View file @
e24d28c8
...
...
@@ -8,14 +8,16 @@ module.exports = {
decodeInt
:
decodeInt
}
function
decodeInt
(
location
,
storageContent
,
byteLength
)
{
function
decodeInt
(
location
,
storageContent
,
byteLength
,
signed
)
{
var
slotvalue
=
extractSlotValue
(
location
.
slot
,
storageContent
)
if
(
slotvalue
===
null
)
{
return
'0'
}
var
value
=
extractHexByteSlice
(
slotvalue
,
byteLength
,
location
.
offset
)
var
bigNumber
=
new
BN
(
value
,
16
)
if
(
signed
)
{
bigNumber
=
bigNumber
.
fromTwos
(
8
*
byteLength
)
}
return
bigNumber
.
toString
(
10
)
}
...
...
test/solidity/contracts/intStorage.js
View file @
e24d28c8
...
...
@@ -3,12 +3,12 @@
module
.
exports
=
{
contract
:
`
contract intStorage {
uint8 ui8 = 1
23
;
uint8 ui8 = 1
30
;
uint16 ui16 = 456;
uint32 ui32 = 4356;
uint64 ui64 = 3543543543;
uint128 ui128 = 234567;
uint256
ui256 = 234566666656
;
uint256
public ui256 = 115792089237316195423570985008687907853269984665640564039457584007880697216513
;
uint ui = 123545666;
int8 i8 = -45;
int16 i16 = -1234;
...
...
@@ -18,27 +18,15 @@ module.exports = {
int256 i256 = 3434343;
int i = -32432423423;
int32 ishrink = 2;
function intStorage () {
}
}
`
,
fullStorage
:
{
'0x0000000000000000000000000000000000000000000000000000000000000000'
:
'0x000000000000000000000000000003944700000000d3362ef70000110401c8
7b
'
,
'0x0000000000000000000000000000000000000000000000000000000000000001'
:
'0x
000000000000000000000000000000000000000000000000000000369d4349a0
'
,
'0x0000000000000000000000000000000000000000000000000000000000000000'
:
'0x000000000000000000000000000003944700000000d3362ef70000110401c8
82
'
,
'0x0000000000000000000000000000000000000000000000000000000000000001'
:
'0x
fffffffffffffffffffffffffffffffffffffffffffffffffffffff872e07e01
'
,
'0x0000000000000000000000000000000000000000000000000000000000000002'
:
'0x00000000000000000000000000000000000000000000000000000000075d2842'
,
'0x0000000000000000000000000000000000000000000000000000000000000003'
:
'0x00fffffffffffffffffffffffffff937e4ffffffffffff751200000d7ffb2ed3'
,
'0x0000000000000000000000000000000000000000000000000000000000000004'
:
'0x0000000000000000000000000000000000000000000000000000000000346767'
,
'0x0000000000000000000000000000000000000000000000000000000000000005'
:
'0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff872e07e01'
,
'0x0000000000000000000000000000000000000000000000000000000000000006'
:
'0x0000000000000000000000000000000000000000000000000000000000000002'
},
shrinkedStorage
:
{
'0x00'
:
'0x03944700000000d3362ef70000110401c87b'
,
'0x01'
:
'0x369d4349a0'
,
'0x02'
:
'0x075d2842'
,
'0x03'
:
'0xfffffffffffffffffffffffffff937e4ffffffffffff751200000d7ffb2ed3'
,
'0x04'
:
'0x346767'
,
'0x05'
:
'0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff872e07e01'
,
'0x06'
:
'0x02'
}
}
test/solidity/storageDecoder.js
View file @
e24d28c8
...
...
@@ -13,12 +13,12 @@ function testIntStorage (st) {
var
intStorage
=
require
(
'./contracts/intStorage'
)
var
output
=
compiler
.
compile
(
intStorage
.
contract
,
0
)
var
decoded
=
stateDecoder
.
solidityState
(
intStorage
.
fullStorage
,
output
.
sources
,
'intStorage'
)
st
.
equal
(
decoded
[
'ui8'
],
'1
23
'
)
st
.
equal
(
decoded
[
'ui8'
],
'1
30
'
)
st
.
equal
(
decoded
[
'ui16'
],
'456'
)
st
.
equal
(
decoded
[
'ui32'
],
'4356'
)
st
.
equal
(
decoded
[
'ui64'
],
'3543543543'
)
st
.
equal
(
decoded
[
'ui128'
],
'234567'
)
st
.
equal
(
decoded
[
'ui256'
],
'
234566666656
'
)
st
.
equal
(
decoded
[
'ui256'
],
'
115792089237316195423570985008687907853269984665640564039457584007880697216513
'
)
st
.
equal
(
decoded
[
'ui'
],
'123545666'
)
st
.
equal
(
decoded
[
'i8'
],
'-45'
)
st
.
equal
(
decoded
[
'i16'
],
'-1234'
)
...
...
@@ -29,6 +29,7 @@ function testIntStorage (st) {
st
.
equal
(
decoded
[
'i'
],
'-32432423423'
)
st
.
equal
(
decoded
[
'ishrink'
],
'2'
)
/*
decoded = stateDecoder.solidityState(intStorage.shrinkedStorage, output.sources, 'intStorage')
st.equal(decoded['ui8'], '123')
st.equal(decoded['ui16'], '456')
...
...
@@ -45,6 +46,7 @@ function testIntStorage (st) {
st.equal(decoded['i256'], '3434343')
st.equal(decoded['i'], '-32432423423')
st.equal(decoded['ishrink'], '2')
*/
decoded
=
stateDecoder
.
solidityState
({},
output
.
sources
,
'intStorage'
)
st
.
equal
(
decoded
[
'ui8'
],
'0'
)
...
...
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