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
c660fc80
Commit
c660fc80
authored
May 31, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add getBalance + refactor
parent
682f0709
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
5 deletions
+21
-5
app.js
src/app.js
+9
-0
renderer.js
src/app/renderer.js
+4
-3
helper.js
src/lib/helper.js
+6
-0
universal-dapp.js
src/universal-dapp.js
+2
-2
No files found.
src/app.js
View file @
c660fc80
...
@@ -770,6 +770,15 @@ var run = function () {
...
@@ -770,6 +770,15 @@ var run = function () {
},
},
getAccounts
:
(
callback
)
=>
{
getAccounts
:
(
callback
)
=>
{
udapp
.
getAccounts
(
callback
)
udapp
.
getAccounts
(
callback
)
},
getBalance
:
(
address
,
callback
)
=>
{
udapp
.
getBalance
(
address
,
(
error
,
balance
)
=>
{
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
executionContext
.
web3
().
fromWei
(
balance
,
'ether'
))
}
})
}
}
}
}
var
renderer
=
new
Renderer
(
rendererAPI
,
compiler
.
event
)
var
renderer
=
new
Renderer
(
rendererAPI
,
compiler
.
event
)
...
...
src/app/renderer.js
View file @
c660fc80
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
var
$
=
require
(
'jquery'
)
var
$
=
require
(
'jquery'
)
var
utils
=
require
(
'./utils'
)
var
utils
=
require
(
'./utils'
)
var
helper
=
require
(
'../lib/helper.js'
)
// -------------- styling ----------------------
// -------------- styling ----------------------
var
csjs
=
require
(
'csjs-inject'
)
var
csjs
=
require
(
'csjs-inject'
)
...
@@ -61,7 +62,7 @@ function Renderer (appAPI, compilerEvent) {
...
@@ -61,7 +62,7 @@ function Renderer (appAPI, compilerEvent) {
})
})
}
}
})
})
setInterval
(()
=>
{
updateAccountBalances
(
appAPI
)
},
1000
)
setInterval
(()
=>
{
updateAccountBalances
(
self
,
appAPI
)
},
1000
)
}
}
Renderer
.
prototype
.
clear
=
function
()
{
Renderer
.
prototype
.
clear
=
function
()
{
...
@@ -345,13 +346,13 @@ Renderer.prototype.contracts = function (data, source) {
...
@@ -345,13 +346,13 @@ Renderer.prototype.contracts = function (data, source) {
$
(
'.'
+
css
.
col2
+
' input,textarea'
).
click
(
function
()
{
this
.
select
()
})
$
(
'.'
+
css
.
col2
+
' input,textarea'
).
click
(
function
()
{
this
.
select
()
})
}
}
function
updateAccountBalances
(
appAPI
)
{
function
updateAccountBalances
(
self
,
appAPI
)
{
var
accounts
=
$
(
'#txorigin'
).
children
(
'option'
)
var
accounts
=
$
(
'#txorigin'
).
children
(
'option'
)
accounts
.
each
(
function
(
index
,
value
)
{
accounts
.
each
(
function
(
index
,
value
)
{
(
function
(
acc
)
{
(
function
(
acc
)
{
appAPI
.
getBalance
(
accounts
[
acc
].
value
,
function
(
err
,
res
)
{
appAPI
.
getBalance
(
accounts
[
acc
].
value
,
function
(
err
,
res
)
{
if
(
!
err
)
{
if
(
!
err
)
{
accounts
[
acc
].
innerText
=
accounts
[
acc
].
value
.
substring
(
0
,
8
)
+
'... ('
+
res
.
toString
()
+
' ether)'
accounts
[
acc
].
innerText
=
helper
.
shortenAddress
(
accounts
[
acc
].
value
,
res
)
}
}
})
})
})(
index
)
})(
index
)
...
...
src/lib/helper.js
0 → 100644
View file @
c660fc80
module
.
exports
=
{
shortenAddress
:
function
(
address
,
etherBalance
)
{
var
len
=
address
.
length
return
address
.
slice
(
0
,
5
)
+
'...'
+
address
.
slice
(
len
-
5
,
len
)
+
(
etherBalance
?
' ('
+
etherBalance
.
toString
()
+
' ether)'
:
''
)
}
}
src/universal-dapp.js
View file @
c660fc80
...
@@ -9,6 +9,7 @@ var EventManager = require('ethereum-remix').lib.EventManager
...
@@ -9,6 +9,7 @@ var EventManager = require('ethereum-remix').lib.EventManager
var
crypto
=
require
(
'crypto'
)
var
crypto
=
require
(
'crypto'
)
var
async
=
require
(
'async'
)
var
async
=
require
(
'async'
)
var
TxRunner
=
require
(
'./app/txRunner'
)
var
TxRunner
=
require
(
'./app/txRunner'
)
var
helper
=
require
(
'./lib/helper'
)
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
// copy to copyToClipboard
// copy to copyToClipboard
...
@@ -353,8 +354,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
...
@@ -353,8 +354,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
var
context
=
self
.
executionContext
.
isVM
()
?
'memory'
:
'blockchain'
var
context
=
self
.
executionContext
.
isVM
()
?
'memory'
:
'blockchain'
address
=
(
address
.
slice
(
0
,
2
)
===
'0x'
?
''
:
'0x'
)
+
address
.
toString
(
'hex'
)
address
=
(
address
.
slice
(
0
,
2
)
===
'0x'
?
''
:
'0x'
)
+
address
.
toString
(
'hex'
)
var
len
=
address
.
length
var
shortAddress
=
helper
.
shortenAddress
(
address
)
var
shortAddress
=
address
.
slice
(
0
,
5
)
+
'...'
+
address
.
slice
(
len
-
5
,
len
)
var
title
=
yo
`
var
title
=
yo
`
<div class="
${
cssInstance
.
title
}
" onclick=
${
toggleClass
}
>
<div class="
${
cssInstance
.
title
}
" onclick=
${
toggleClass
}
>
<div class="
${
cssInstance
.
titleText
}
">
${
contract
.
name
}
at
${
shortAddress
}
(
${
context
}
) </div>
<div class="
${
cssInstance
.
titleText
}
">
${
contract
.
name
}
at
${
shortAddress
}
(
${
context
}
) </div>
...
...
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