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
7406045b
Commit
7406045b
authored
Feb 08, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move execution txExecution to Remix-Lib
parent
0a66c499
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
1 deletion
+79
-1
index.js
remix-lib/index.js
+3
-1
txExecution.js
remix-lib/src/execution/txExecution.js
+76
-0
No files found.
remix-lib/index.js
View file @
7406045b
...
...
@@ -18,6 +18,7 @@ var themeChooser = require('./src/ui/theme-chooser')
var
Storage
=
require
(
'./src/storage'
)
var
EventsDecoder
=
require
(
'./src/execution/eventsDecoder'
)
var
txExecution
=
require
(
'./src/execution/txExecution'
)
if
(
typeof
(
module
)
!==
'undefined'
&&
typeof
(
module
.
exports
)
!==
'undefined'
)
{
module
.
exports
=
modules
()
...
...
@@ -53,7 +54,8 @@ function modules () {
themeChooser
:
themeChooser
},
execution
:
{
EventsDecoder
:
EventsDecoder
EventsDecoder
:
EventsDecoder
,
txExecution
:
txExecution
}
}
}
remix-lib/src/execution/txExecution.js
0 → 100644
View file @
7406045b
'use strict'
module
.
exports
=
{
/**
* deploy the given contract
*
* @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
* @param {Object} udap - udapp.
* @param {Function} callback - callback.
*/
createContract
:
function
(
data
,
udapp
,
callback
)
{
udapp
.
runTx
({
data
:
data
,
useCall
:
false
},
(
error
,
txResult
)
=>
{
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback
(
error
,
txResult
)
})
},
/**
* call the current given contract
*
* @param {String} to - address of the contract to call.
* @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
* @param {Object} funAbi - abi definition of the function to call.
* @param {Object} udap - udapp.
* @param {Function} callback - callback.
*/
callFunction
:
function
(
to
,
data
,
funAbi
,
udapp
,
callback
)
{
udapp
.
runTx
({
to
:
to
,
data
:
data
,
useCall
:
funAbi
.
constant
},
(
error
,
txResult
)
=>
{
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback
(
error
,
txResult
)
})
},
/**
* check if the vm has errored
*
* @param {Object} txResult - the value returned by the vm
* @return {Object} - { error: true/false, message: DOMNode }
*/
checkVMError
:
function
(
txResult
)
{
var
errorCode
=
{
OUT_OF_GAS
:
'out of gas'
,
STACK_UNDERFLOW
:
'stack underflow'
,
STACK_OVERFLOW
:
'stack overflow'
,
INVALID_JUMP
:
'invalid JUMP'
,
INVALID_OPCODE
:
'invalid opcode'
,
REVERT
:
'revert'
,
STATIC_STATE_CHANGE
:
'static state change'
}
var
ret
=
{
error
:
false
,
message
:
''
}
if
(
!
txResult
.
result
.
vm
.
exceptionError
)
{
return
ret
}
var
error
=
`VM error:
${
txResult
.
result
.
vm
.
exceptionError
}
.\n`
var
msg
if
(
txResult
.
result
.
vm
.
exceptionError
===
errorCode
.
INVALID_OPCODE
)
{
msg
=
`\t\n\tThe execution might have thrown.\n`
ret
.
error
=
true
}
else
if
(
txResult
.
result
.
vm
.
exceptionError
===
errorCode
.
OUT_OF_GAS
)
{
msg
=
`\tThe transaction ran out of gas. Please increase the Gas Limit.\n`
ret
.
error
=
true
}
else
if
(
txResult
.
result
.
vm
.
exceptionError
===
errorCode
.
REVERT
)
{
msg
=
`\tThe transaction has been reverted to the initial state.\nNote: The constructor should be payable if you send value.`
ret
.
error
=
true
}
else
if
(
txResult
.
result
.
vm
.
exceptionError
===
errorCode
.
STATIC_STATE_CHANGE
)
{
msg
=
`\tState changes is not allowed in Static Call context\n`
ret
.
error
=
true
}
ret
.
message
=
`
${
error
}${
txResult
.
result
.
vm
.
exceptionError
}${
msg
}
\tDebug the transaction to get more information.`
return
ret
}
}
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