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
79e564b5
Commit
79e564b5
authored
Dec 02, 2020
by
aniket-engg
Committed by
Aniket
Dec 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
execution src updated
parent
a4a16863
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
45 deletions
+39
-45
eventsDecoder.ts
libs/remix-lib/src/execution/eventsDecoder.ts
+2
-2
execution-context.ts
libs/remix-lib/src/execution/execution-context.ts
+2
-4
txListener.ts
libs/remix-lib/src/execution/txListener.ts
+14
-16
txRunner.ts
libs/remix-lib/src/execution/txRunner.ts
+7
-7
typeConversion.ts
libs/remix-lib/src/execution/typeConversion.ts
+14
-16
No files found.
libs/remix-lib/src/execution/eventsDecoder.ts
View file @
79e564b5
'use strict'
import
{
ethers
}
from
'ethers'
const
txHelper
=
require
(
'./txHelper'
)
import
{
visitContracts
}
from
'./txHelper'
/**
* Register to txListener and extract events
...
...
@@ -50,7 +50,7 @@ export class EventsDecoder {
_eventsABI
(
compiledContracts
)
{
const
eventsABI
=
{}
txHelper
.
visitContracts
(
compiledContracts
,
(
contract
)
=>
{
visitContracts
(
compiledContracts
,
(
contract
)
=>
{
eventsABI
[
contract
.
name
]
=
this
.
_eventABI
(
contract
.
object
)
})
return
eventsABI
...
...
libs/remix-lib/src/execution/execution-context.ts
View file @
79e564b5
...
...
@@ -3,14 +3,12 @@
import
Web3
from
'web3'
const
EventManager
=
require
(
'../eventManager'
)
const
EthJSVM
=
require
(
'ethereumjs-vm'
).
default
const
ethUtil
=
require
(
'ethereumjs-util'
)
import
{
rlp
,
keccak
,
bufferToHex
}
from
'ethereumjs-util'
const
StateManager
=
require
(
'ethereumjs-vm/dist/state/stateManager'
).
default
const
Web3VMProvider
=
require
(
'../web3Provider/web3VmProvider'
)
const
LogsManager
=
require
(
'./logsManager.js'
)
const
rlp
=
ethUtil
.
rlp
let
web3
if
(
typeof
window
!==
'undefined'
&&
typeof
window
[
'ethereum'
]
!==
'undefined'
)
{
var
injectedProvider
=
window
[
'ethereum'
]
...
...
@@ -32,7 +30,7 @@ class StateManagerCommonStorageDump extends StateManager {
}
putContractStorage
(
address
,
key
,
value
,
cb
)
{
this
.
keyHashes
[
ethUtil
.
keccak
(
key
).
toString
(
'hex'
)]
=
ethUtil
.
bufferToHex
(
key
)
this
.
keyHashes
[
keccak
(
key
).
toString
(
'hex'
)]
=
bufferToHex
(
key
)
super
.
putContractStorage
(
address
,
key
,
value
,
cb
)
}
...
...
libs/remix-lib/src/execution/txListener.ts
View file @
79e564b5
'use strict'
import
async
from
'async'
import
{
ethers
}
from
'ethers'
const
ethJSUtil
=
require
(
'ethereumjs-util'
)
import
{
toBuffer
}
from
'ethereumjs-util'
const
EventManager
=
require
(
'../eventManager'
)
const
codeUtil
=
require
(
'../util'
)
const
defaultExecutionContext
=
require
(
'./execution-context'
)
const
txFormat
=
require
(
'./txFormat'
)
const
txHelper
=
require
(
'./txHelper'
)
import
{
ExecutionContext
}
from
'./execution-context'
import
{
decodeResponse
}
from
'./txFormat'
import
{
getFunction
,
getReceiveInterface
,
getConstructorInterface
,
visitContracts
,
makeFullTypeDefinition
}
from
'./txHelper'
function
addExecutionCosts
(
txResult
,
tx
)
{
if
(
txResult
&&
txResult
.
result
)
{
...
...
@@ -26,7 +26,7 @@ function addExecutionCosts(txResult, tx) {
* trigger 'newBlock'
*
*/
class
TxListener
{
export
class
TxListener
{
event
executionContext
...
...
@@ -42,7 +42,7 @@ class TxListener {
constructor
(
opt
,
executionContext
)
{
this
.
event
=
new
EventManager
()
// has a default for now for backwards compatability
this
.
executionContext
=
executionContext
||
defaultExecutionContext
this
.
executionContext
=
executionContext
||
new
ExecutionContext
()
this
.
_api
=
opt
.
api
this
.
_resolvedTransactions
=
{}
this
.
_resolvedContracts
=
{}
...
...
@@ -71,7 +71,7 @@ class TxListener {
input
:
data
,
hash
:
txResult
.
transactionHash
?
txResult
.
transactionHash
:
'call'
+
(
from
||
''
)
+
to
+
data
,
isCall
:
true
,
returnValue
:
this
.
executionContext
.
isVM
()
?
txResult
.
result
.
execResult
.
returnValue
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
returnValue
:
this
.
executionContext
.
isVM
()
?
txResult
.
result
.
execResult
.
returnValue
:
toBuffer
(
txResult
.
result
),
envMode
:
this
.
executionContext
.
getProvider
()
}
...
...
@@ -289,7 +289,7 @@ class TxListener {
const
methodIdentifiers
=
contract
.
object
.
evm
.
methodIdentifiers
for
(
let
fn
in
methodIdentifiers
)
{
if
(
methodIdentifiers
[
fn
]
===
inputData
.
substring
(
0
,
8
))
{
const
fnabi
=
txHelper
.
getFunction
(
abi
,
fn
)
const
fnabi
=
getFunction
(
abi
,
fn
)
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contract
.
name
,
to
:
tx
.
to
,
...
...
@@ -297,13 +297,13 @@ class TxListener {
params
:
this
.
_decodeInputParams
(
inputData
.
substring
(
8
),
fnabi
)
}
if
(
tx
.
returnValue
)
{
this
.
_resolvedTransactions
[
tx
.
hash
].
decodedReturnValue
=
txFormat
.
decodeResponse
(
tx
.
returnValue
,
fnabi
)
this
.
_resolvedTransactions
[
tx
.
hash
].
decodedReturnValue
=
decodeResponse
(
tx
.
returnValue
,
fnabi
)
}
return
this
.
_resolvedTransactions
[
tx
.
hash
]
}
}
// receive function
if
(
!
inputData
&&
txHelper
.
getReceiveInterface
(
abi
))
{
if
(
!
inputData
&&
getReceiveInterface
(
abi
))
{
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contract
.
name
,
to
:
tx
.
to
,
...
...
@@ -323,7 +323,7 @@ class TxListener {
const
bytecode
=
contract
.
object
.
evm
.
bytecode
.
object
let
params
=
null
if
(
bytecode
&&
bytecode
.
length
)
{
params
=
this
.
_decodeInputParams
(
inputData
.
substring
(
bytecode
.
length
),
txHelper
.
getConstructorInterface
(
abi
))
params
=
this
.
_decodeInputParams
(
inputData
.
substring
(
bytecode
.
length
),
getConstructorInterface
(
abi
))
}
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contract
.
name
,
...
...
@@ -337,7 +337,7 @@ class TxListener {
_tryResolveContract
(
codeToResolve
,
compiledContracts
,
isCreation
)
{
let
found
=
null
txHelper
.
visitContracts
(
compiledContracts
,
(
contract
)
=>
{
visitContracts
(
compiledContracts
,
(
contract
)
=>
{
const
bytes
=
isCreation
?
contract
.
object
.
evm
.
bytecode
.
object
:
contract
.
object
.
evm
.
deployedBytecode
.
object
if
(
codeUtil
.
compareByteCode
(
codeToResolve
,
'0x'
+
bytes
))
{
found
=
contract
...
...
@@ -348,13 +348,13 @@ class TxListener {
}
_decodeInputParams
(
data
,
abi
)
{
data
=
ethJSUtil
.
toBuffer
(
'0x'
+
data
)
data
=
toBuffer
(
'0x'
+
data
)
if
(
!
data
.
length
)
data
=
new
Uint8Array
(
32
*
abi
.
inputs
.
length
)
// ensuring the data is at least filled by 0 cause `AbiCoder` throws if there's not engouh data
const
inputTypes
=
[]
for
(
let
i
=
0
;
i
<
abi
.
inputs
.
length
;
i
++
)
{
const
type
=
abi
.
inputs
[
i
].
type
inputTypes
.
push
(
type
.
indexOf
(
'tuple'
)
===
0
?
txHelper
.
makeFullTypeDefinition
(
abi
.
inputs
[
i
])
:
type
)
inputTypes
.
push
(
type
.
indexOf
(
'tuple'
)
===
0
?
makeFullTypeDefinition
(
abi
.
inputs
[
i
])
:
type
)
}
const
abiCoder
=
new
ethers
.
utils
.
AbiCoder
()
const
decoded
=
abiCoder
.
decode
(
inputTypes
,
data
)
...
...
@@ -365,5 +365,3 @@ class TxListener {
return
ret
}
}
module
.
exports
=
TxListener
libs/remix-lib/src/execution/txRunner.ts
View file @
79e564b5
'use strict'
const
EthJSTX
=
require
(
'ethereumjs-tx'
).
Transaction
const
EthJSBlock
=
require
(
'ethereumjs-block'
)
import
{
Transaction
}
from
'ethereumjs-tx'
import
{
Block
}
from
'ethereumjs-block'
import
{
BN
}
from
'ethereumjs-util'
const
defaultExecutionContext
=
require
(
'./execution-context'
)
import
{
ExecutionContext
}
from
'./execution-context'
const
EventManager
=
require
(
'../eventManager'
)
class
TxRunner
{
...
...
@@ -20,7 +20,7 @@ class TxRunner {
constructor
(
vmaccounts
,
api
,
executionContext
)
{
this
.
event
=
new
EventManager
()
// has a default for now for backwards compatability
this
.
executionContext
=
executionContext
||
defaultExecutionContext
this
.
executionContext
=
executionContext
||
new
ExecutionContext
()
this
.
_api
=
api
this
.
blockNumber
=
0
this
.
runAsync
=
true
...
...
@@ -117,7 +117,7 @@ class TxRunner {
// See https://github.com/ethereumjs/ethereumjs-tx/blob/master/docs/classes/transaction.md#constructor
// for initialization fields and their types
value
=
value
?
parseInt
(
value
)
:
0
const
tx
=
new
EthJSTX
({
const
tx
=
new
Transaction
({
nonce
:
new
BN
(
res
.
nonce
),
gasPrice
:
'0x1'
,
gasLimit
:
gasLimit
,
...
...
@@ -128,7 +128,7 @@ class TxRunner {
tx
.
sign
(
account
.
privateKey
)
const
coinbases
=
[
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
'0x8945a1288dc78a6d8952a92c77aee6730b414778'
,
'0x94d76e24f818426ae84aa404140e8d5f60e10e7e'
]
const
difficulties
=
[
new
BN
(
'69762765929000'
,
10
),
new
BN
(
'70762765929000'
,
10
),
new
BN
(
'71762765929000'
,
10
)]
const
block
=
new
EthJS
Block
({
const
block
=
new
Block
({
header
:
{
timestamp
:
timestamp
||
(
new
Date
().
getTime
()
/
1000
|
0
),
number
:
self
.
blockNumber
,
...
...
@@ -166,7 +166,7 @@ class TxRunner {
this
.
executionContext
.
trackTx
(
'0x'
+
tx
.
hash
().
toString
(
'hex'
),
block
)
callback
(
null
,
{
result
:
result
,
transactionHash
:
ethJSUtil
.
bufferToHex
(
Buffer
.
from
(
tx
.
hash
()))
transactionHash
:
bufferToHex
(
Buffer
.
from
(
tx
.
hash
()))
})
}).
catch
(
function
(
err
)
{
callback
(
err
)
...
...
libs/remix-lib/src/execution/typeConversion.ts
View file @
79e564b5
'use strict'
const
ethJSUtil
=
require
(
'ethereumjs-util'
)
const
BN
=
ethJSUtil
.
BN
import
{
BN
,
bufferToHex
}
from
'ethereumjs-util'
module
.
exports
=
{
toInt
:
(
h
)
=>
{
if
(
h
.
indexOf
&&
h
.
indexOf
(
'0x'
)
===
0
)
{
return
(
new
BN
(
h
.
replace
(
'0x'
,
''
),
16
)).
toString
(
10
)
}
else
if
(
h
.
constructor
&&
h
.
constructor
.
name
===
'BigNumber'
||
BN
.
isBN
(
h
))
{
return
h
.
toString
(
10
)
}
return
h
},
stringify
:
stringify
export
function
toInt
(
h
)
{
if
(
h
.
indexOf
&&
h
.
indexOf
(
'0x'
)
===
0
)
{
return
(
new
BN
(
h
.
replace
(
'0x'
,
''
),
16
)).
toString
(
10
)
}
else
if
(
h
.
constructor
&&
h
.
constructor
.
name
===
'BigNumber'
||
BN
.
isBN
(
h
))
{
return
h
.
toString
(
10
)
}
return
h
}
export
var
stringify
=
convertToString
function
stringify
(
v
)
{
function
convertToString
(
v
)
{
try
{
if
(
v
instanceof
Array
)
{
const
ret
=
[]
for
(
var
k
in
v
)
{
ret
.
push
(
stringify
(
v
[
k
]))
ret
.
push
(
convertToString
(
v
[
k
]))
}
return
ret
}
else
if
(
BN
.
isBN
(
v
)
||
(
v
.
constructor
&&
v
.
constructor
.
name
===
'BigNumber'
))
{
return
v
.
toString
(
10
)
}
else
if
(
v
.
_isBuffer
)
{
return
ethJSUtil
.
bufferToHex
(
v
)
return
bufferToHex
(
v
)
}
else
if
(
typeof
v
===
'object'
)
{
const
retObject
=
{}
for
(
let
i
in
v
)
{
retObject
[
i
]
=
stringify
(
v
[
i
])
retObject
[
i
]
=
convertToString
(
v
[
i
])
}
return
retObject
}
else
{
...
...
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