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
9fc2291d
Commit
9fc2291d
authored
Dec 14, 2020
by
aniket-engg
Committed by
Aniket
Dec 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solidity decoder types updated
parent
1b097bc6
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
42 additions
and
56 deletions
+42
-56
Address.ts
libs/remix-debug/src/solidity-decoder/types/Address.ts
+1
-3
ArrayType.ts
libs/remix-debug/src/solidity-decoder/types/ArrayType.ts
+1
-3
Bool.ts
libs/remix-debug/src/solidity-decoder/types/Bool.ts
+1
-3
DynamicByteArray.ts
...emix-debug/src/solidity-decoder/types/DynamicByteArray.ts
+1
-2
Enum.ts
libs/remix-debug/src/solidity-decoder/types/Enum.ts
+1
-3
FixedByteArray.ts
.../remix-debug/src/solidity-decoder/types/FixedByteArray.ts
+1
-3
Int.ts
libs/remix-debug/src/solidity-decoder/types/Int.ts
+1
-3
Mapping.ts
libs/remix-debug/src/solidity-decoder/types/Mapping.ts
+1
-3
RefType.ts
libs/remix-debug/src/solidity-decoder/types/RefType.ts
+8
-3
StringType.ts
libs/remix-debug/src/solidity-decoder/types/StringType.ts
+3
-5
Struct.ts
libs/remix-debug/src/solidity-decoder/types/Struct.ts
+1
-3
Uint.ts
libs/remix-debug/src/solidity-decoder/types/Uint.ts
+1
-3
ValueType.ts
libs/remix-debug/src/solidity-decoder/types/ValueType.ts
+7
-1
util.ts
libs/remix-debug/src/solidity-decoder/types/util.ts
+14
-18
No files found.
libs/remix-debug/src/solidity-decoder/types/Address.ts
View file @
9fc2291d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
const
util
=
require
(
'./util'
)
const
util
=
require
(
'./util'
)
const
ValueType
=
require
(
'./ValueType'
)
const
ValueType
=
require
(
'./ValueType'
)
class
Address
extends
ValueType
{
export
class
Address
extends
ValueType
{
constructor
()
{
constructor
()
{
super
(
1
,
20
,
'address'
)
super
(
1
,
20
,
'address'
)
}
}
...
@@ -14,5 +14,3 @@ class Address extends ValueType {
...
@@ -14,5 +14,3 @@ class Address extends ValueType {
return
'0x'
+
util
.
extractHexByteSlice
(
value
,
this
.
storageBytes
,
0
).
toUpperCase
()
return
'0x'
+
util
.
extractHexByteSlice
(
value
,
this
.
storageBytes
,
0
).
toUpperCase
()
}
}
}
}
module
.
exports
=
Address
libs/remix-debug/src/solidity-decoder/types/ArrayType.ts
View file @
9fc2291d
...
@@ -5,7 +5,7 @@ const sha3256 = remixLib.util.sha3_256
...
@@ -5,7 +5,7 @@ const sha3256 = remixLib.util.sha3_256
const
BN
=
require
(
'ethereumjs-util'
).
BN
const
BN
=
require
(
'ethereumjs-util'
).
BN
const
RefType
=
require
(
'./RefType'
)
const
RefType
=
require
(
'./RefType'
)
class
ArrayType
extends
RefType
{
export
class
ArrayType
extends
RefType
{
constructor
(
underlyingType
,
arraySize
,
location
)
{
constructor
(
underlyingType
,
arraySize
,
location
)
{
let
storageSlots
=
null
let
storageSlots
=
null
...
@@ -104,5 +104,3 @@ class ArrayType extends RefType {
...
@@ -104,5 +104,3 @@ class ArrayType extends RefType {
}
}
}
}
}
}
module
.
exports
=
ArrayType
libs/remix-debug/src/solidity-decoder/types/Bool.ts
View file @
9fc2291d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
const
ValueType
=
require
(
'./ValueType'
)
const
ValueType
=
require
(
'./ValueType'
)
const
util
=
require
(
'./util'
)
const
util
=
require
(
'./util'
)
class
Bool
extends
ValueType
{
export
class
Bool
extends
ValueType
{
constructor
()
{
constructor
()
{
super
(
1
,
1
,
'bool'
)
super
(
1
,
1
,
'bool'
)
}
}
...
@@ -15,5 +15,3 @@ class Bool extends ValueType {
...
@@ -15,5 +15,3 @@ class Bool extends ValueType {
return
value
!==
'00'
return
value
!==
'00'
}
}
}
}
module
.
exports
=
Bool
libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts
View file @
9fc2291d
...
@@ -5,7 +5,7 @@ const sha3256 = remixLib.util.sha3_256
...
@@ -5,7 +5,7 @@ const sha3256 = remixLib.util.sha3_256
const
BN
=
require
(
'ethereumjs-util'
).
BN
const
BN
=
require
(
'ethereumjs-util'
).
BN
const
RefType
=
require
(
'./RefType'
)
const
RefType
=
require
(
'./RefType'
)
class
DynamicByteArray
extends
RefType
{
export
class
DynamicByteArray
extends
RefType
{
constructor
(
location
)
{
constructor
(
location
)
{
super
(
1
,
32
,
'bytes'
,
location
)
super
(
1
,
32
,
'bytes'
,
location
)
}
}
...
@@ -56,4 +56,3 @@ class DynamicByteArray extends RefType {
...
@@ -56,4 +56,3 @@ class DynamicByteArray extends RefType {
}
}
}
}
module
.
exports
=
DynamicByteArray
libs/remix-debug/src/solidity-decoder/types/Enum.ts
View file @
9fc2291d
'use strict'
'use strict'
const
ValueType
=
require
(
'./ValueType'
)
const
ValueType
=
require
(
'./ValueType'
)
class
Enum
extends
ValueType
{
export
class
Enum
extends
ValueType
{
constructor
(
enumDef
)
{
constructor
(
enumDef
)
{
let
storageBytes
=
0
let
storageBytes
=
0
let
length
=
enumDef
.
members
.
length
let
length
=
enumDef
.
members
.
length
...
@@ -24,5 +24,3 @@ class Enum extends ValueType {
...
@@ -24,5 +24,3 @@ class Enum extends ValueType {
return
'INVALID_ENUM<'
+
value
+
'>'
return
'INVALID_ENUM<'
+
value
+
'>'
}
}
}
}
module
.
exports
=
Enum
libs/remix-debug/src/solidity-decoder/types/FixedByteArray.ts
View file @
9fc2291d
'use strict'
'use strict'
const
ValueType
=
require
(
'./ValueType'
)
const
ValueType
=
require
(
'./ValueType'
)
class
FixedByteArray
extends
ValueType
{
export
class
FixedByteArray
extends
ValueType
{
constructor
(
storageBytes
)
{
constructor
(
storageBytes
)
{
super
(
1
,
storageBytes
,
'bytes'
+
storageBytes
)
super
(
1
,
storageBytes
,
'bytes'
+
storageBytes
)
}
}
...
@@ -10,5 +10,3 @@ class FixedByteArray extends ValueType {
...
@@ -10,5 +10,3 @@ class FixedByteArray extends ValueType {
return
'0x'
+
value
.
substr
(
0
,
2
*
this
.
storageBytes
).
toUpperCase
()
return
'0x'
+
value
.
substr
(
0
,
2
*
this
.
storageBytes
).
toUpperCase
()
}
}
}
}
module
.
exports
=
FixedByteArray
libs/remix-debug/src/solidity-decoder/types/Int.ts
View file @
9fc2291d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
const
util
=
require
(
'./util'
)
const
util
=
require
(
'./util'
)
const
ValueType
=
require
(
'./ValueType'
)
const
ValueType
=
require
(
'./ValueType'
)
class
Int
extends
ValueType
{
export
class
Int
extends
ValueType
{
constructor
(
storageBytes
)
{
constructor
(
storageBytes
)
{
super
(
1
,
storageBytes
,
'int'
+
storageBytes
*
8
)
super
(
1
,
storageBytes
,
'int'
+
storageBytes
*
8
)
}
}
...
@@ -12,5 +12,3 @@ class Int extends ValueType {
...
@@ -12,5 +12,3 @@ class Int extends ValueType {
return
util
.
decodeIntFromHex
(
value
,
this
.
storageBytes
,
true
)
return
util
.
decodeIntFromHex
(
value
,
this
.
storageBytes
,
true
)
}
}
}
}
module
.
exports
=
Int
libs/remix-debug/src/solidity-decoder/types/Mapping.ts
View file @
9fc2291d
...
@@ -3,7 +3,7 @@ const RefType = require('./RefType')
...
@@ -3,7 +3,7 @@ const RefType = require('./RefType')
const
util
=
require
(
'./util'
)
const
util
=
require
(
'./util'
)
const
ethutil
=
require
(
'ethereumjs-util'
)
const
ethutil
=
require
(
'ethereumjs-util'
)
class
Mapping
extends
RefType
{
export
class
Mapping
extends
RefType
{
constructor
(
underlyingTypes
,
location
,
fullType
)
{
constructor
(
underlyingTypes
,
location
,
fullType
)
{
super
(
1
,
32
,
fullType
,
'storage'
)
super
(
1
,
32
,
fullType
,
'storage'
)
this
.
keyType
=
underlyingTypes
.
keyType
this
.
keyType
=
underlyingTypes
.
keyType
...
@@ -76,5 +76,3 @@ function concatTypedArrays (a, b) { // a, b TypedArray of same type
...
@@ -76,5 +76,3 @@ function concatTypedArrays (a, b) { // a, b TypedArray of same type
c
.
set
(
b
,
a
.
length
)
c
.
set
(
b
,
a
.
length
)
return
c
return
c
}
}
module
.
exports
=
Mapping
libs/remix-debug/src/solidity-decoder/types/RefType.ts
View file @
9fc2291d
'use strict'
'use strict'
const
util
=
require
(
'./util'
)
const
util
=
require
(
'./util'
)
class
RefType
{
export
class
RefType
{
location
storageSlots
storageBytes
typeName
basicType
constructor
(
storageSlots
,
storageBytes
,
typeName
,
location
)
{
constructor
(
storageSlots
,
storageBytes
,
typeName
,
location
)
{
this
.
location
=
location
this
.
location
=
location
this
.
storageSlots
=
storageSlots
this
.
storageSlots
=
storageSlots
...
@@ -71,5 +78,3 @@ class RefType {
...
@@ -71,5 +78,3 @@ class RefType {
return
this
.
location
.
indexOf
(
'memory'
)
===
0
return
this
.
location
.
indexOf
(
'memory'
)
===
0
}
}
}
}
module
.
exports
=
RefType
libs/remix-debug/src/solidity-decoder/types/StringType.ts
View file @
9fc2291d
'use strict'
'use strict'
const
DynamicBytes
=
require
(
'./DynamicByteArray'
)
const
DynamicBytes
=
require
(
'./DynamicByteArray'
)
class
StringType
extends
DynamicBytes
{
export
class
StringType
extends
DynamicBytes
{
constructor
(
location
)
{
constructor
(
location
)
{
super
(
location
)
super
(
location
)
this
.
typeName
=
'string'
this
.
typeName
=
'string'
...
@@ -41,12 +41,10 @@ function format (decoded) {
...
@@ -41,12 +41,10 @@ function format (decoded) {
value
=
value
.
replace
(
'0x'
,
''
).
replace
(
/
(
..
)
/g
,
'%$1'
)
value
=
value
.
replace
(
'0x'
,
''
).
replace
(
/
(
..
)
/g
,
'%$1'
)
const
ret
=
{
length
:
decoded
.
length
,
raw
:
decoded
.
value
,
type
:
'string'
}
const
ret
=
{
length
:
decoded
.
length
,
raw
:
decoded
.
value
,
type
:
'string'
}
try
{
try
{
ret
.
value
=
decodeURIComponent
(
value
)
ret
[
'value'
]
=
decodeURIComponent
(
value
)
}
catch
(
e
)
{
}
catch
(
e
)
{
ret
.
error
=
'Invalid UTF8 encoding'
ret
[
'error'
]
=
'Invalid UTF8 encoding'
ret
.
raw
=
decoded
.
value
ret
.
raw
=
decoded
.
value
}
}
return
ret
return
ret
}
}
module
.
exports
=
StringType
libs/remix-debug/src/solidity-decoder/types/Struct.ts
View file @
9fc2291d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
const
util
=
require
(
'./util'
)
const
util
=
require
(
'./util'
)
const
RefType
=
require
(
'./RefType'
)
const
RefType
=
require
(
'./RefType'
)
class
Struct
extends
RefType
{
export
class
Struct
extends
RefType
{
constructor
(
memberDetails
,
location
,
fullType
)
{
constructor
(
memberDetails
,
location
,
fullType
)
{
super
(
memberDetails
.
storageSlots
,
32
,
'struct '
+
fullType
,
location
)
super
(
memberDetails
.
storageSlots
,
32
,
'struct '
+
fullType
,
location
)
this
.
members
=
memberDetails
.
members
this
.
members
=
memberDetails
.
members
...
@@ -36,5 +36,3 @@ class Struct extends RefType {
...
@@ -36,5 +36,3 @@ class Struct extends RefType {
return
{
value
:
ret
,
type
:
this
.
typeName
}
return
{
value
:
ret
,
type
:
this
.
typeName
}
}
}
}
}
module
.
exports
=
Struct
libs/remix-debug/src/solidity-decoder/types/Uint.ts
View file @
9fc2291d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
const
util
=
require
(
'./util'
)
const
util
=
require
(
'./util'
)
const
ValueType
=
require
(
'./ValueType'
)
const
ValueType
=
require
(
'./ValueType'
)
class
Uint
extends
ValueType
{
export
class
Uint
extends
ValueType
{
constructor
(
storageBytes
)
{
constructor
(
storageBytes
)
{
super
(
1
,
storageBytes
,
'uint'
+
storageBytes
*
8
)
super
(
1
,
storageBytes
,
'uint'
+
storageBytes
*
8
)
}
}
...
@@ -12,5 +12,3 @@ class Uint extends ValueType {
...
@@ -12,5 +12,3 @@ class Uint extends ValueType {
return
util
.
decodeIntFromHex
(
value
,
this
.
storageBytes
,
false
)
return
util
.
decodeIntFromHex
(
value
,
this
.
storageBytes
,
false
)
}
}
}
}
module
.
exports
=
Uint
libs/remix-debug/src/solidity-decoder/types/ValueType.ts
View file @
9fc2291d
'use strict'
'use strict'
var
util
=
require
(
'./util'
)
var
util
=
require
(
'./util'
)
class
ValueType
{
export
class
ValueType
{
storageSlots
storageBytes
typeName
basicType
constructor
(
storageSlots
,
storageBytes
,
typeName
)
{
constructor
(
storageSlots
,
storageBytes
,
typeName
)
{
this
.
storageSlots
=
storageSlots
this
.
storageSlots
=
storageSlots
this
.
storageBytes
=
storageBytes
this
.
storageBytes
=
storageBytes
...
...
libs/remix-debug/src/solidity-decoder/types/util.ts
View file @
9fc2291d
'use strict'
'use strict'
const
ethutil
=
require
(
'ethereumjs-util'
)
import
{
BN
,
bufferToHex
,
unpad
}
from
'ethereumjs-util'
const
BN
=
require
(
'ethereumjs-util'
).
BN
function
decodeIntFromHex
(
value
,
byteLength
,
signed
)
{
export
function
decodeIntFromHex
(
value
,
byteLength
,
signed
)
{
let
bigNumber
=
new
BN
(
value
,
16
)
let
bigNumber
=
new
BN
(
value
,
16
)
if
(
signed
)
{
if
(
signed
)
{
bigNumber
=
bigNumber
.
fromTwos
(
8
*
byteLength
)
bigNumber
=
bigNumber
.
fromTwos
(
8
*
byteLength
)
...
@@ -10,8 +9,8 @@ function decodeIntFromHex (value, byteLength, signed) {
...
@@ -10,8 +9,8 @@ function decodeIntFromHex (value, byteLength, signed) {
return
bigNumber
.
toString
(
10
)
return
bigNumber
.
toString
(
10
)
}
}
function
readFromStorage
(
slot
,
storageResolver
)
{
export
function
readFromStorage
(
slot
,
storageResolver
)
{
const
hexSlot
=
'0x'
+
normalizeHex
(
ethutil
.
bufferToHex
(
slot
))
const
hexSlot
=
'0x'
+
normalizeHex
(
bufferToHex
(
slot
))
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
storageResolver
.
storageSlot
(
hexSlot
,
(
error
,
slot
)
=>
{
storageResolver
.
storageSlot
(
hexSlot
,
(
error
,
slot
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
@@ -32,7 +31,7 @@ function readFromStorage(slot, storageResolver) {
...
@@ -32,7 +31,7 @@ function readFromStorage(slot, storageResolver) {
* @param {Int} byteLength - Length of the byte slice to extract
* @param {Int} byteLength - Length of the byte slice to extract
* @param {Int} offsetFromLSB - byte distance from the right end slot value to the right end of the byte slice
* @param {Int} offsetFromLSB - byte distance from the right end slot value to the right end of the byte slice
*/
*/
function
extractHexByteSlice
(
slotValue
,
byteLength
,
offsetFromLSB
)
{
export
function
extractHexByteSlice
(
slotValue
,
byteLength
,
offsetFromLSB
)
{
const
offset
=
slotValue
.
length
-
2
*
offsetFromLSB
-
2
*
byteLength
const
offset
=
slotValue
.
length
-
2
*
offsetFromLSB
-
2
*
byteLength
return
slotValue
.
substr
(
offset
,
2
*
byteLength
)
return
slotValue
.
substr
(
offset
,
2
*
byteLength
)
}
}
...
@@ -44,7 +43,7 @@ function extractHexByteSlice (slotValue, byteLength, offsetFromLSB) {
...
@@ -44,7 +43,7 @@ function extractHexByteSlice (slotValue, byteLength, offsetFromLSB) {
* @param {Object} storageResolver - storage resolver
* @param {Object} storageResolver - storage resolver
* @param {Int} byteLength - Length of the byte slice to extract
* @param {Int} byteLength - Length of the byte slice to extract
*/
*/
async
function
extractHexValue
(
location
,
storageResolver
,
byteLength
)
{
export
async
function
extractHexValue
(
location
,
storageResolver
,
byteLength
)
{
let
slotvalue
let
slotvalue
try
{
try
{
slotvalue
=
await
readFromStorage
(
location
.
slot
,
storageResolver
)
slotvalue
=
await
readFromStorage
(
location
.
slot
,
storageResolver
)
...
@@ -54,11 +53,11 @@ async function extractHexValue (location, storageResolver, byteLength) {
...
@@ -54,11 +53,11 @@ async function extractHexValue (location, storageResolver, byteLength) {
return
extractHexByteSlice
(
slotvalue
,
byteLength
,
location
.
offset
)
return
extractHexByteSlice
(
slotvalue
,
byteLength
,
location
.
offset
)
}
}
function
toBN
(
value
)
{
export
function
toBN
(
value
)
{
if
(
value
instanceof
BN
)
{
if
(
value
instanceof
BN
)
{
return
value
return
value
}
else
if
(
value
.
match
&&
value
.
match
(
/^
(
0x
)?([
a-f0-9
]
*
)
$/
))
{
}
else
if
(
value
.
match
&&
value
.
match
(
/^
(
0x
)?([
a-f0-9
]
*
)
$/
))
{
value
=
ethutil
.
unpad
(
value
.
replace
(
/^
(
0x
)
/
,
''
))
value
=
unpad
(
value
.
replace
(
/^
(
0x
)
/
,
''
))
value
=
new
BN
(
value
===
''
?
'0'
:
value
,
16
)
value
=
new
BN
(
value
===
''
?
'0'
:
value
,
16
)
}
else
if
(
!
isNaN
(
value
))
{
}
else
if
(
!
isNaN
(
value
))
{
value
=
new
BN
(
value
)
value
=
new
BN
(
value
)
...
@@ -66,19 +65,19 @@ function toBN (value) {
...
@@ -66,19 +65,19 @@ function toBN (value) {
return
value
return
value
}
}
function
add
(
value1
,
value2
)
{
export
function
add
(
value1
,
value2
)
{
return
toBN
(
value1
).
add
(
toBN
(
value2
))
return
toBN
(
value1
).
add
(
toBN
(
value2
))
}
}
function
sub
(
value1
,
value2
)
{
export
function
sub
(
value1
,
value2
)
{
return
toBN
(
value1
).
sub
(
toBN
(
value2
))
return
toBN
(
value1
).
sub
(
toBN
(
value2
))
}
}
function
removeLocation
(
type
)
{
export
function
removeLocation
(
type
)
{
return
type
.
replace
(
/
(
storage ref| storage pointer| memory| calldata
)
/g
,
''
)
return
type
.
replace
(
/
(
storage ref| storage pointer| memory| calldata
)
/g
,
''
)
}
}
function
extractLocation
(
type
)
{
export
function
extractLocation
(
type
)
{
let
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
let
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
if
(
match
[
1
]
!==
''
)
{
if
(
match
[
1
]
!==
''
)
{
return
match
[
1
].
trim
()
return
match
[
1
].
trim
()
...
@@ -86,7 +85,7 @@ function extractLocation (type) {
...
@@ -86,7 +85,7 @@ function extractLocation (type) {
return
null
return
null
}
}
function
extractLocationFromAstVariable
(
node
)
{
export
function
extractLocationFromAstVariable
(
node
)
{
if
(
node
.
storageLocation
!==
'default'
)
{
if
(
node
.
storageLocation
!==
'default'
)
{
return
node
.
storageLocation
return
node
.
storageLocation
}
else
if
(
node
.
stateVariable
)
{
}
else
if
(
node
.
stateVariable
)
{
...
@@ -95,12 +94,10 @@ function extractLocationFromAstVariable (node) {
...
@@ -95,12 +94,10 @@ function extractLocationFromAstVariable (node) {
return
'default'
// local variables => storage, function parameters & return values => memory, state => storage
return
'default'
// local variables => storage, function parameters & return values => memory, state => storage
}
}
function
normalizeHex
(
hex
)
{
export
function
normalizeHex
(
hex
)
{
hex
=
hex
.
replace
(
'0x'
,
''
)
hex
=
hex
.
replace
(
'0x'
,
''
)
if
(
hex
.
length
<
64
)
{
if
(
hex
.
length
<
64
)
{
return
(
new
Array
(
64
-
hex
.
length
+
1
).
join
(
'0'
))
+
hex
return
(
new
Array
(
64
-
hex
.
length
+
1
).
join
(
'0'
))
+
hex
}
}
return
hex
return
hex
}
}
module
.
exports
=
{
readFromStorage
,
decodeIntFromHex
,
extractHexValue
,
extractHexByteSlice
,
toBN
,
add
,
sub
,
extractLocation
,
removeLocation
,
normalizeHex
,
extractLocationFromAstVariable
}
\ No newline at end of file
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