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
f65bd7fc
Commit
f65bd7fc
authored
Dec 05, 2016
by
yann300
Committed by
GitHub
Dec 05, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #341 from ethereum/fixweb3SendTx
Fix send tx through web3
parents
b2b42411
821489c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
13 deletions
+24
-13
txRunner.js
src/app/txRunner.js
+8
-3
universal-dapp.js
src/universal-dapp.js
+16
-10
No files found.
src/app/txRunner.js
View file @
f65bd7fc
...
...
@@ -4,7 +4,7 @@ var EthJSBlock = require('ethereumjs-block')
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
BN
=
ethJSUtil
.
BN
function
TxRunner
(
executionContext
,
opts
)
{
function
TxRunner
(
executionContext
,
vmaccounts
,
opts
)
{
this
.
executionContext
=
executionContext
this
.
web3
=
executionContext
.
web3
()
this
.
vm
=
executionContext
.
vm
()
...
...
@@ -16,6 +16,7 @@ function TxRunner (executionContext, opts) {
}
this
.
running
=
false
this
.
pendingTxs
=
[]
this
.
vmaccounts
=
vmaccounts
}
TxRunner
.
prototype
.
rawRun
=
function
(
args
,
cb
)
{
...
...
@@ -83,15 +84,19 @@ TxRunner.prototype.execute = function () {
}
}
else
{
try
{
var
account
=
self
.
vmaccounts
[
from
]
if
(
!
account
)
{
return
cb
(
'Invalid account selected'
)
}
tx
=
new
EthJSTX
({
nonce
:
new
BN
(
from
.
nonce
++
),
nonce
:
new
BN
(
account
.
nonce
++
),
gasPrice
:
new
BN
(
1
),
gasLimit
:
new
BN
(
gasLimit
,
10
),
to
:
to
,
value
:
new
BN
(
value
,
10
),
data
:
new
Buffer
(
data
.
slice
(
2
),
'hex'
)
})
tx
.
sign
(
from
.
privateKey
)
tx
.
sign
(
account
.
privateKey
)
var
block
=
new
EthJSBlock
({
header
:
{
// FIXME: support coinbase, difficulty and gasLimit
...
...
src/universal-dapp.js
View file @
f65bd7fc
...
...
@@ -33,18 +33,14 @@ function UniversalDApp (executionContext, options, txdebugger) {
self
.
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
self
.
reset
(
self
.
contracts
)
})
self
.
txRunner
=
new
TxRunner
(
executionContext
,
{
self
.
txRunner
=
new
TxRunner
(
executionContext
,
{
},
{
queueTxs
:
true
,
personalMode
:
t
ru
e
personalMode
:
t
his
.
personalMod
e
})
}
UniversalDApp
.
prototype
.
reset
=
function
(
contracts
,
getAddress
,
getValue
,
getGasLimit
,
renderer
)
{
this
.
$el
.
empty
()
this
.
txRunner
=
new
TxRunner
(
this
.
executionContext
,
{
queueTxs
:
true
,
personalMode
:
true
})
this
.
contracts
=
contracts
this
.
getAddress
=
getAddress
this
.
getValue
=
getValue
...
...
@@ -58,6 +54,10 @@ UniversalDApp.prototype.reset = function (contracts, getAddress, getValue, getGa
this
.
_addAccount
(
'd74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea'
)
this
.
_addAccount
(
'71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce'
)
}
this
.
txRunner
=
new
TxRunner
(
this
.
executionContext
,
this
.
accounts
,
{
queueTxs
:
true
,
personalMode
:
this
.
personalMode
})
}
UniversalDApp
.
prototype
.
newAccount
=
function
(
password
)
{
...
...
@@ -549,6 +549,10 @@ UniversalDApp.prototype.getCallButton = function (args) {
var
decoded
self
.
runTx
({
to
:
args
.
address
,
data
:
data
,
useCall
:
args
.
abi
.
constant
&&
!
isConstructor
},
function
(
err
,
txResult
)
{
if
(
!
txResult
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'callback contain no result '
+
err
).
addClass
(
'error'
))
return
}
var
result
=
txResult
.
result
if
(
err
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
err
).
addClass
(
'error'
))
...
...
@@ -681,7 +685,6 @@ UniversalDApp.prototype.runTx = function (args, cb) {
data
:
args
.
data
,
useCall
:
args
.
useCall
}
var
accounts
=
this
.
accounts
async
.
waterfall
([
// query gas limit
function
(
callback
)
{
...
...
@@ -725,7 +728,8 @@ UniversalDApp.prototype.runTx = function (args, cb) {
return
callback
(
err
)
}
tx
.
from
=
accounts
[
ret
]
tx
.
from
=
ret
callback
()
})
}
else
{
...
...
@@ -738,10 +742,12 @@ UniversalDApp.prototype.runTx = function (args, cb) {
return
callback
(
'No accounts available'
)
}
tx
.
from
=
accounts
[
ret
[
0
]]
if
(
self
.
executionContext
.
isVM
()
&&
!
self
.
accounts
[
tx
.
from
])
{
if
(
self
.
executionContext
.
isVM
()
&&
!
self
.
accounts
[
ret
[
0
]])
{
return
callback
(
'Invalid account selected'
)
}
tx
.
from
=
ret
[
0
]
callback
()
})
}
...
...
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