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
19275236
Unverified
Commit
19275236
authored
Apr 24, 2018
by
yann300
Committed by
GitHub
Apr 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #765 from ethereum/fixByteEncoding
Switch abi coder
parents
2bcab045
faa2f041
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
77 deletions
+33
-77
package.json
remix-lib/package.json
+8
-8
eventsDecoder.js
remix-lib/src/execution/eventsDecoder.js
+12
-51
txFormat.js
remix-lib/src/execution/txFormat.js
+4
-5
txHelper.js
remix-lib/src/execution/txHelper.js
+6
-10
txListener.js
remix-lib/src/execution/txListener.js
+3
-3
No files found.
remix-lib/package.json
View file @
19275236
...
@@ -15,22 +15,22 @@
...
@@ -15,22 +15,22 @@
"main"
:
"./index.js"
,
"main"
:
"./index.js"
,
"dependencies"
:
{
"dependencies"
:
{
"async"
:
"^2.1.2"
,
"async"
:
"^2.1.2"
,
"babel-preset-es2015"
:
"^6.24.0"
,
"babel-plugin-transform-object-assign"
:
"^6.22.0"
,
"babel-eslint"
:
"^7.1.1"
,
"babel-eslint"
:
"^7.1.1"
,
"babel-plugin-transform-object-assign"
:
"^6.22.0"
,
"babel-preset-env"
:
"^1.6.1"
,
"babel-preset-env"
:
"^1.6.1"
,
"babel-preset-es2015"
:
"^6.24.0"
,
"babel-preset-stage-0"
:
"^6.24.1"
,
"babel-preset-stage-0"
:
"^6.24.1"
,
"babelify"
:
"^7.3.0"
,
"babelify"
:
"^7.3.0"
,
"fast-async"
:
"^6.1.2"
,
"ethereumjs-util"
:
"^5.1.2"
,
"ethereumjs-abi"
:
"https://github.com/ethereumjs/ethereumjs-abi"
,
"ethereumjs-vm"
:
"^2.3.3"
,
"ethereumjs-block"
:
"^1.6.0"
,
"ethereumjs-block"
:
"^1.6.0"
,
"ethereumjs-tx"
:
"^1.3.3"
,
"ethereumjs-tx"
:
"^1.3.3"
,
"web3"
:
"^0.18.0"
,
"ethereumjs-util"
:
"^5.1.2"
,
"ethereumjs-vm"
:
"^2.3.3"
,
"ethers"
:
"^3.0.15"
,
"fast-async"
:
"^6.1.2"
,
"solc"
:
"^0.4.13"
,
"solc"
:
"^0.4.13"
,
"standard"
:
"^7.0.1"
,
"standard"
:
"^7.0.1"
,
"tape"
:
"^4.6.0"
"tape"
:
"^4.6.0"
,
"web3"
:
"^0.18.0"
},
},
"scripts"
:
{
"scripts"
:
{
"test"
:
"standard && tape ./test/tests.js"
"test"
:
"standard && tape ./test/tests.js"
...
...
remix-lib/src/execution/eventsDecoder.js
View file @
19275236
'use strict'
'use strict'
var
ethJSABI
=
require
(
'ethereumjs-abi'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
ethers
=
require
(
'ethers'
)
var
txHelper
=
require
(
'./txHelper'
)
var
txHelper
=
require
(
'./txHelper'
)
/**
/**
...
@@ -38,13 +39,11 @@ class EventsDecoder {
...
@@ -38,13 +39,11 @@ class EventsDecoder {
_eventABI
(
contract
)
{
_eventABI
(
contract
)
{
var
eventABI
=
{}
var
eventABI
=
{}
contract
.
abi
.
forEach
(
function
(
funABI
,
i
)
{
var
abi
=
new
ethers
.
Interface
(
contract
.
abi
)
if
(
funABI
.
type
!==
'event'
)
{
for
(
var
e
in
abi
.
events
)
{
return
var
event
=
abi
.
events
[
e
]
}
eventABI
[
ethJSUtil
.
sha3
(
new
Buffer
(
event
.
signature
)).
toString
(
'hex'
)]
=
{
event
:
event
.
name
,
inputs
:
event
.
inputs
,
object
:
event
}
var
hash
=
ethJSABI
.
eventID
(
funABI
.
name
,
funABI
.
inputs
.
map
(
function
(
item
)
{
return
item
.
type
}))
}
eventABI
[
hash
.
toString
(
'hex'
)]
=
{
event
:
funABI
.
name
,
inputs
:
funABI
.
inputs
}
})
return
eventABI
return
eventABI
}
}
...
@@ -67,54 +66,16 @@ class EventsDecoder {
...
@@ -67,54 +66,16 @@ class EventsDecoder {
_decodeEvents
(
tx
,
logs
,
contractName
,
compiledContracts
,
cb
)
{
_decodeEvents
(
tx
,
logs
,
contractName
,
compiledContracts
,
cb
)
{
var
eventsABI
=
this
.
_eventsABI
(
compiledContracts
)
var
eventsABI
=
this
.
_eventsABI
(
compiledContracts
)
var
events
=
[]
var
events
=
{}
for
(
var
i
in
logs
)
{
for
(
var
i
in
logs
)
{
// [address, topics, mem]
// [address, topics, mem]
var
log
=
logs
[
i
]
var
log
=
logs
[
i
]
var
topicId
=
log
.
topics
[
0
]
var
topicId
=
log
.
topics
[
0
]
var
abi
=
this
.
_event
(
topicId
.
replace
(
'0x'
,
''
),
eventsABI
)
var
abi
=
this
.
_event
(
topicId
.
replace
(
'0x'
,
''
),
eventsABI
)
if
(
abi
)
{
var
topics
=
log
.
topics
.
map
((
value
)
=>
{
var
event
return
value
.
indexOf
(
'0x'
)
===
0
?
value
:
'0x'
+
value
try
{
})
var
decoded
=
new
Array
(
abi
.
inputs
.
length
)
events
=
abi
.
object
.
parse
(
topics
,
'0x'
+
log
.
data
)
event
=
abi
.
event
var
indexed
=
1
var
nonindexed
=
[]
// decode indexed param
abi
.
inputs
.
map
(
function
(
item
,
index
)
{
if
(
item
.
indexed
)
{
var
encodedData
=
log
.
topics
[
indexed
].
replace
(
'0x'
,
''
)
try
{
decoded
[
index
]
=
ethJSABI
.
rawDecode
([
item
.
type
],
new
Buffer
(
encodedData
,
'hex'
))[
0
]
if
(
typeof
decoded
[
index
]
!==
'string'
)
{
decoded
[
index
]
=
ethJSABI
.
stringify
([
item
.
type
],
decoded
[
index
])
}
}
catch
(
e
)
{
decoded
[
index
]
=
encodedData
}
indexed
++
}
else
{
nonindexed
.
push
(
item
.
type
)
}
})
// decode non indexed param
var
nonindexededResult
=
ethJSABI
.
rawDecode
(
nonindexed
,
new
Buffer
(
log
.
data
.
replace
(
'0x'
,
''
),
'hex'
))
nonindexed
=
ethJSABI
.
stringify
(
nonindexed
,
nonindexededResult
)
// ordering
var
j
=
0
abi
.
inputs
.
map
(
function
(
item
,
index
)
{
if
(
!
item
.
indexed
)
{
decoded
[
index
]
=
nonindexed
[
j
]
j
++
}
})
}
catch
(
e
)
{
decoded
=
log
.
data
}
events
.
push
({
topic
:
topicId
,
event
:
event
,
args
:
decoded
})
}
else
{
events
.
push
({
data
:
log
.
data
,
topics
:
log
.
topics
})
}
}
}
cb
(
null
,
{
decoded
:
events
,
raw
:
logs
})
cb
(
null
,
{
decoded
:
events
,
raw
:
logs
})
}
}
...
...
remix-lib/src/execution/txFormat.js
View file @
19275236
'use strict'
'use strict'
var
eth
JSABI
=
require
(
'ethereumjs-abi
'
)
var
eth
ers
=
require
(
'ethers
'
)
var
helper
=
require
(
'./txHelper'
)
var
helper
=
require
(
'./txHelper'
)
var
executionContext
=
require
(
'./execution-context'
)
var
executionContext
=
require
(
'./execution-context'
)
var
asyncJS
=
require
(
'async'
)
var
asyncJS
=
require
(
'async'
)
...
@@ -96,7 +96,7 @@ module.exports = {
...
@@ -96,7 +96,7 @@ module.exports = {
dataHex
=
bytecodeToDeploy
+
dataHex
dataHex
=
bytecodeToDeploy
+
dataHex
}
}
}
else
{
}
else
{
dataHex
=
Buffer
.
concat
([
helper
.
encodeFunctionId
(
funAbi
),
data
]).
toString
(
'hex'
)
dataHex
=
helper
.
encodeFunctionId
(
funAbi
)
+
dataHex
}
}
callback
(
null
,
{
dataHex
,
funAbi
,
funArgs
,
contractBytecode
,
contractName
:
contractName
})
callback
(
null
,
{
dataHex
,
funAbi
,
funArgs
,
contractBytecode
,
contractName
:
contractName
})
},
},
...
@@ -244,10 +244,9 @@ module.exports = {
...
@@ -244,10 +244,9 @@ module.exports = {
}
}
// decode data
// decode data
var
decodedObj
=
ethJSABI
.
rawDecode
(
outputTypes
,
response
)
var
abiCoder
=
new
ethers
.
utils
.
AbiCoder
()
var
decodedObj
=
abiCoder
.
decode
(
outputTypes
,
response
)
// format decoded data
decodedObj
=
ethJSABI
.
stringify
(
outputTypes
,
decodedObj
)
var
json
=
{}
var
json
=
{}
for
(
i
=
0
;
i
<
outputTypes
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
outputTypes
.
length
;
i
++
)
{
var
name
=
fnabi
.
outputs
[
i
].
name
var
name
=
fnabi
.
outputs
[
i
].
name
...
...
remix-lib/src/execution/txHelper.js
View file @
19275236
'use strict'
'use strict'
var
eth
JSABI
=
require
(
'ethereumjs-abi
'
)
var
eth
ers
=
require
(
'ethers
'
)
module
.
exports
=
{
module
.
exports
=
{
encodeParams
:
function
(
funABI
,
args
)
{
encodeParams
:
function
(
funABI
,
args
)
{
...
@@ -16,18 +16,14 @@ module.exports = {
...
@@ -16,18 +16,14 @@ module.exports = {
// NOTE: the caller will concatenate the bytecode and this
// NOTE: the caller will concatenate the bytecode and this
// it could be done here too for consistency
// it could be done here too for consistency
return
ethJSABI
.
rawEncode
(
types
,
args
)
var
abiCoder
=
new
ethers
.
utils
.
AbiCoder
()
return
abiCoder
.
encode
(
types
,
args
)
},
},
encodeFunctionId
:
function
(
funABI
)
{
encodeFunctionId
:
function
(
funABI
)
{
var
types
=
[]
var
abi
=
new
ethers
.
Interface
([
funABI
])
if
(
funABI
.
inputs
&&
funABI
.
inputs
.
length
)
{
abi
=
abi
.
functions
[
funABI
.
name
]
for
(
var
i
=
0
;
i
<
funABI
.
inputs
.
length
;
i
++
)
{
return
abi
.
sighash
types
.
push
(
funABI
.
inputs
[
i
].
type
)
}
}
return
ethJSABI
.
methodID
(
funABI
.
name
,
types
)
},
},
sortAbiFunction
:
function
(
contractabi
)
{
sortAbiFunction
:
function
(
contractabi
)
{
...
...
remix-lib/src/execution/txListener.js
View file @
19275236
'use strict'
'use strict'
var
async
=
require
(
'async'
)
var
async
=
require
(
'async'
)
var
eth
JSABI
=
require
(
'ethereumjs-abi
'
)
var
eth
ers
=
require
(
'ethers
'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
EventManager
=
require
(
'../eventManager'
)
var
EventManager
=
require
(
'../eventManager'
)
var
codeUtil
=
require
(
'../util'
)
var
codeUtil
=
require
(
'../util'
)
...
@@ -329,8 +329,8 @@ class TxListener {
...
@@ -329,8 +329,8 @@ class TxListener {
for
(
var
i
=
0
;
i
<
abi
.
inputs
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
abi
.
inputs
.
length
;
i
++
)
{
inputTypes
.
push
(
abi
.
inputs
[
i
].
type
)
inputTypes
.
push
(
abi
.
inputs
[
i
].
type
)
}
}
var
decoded
=
ethJSABI
.
rawDecode
(
inputTypes
,
data
)
var
abiCoder
=
new
ethers
.
utils
.
AbiCoder
(
)
decoded
=
ethJSABI
.
stringify
(
inputTypes
,
decoded
)
var
decoded
=
abiCoder
.
decode
(
inputTypes
,
data
)
var
ret
=
{}
var
ret
=
{}
for
(
var
k
in
abi
.
inputs
)
{
for
(
var
k
in
abi
.
inputs
)
{
ret
[
abi
.
inputs
[
k
].
type
+
' '
+
abi
.
inputs
[
k
].
name
]
=
decoded
[
k
]
ret
[
abi
.
inputs
[
k
].
type
+
' '
+
abi
.
inputs
[
k
].
name
]
=
decoded
[
k
]
...
...
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