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
142d6478
Commit
142d6478
authored
Dec 02, 2020
by
aniket-engg
Committed by
Aniket
Dec 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
helpers erc updated
parent
79e564b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
83 deletions
+74
-83
compilerHelper.ts
libs/remix-lib/src/helpers/compilerHelper.ts
+1
-5
txResultHelper.ts
libs/remix-lib/src/helpers/txResultHelper.ts
+3
-6
uiHelper.ts
libs/remix-lib/src/helpers/uiHelper.ts
+70
-72
No files found.
libs/remix-lib/src/helpers/compilerHelper.ts
View file @
142d6478
module
.
exports
=
{
compilerInput
:
compilerInput
}
function
compilerInput
(
contracts
)
{
export
function
compilerInput
(
contracts
)
{
return
JSON
.
stringify
({
language
:
'Solidity'
,
sources
:
{
...
...
libs/remix-lib/src/helpers/txResultHelper.ts
View file @
142d6478
'use strict'
const
{
bufferToHex
,
isHexString
}
=
require
(
'ethereumjs-util'
)
import
{
bufferToHex
}
from
'ethereumjs-util'
import
{
isHexString
}
from
'ethjs-util'
function
convertToPrefixedHex
(
input
)
{
if
(
input
===
undefined
||
input
===
null
||
isHexString
(
input
))
{
...
...
@@ -19,7 +20,7 @@ function convertToPrefixedHex (input) {
Also, VM results use BN and Buffers, Node results use hex strings/ints,
So we need to normalize the values to prefixed hex strings
*/
function
resultToRemixTx
(
txResult
)
{
export
function
resultToRemixTx
(
txResult
)
{
const
{
result
,
transactionHash
}
=
txResult
const
{
status
,
execResult
,
gasUsed
,
createdAddress
,
contractAddress
}
=
result
let
returnValue
,
errorMessage
...
...
@@ -40,7 +41,3 @@ function resultToRemixTx (txResult) {
createdAddress
:
convertToPrefixedHex
(
createdAddress
||
contractAddress
)
}
}
module
.
exports
=
{
resultToRemixTx
}
libs/remix-lib/src/helpers/uiHelper.ts
View file @
142d6478
'use strict'
module
.
exports
=
{
formatMemory
:
function
(
mem
,
width
)
{
const
ret
=
{}
if
(
!
mem
)
{
return
ret
}
export
function
formatMemory
(
mem
,
width
)
{
const
ret
=
{}
if
(
!
mem
)
{
return
ret
}
if
(
!
mem
.
substr
)
{
mem
=
mem
.
join
(
''
)
// geth returns an array, eth return raw string
}
if
(
!
mem
.
substr
)
{
mem
=
mem
.
join
(
''
)
// geth returns an array, eth return raw string
}
for
(
let
k
=
0
;
k
<
mem
.
length
;
k
+=
(
width
*
2
))
{
const
memory
=
mem
.
substr
(
k
,
width
*
2
)
const
content
=
this
.
tryConvertAsciiFormat
(
memory
)
ret
[
'0x'
+
(
k
/
2
).
toString
(
16
)]
=
content
.
raw
+
'
\
t'
+
content
.
ascii
}
return
ret
},
for
(
let
k
=
0
;
k
<
mem
.
length
;
k
+=
(
width
*
2
))
{
const
memory
=
mem
.
substr
(
k
,
width
*
2
)
const
content
=
this
.
tryConvertAsciiFormat
(
memory
)
ret
[
'0x'
+
(
k
/
2
).
toString
(
16
)]
=
content
.
raw
+
'
\
t'
+
content
.
ascii
}
return
ret
}
tryConvertAsciiFormat
:
function
(
memorySlot
)
{
const
ret
=
{
ascii
:
''
,
raw
:
''
}
for
(
let
k
=
0
;
k
<
memorySlot
.
length
;
k
+=
2
)
{
const
raw
=
memorySlot
.
substr
(
k
,
2
)
let
ascii
=
String
.
fromCharCode
(
parseInt
(
raw
,
16
))
ascii
=
ascii
.
replace
(
/
[^\w\s]
/
,
'?'
)
if
(
ascii
===
''
)
{
ascii
=
'?'
}
ret
.
ascii
+=
ascii
ret
.
raw
+=
raw
export
function
tryConvertAsciiFormat
(
memorySlot
)
{
const
ret
=
{
ascii
:
''
,
raw
:
''
}
for
(
let
k
=
0
;
k
<
memorySlot
.
length
;
k
+=
2
)
{
const
raw
=
memorySlot
.
substr
(
k
,
2
)
let
ascii
=
String
.
fromCharCode
(
parseInt
(
raw
,
16
))
ascii
=
ascii
.
replace
(
/
[^\w\s]
/
,
'?'
)
if
(
ascii
===
''
)
{
ascii
=
'?'
}
return
ret
},
ret
.
ascii
+=
ascii
ret
.
raw
+=
raw
}
return
ret
}
/**
* format @args css1, css2, css3 to css inline style
*
* @param {Object} css1 - css inline declaration
* @param {Object} css2 - css inline declaration
* @param {Object} css3 - css inline declaration
* @param {Object} ...
* @return {String} css inline style
* if the key start with * the value is direcly appended to the inline style (which should be already inline style formatted)
* used if multiple occurences of the same key is needed
*/
formatCss
:
function
(
css1
,
css2
)
{
let
ret
=
''
for
(
let
arg
in
arguments
)
{
for
(
let
k
in
arguments
[
arg
])
{
if
(
arguments
[
arg
][
k
]
&&
ret
.
indexOf
(
k
)
===
-
1
)
{
if
(
k
.
indexOf
(
'*'
)
===
0
)
{
ret
+=
arguments
[
arg
][
k
]
}
else
{
ret
+=
k
+
':'
+
arguments
[
arg
][
k
]
+
';'
}
/**
* format @args css1, css2, css3 to css inline style
*
* @param {Object} css1 - css inline declaration
* @param {Object} css2 - css inline declaration
* @param {Object} css3 - css inline declaration
* @param {Object} ...
* @return {String} css inline style
* if the key start with * the value is direcly appended to the inline style (which should be already inline style formatted)
* used if multiple occurences of the same key is needed
*/
export
function
formatCss
(
css1
,
css2
)
{
let
ret
=
''
for
(
let
arg
in
arguments
)
{
for
(
let
k
in
arguments
[
arg
])
{
if
(
arguments
[
arg
][
k
]
&&
ret
.
indexOf
(
k
)
===
-
1
)
{
if
(
k
.
indexOf
(
'*'
)
===
0
)
{
ret
+=
arguments
[
arg
][
k
]
}
else
{
ret
+=
k
+
':'
+
arguments
[
arg
][
k
]
+
';'
}
}
}
return
ret
},
}
return
ret
}
normalizeHex
:
function
(
hex
)
{
if
(
hex
.
indexOf
(
'0x'
)
===
0
)
{
hex
=
hex
.
replace
(
'0x'
,
''
)
}
hex
=
hex
.
replace
(
/^0+/
,
''
)
return
'0x'
+
hex
},
export
function
normalizeHex
(
hex
)
{
if
(
hex
.
indexOf
(
'0x'
)
===
0
)
{
hex
=
hex
.
replace
(
'0x'
,
''
)
}
hex
=
hex
.
replace
(
/^0+/
,
''
)
return
'0x'
+
hex
}
normalizeHexAddress
:
function
(
hex
)
{
if
(
hex
.
indexOf
(
'0x'
)
===
0
)
hex
=
hex
.
replace
(
'0x'
,
''
)
if
(
hex
.
length
>=
40
)
{
const
reg
=
/
(
.
{40})
$/
.
exec
(
hex
)
if
(
reg
)
{
return
'0x'
+
reg
[
0
]
}
}
else
{
return
'0x'
+
(
new
Array
(
40
-
hex
.
length
+
1
).
join
(
'0'
))
+
hex
export
function
normalizeHexAddress
(
hex
)
{
if
(
hex
.
indexOf
(
'0x'
)
===
0
)
hex
=
hex
.
replace
(
'0x'
,
''
)
if
(
hex
.
length
>=
40
)
{
const
reg
=
/
(
.
{40})
$/
.
exec
(
hex
)
if
(
reg
)
{
return
'0x'
+
reg
[
0
]
}
},
runInBrowser
:
function
()
{
return
typeof
window
!==
'undefined'
}
else
{
return
'0x'
+
(
new
Array
(
40
-
hex
.
length
+
1
).
join
(
'0'
))
+
hex
}
}
export
function
runInBrowser
()
{
return
typeof
window
!==
'undefined'
}
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