Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
08de13a5
Commit
08de13a5
authored
Jun 25, 2014
by
zelig
Browse files
Options
Browse Files
Download
Plain Diff
merge upstream
parents
6f09a3e8
9654b809
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
210 additions
and
39 deletions
+210
-39
ethereum.js
ethereal/assets/ext/ethereum.js
+3
-0
QmlApp.qml
ethereal/assets/qml/QmlApp.qml
+22
-0
test_app.qml
ethereal/assets/qml/test_app.qml
+58
-23
wallet.qml
ethereal/assets/qml/wallet.qml
+9
-1
webapp.qml
ethereal/assets/qml/webapp.qml
+6
-0
qml_app.go
ethereal/ui/qml_app.go
+59
-0
ui_lib.go
ethereal/ui/ui_lib.go
+4
-11
javascript_runtime.go
ethereum/javascript_runtime.go
+2
-2
repl.go
ethereum/repl.go
+26
-1
repl_darwin.go
ethereum/repl_darwin.go
+3
-1
cmd.go
utils/cmd.go
+18
-0
No files found.
ethereal/assets/ext/ethereum.js
View file @
08de13a5
...
@@ -58,6 +58,9 @@ window.eth = {
...
@@ -58,6 +58,9 @@ window.eth = {
getBalanceAt
:
function
(
address
,
cb
)
{
getBalanceAt
:
function
(
address
,
cb
)
{
postData
({
call
:
"getBalance"
,
args
:
[
address
]},
cb
);
postData
({
call
:
"getBalance"
,
args
:
[
address
]},
cb
);
},
},
getTransactionsFor
:
function
(
address
,
cb
)
{
postData
({
call
:
"getTransactionsFor"
,
args
:
[
address
]},
cb
);
},
getSecretToAddress
:
function
(
sec
,
cb
)
{
getSecretToAddress
:
function
(
sec
,
cb
)
{
postData
({
call
:
"getSecretToAddress"
,
args
:
[
sec
]},
cb
);
postData
({
call
:
"getSecretToAddress"
,
args
:
[
sec
]},
cb
);
...
...
ethereal/assets/qml/QmlApp.qml
0 → 100644
View file @
08de13a5
import
QtQuick
2.0
import
QtQuick
.
Controls
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
Ethereum
1.0
ApplicationWindow
{
minimumWidth
:
500
maximumWidth
:
500
maximumHeight
:
400
minimumHeight
:
400
function
onNewBlockCb
(
block
)
{
console
.
log
(
"Please overwrite onNewBlock(block):"
,
block
)
}
function
onObjectChangeCb
(
stateObject
)
{
console
.
log
(
"Please overwrite onObjectChangeCb(object)"
,
stateObject
)
}
function
onStorageChangeCb
(
storageObject
)
{
var
ev
=
[
"storage"
,
storageObject
.
stateAddress
,
storageObject
.
address
].
join
(
":"
);
console
.
log
(
"Please overwrite onStorageChangeCb(object)"
,
ev
)
}
}
ethereal/assets/qml/test_app.qml
View file @
08de13a5
...
@@ -3,33 +3,68 @@ import QtQuick.Controls 1.0;
...
@@ -3,33 +3,68 @@ import QtQuick.Controls 1.0;
import
QtQuick
.
Layouts
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
Ethereum
1.0
import
Ethereum
1.0
ApplicationWindow
{
QmlApp
{
minimumWidth
:
50
0
minimumWidth
:
35
0
maximumWidth
:
50
0
maximumWidth
:
35
0
maximumHeight
:
10
0
maximumHeight
:
8
0
minimumHeight
:
10
0
minimumHeight
:
8
0
title
:
"
Ethereum Dice
"
title
:
"
Generic Coin
"
TextField
{
property
string
contractAddr
:
"f299f6c74515620e4c4cd8fe3d205b5c4f2e25c8"
id
:
textField
property
string
addr
:
"2ef47100e0787b915105fd5e3f4ff6752079d5cb"
anchors.verticalCenter
:
parent
.
verticalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
Component.onCompleted
:
{
placeholderText
:
"Amount"
eth
.
watch
(
contractAddr
,
addr
)
eth
.
watch
(
addr
,
contractAddr
)
setAmount
()
}
function
onStorageChangeCb
(
storageObject
)
{
setAmount
()
}
}
Label
{
id
:
txHash
function
setAmount
(){
anchors.bottom
:
textField
.
top
var
state
=
eth
.
getStateObject
(
contractAddr
)
anchors.bottomMargin
:
5
var
storage
=
state
.
getStorage
(
addr
)
a
nchors.horizontalCenter
:
parent
.
horizontalCenter
a
mountLabel
.
text
=
storage
}
}
Button
{
Column
{
anchors.top
:
textField
.
bottom
spacing
:
5
anchors.horizontalCenter
:
parent
.
horizontalCenter
Row
{
anchors.topMargin
:
5
spacing
:
20
text
:
"Place bet"
Label
{
onClicked
:
{
id
:
genLabel
txHash
.
text
=
eth
.
createTx
(
"e6716f9544a56c530d868e4bfbacb172315bdead"
,
textField
.
text
)
text
:
"Generic coin balance:"
}
Label
{
id
:
amountLabel
}
}
Row
{
spacing
:
20
TextField
{
id
:
address
placeholderText
:
"Address"
}
TextField
{
id
:
amount
placeholderText
:
"Amount"
}
}
Button
{
text
:
"Send coins"
onClicked
:
{
var
privKey
=
eth
.
getKey
().
privateKey
if
(
privKey
){
var
result
=
eth
.
transact
(
privKey
,
contractAddr
,
0
,
"100000"
,
"250"
,
"0x"
+
address
.
text
+
"
\n
"
+
amount
.
text
)
resultTx
.
text
=
result
.
hash
}
}
}
Label
{
id
:
resultTx
}
}
}
}
}
}
ethereal/assets/qml/wallet.qml
View file @
08de13a5
...
@@ -372,7 +372,15 @@ ApplicationWindow {
...
@@ -372,7 +372,15 @@ ApplicationWindow {
onAccepted
:
{
onAccepted
:
{
//ui.open(openAppDialog.fileUrl.toString())
//ui.open(openAppDialog.fileUrl.toString())
//ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
//ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
ui
.
openHtml
(
openAppDialog
.
fileUrl
.
toString
())
var
path
=
openAppDialog
.
fileUrl
.
toString
()
console
.
log
(
path
)
var
ext
=
path
.
split
(
'.'
).
pop
()
console
.
log
(
ext
)
if
(
ext
==
"html"
||
ext
==
"htm"
)
{
ui
.
openHtml
(
path
)
}
else
if
(
ext
==
"qml"
){
ui
.
openQml
(
path
)
}
}
}
}
}
...
...
ethereal/assets/qml/webapp.qml
View file @
08de13a5
...
@@ -103,6 +103,12 @@ ApplicationWindow {
...
@@ -103,6 +103,12 @@ ApplicationWindow {
postData
(
data
.
_seed
,
stateObject
)
postData
(
data
.
_seed
,
stateObject
)
break
break
case
"getTransactionsFor"
:
require
(
1
);
var
txs
=
eth
.
getTransactionsFor
(
data
.
args
[
0
],
true
)
postData
(
data
.
_seed
,
txs
)
break
case
"getBalance"
:
case
"getBalance"
:
require
(
1
);
require
(
1
);
...
...
ethereal/ui/qml_app.go
0 → 100644
View file @
08de13a5
package
ethui
import
(
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml"
)
type
QmlApplication
struct
{
win
*
qml
.
Window
engine
*
qml
.
Engine
lib
*
UiLib
path
string
}
func
NewQmlApplication
(
path
string
,
lib
*
UiLib
)
*
QmlApplication
{
engine
:=
qml
.
NewEngine
()
return
&
QmlApplication
{
engine
:
engine
,
path
:
path
,
lib
:
lib
}
}
func
(
app
*
QmlApplication
)
Create
()
error
{
component
,
err
:=
app
.
engine
.
LoadFile
(
app
.
path
)
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Debugln
(
err
)
}
app
.
win
=
component
.
CreateWindow
(
nil
)
return
nil
}
func
(
app
*
QmlApplication
)
Destroy
()
{
app
.
engine
.
Destroy
()
}
func
(
app
*
QmlApplication
)
NewWatcher
(
quitChan
chan
bool
)
{
}
// Events
func
(
app
*
QmlApplication
)
NewBlock
(
block
*
ethchain
.
Block
)
{
pblock
:=
&
ethpub
.
PBlock
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Hex
(
block
.
Hash
())}
app
.
win
.
Call
(
"onNewBlockCb"
,
pblock
)
}
func
(
app
*
QmlApplication
)
ObjectChanged
(
stateObject
*
ethchain
.
StateObject
)
{
app
.
win
.
Call
(
"onObjectChangeCb"
,
ethpub
.
NewPStateObject
(
stateObject
))
}
func
(
app
*
QmlApplication
)
StorageChanged
(
storageObject
*
ethchain
.
StorageState
)
{
app
.
win
.
Call
(
"onStorageChangeCb"
,
ethpub
.
NewPStorageState
(
storageObject
))
}
// Getters
func
(
app
*
QmlApplication
)
Engine
()
*
qml
.
Engine
{
return
app
.
engine
}
func
(
app
*
QmlApplication
)
Window
()
*
qml
.
Window
{
return
app
.
win
}
ethereal/ui/ui_lib.go
View file @
08de13a5
...
@@ -28,18 +28,11 @@ func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
...
@@ -28,18 +28,11 @@ func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
return
&
UiLib
{
engine
:
engine
,
eth
:
eth
,
assetPath
:
assetPath
}
return
&
UiLib
{
engine
:
engine
,
eth
:
eth
,
assetPath
:
assetPath
}
}
}
// Opens a QML file (external application)
func
(
ui
*
UiLib
)
OpenQml
(
path
string
)
{
func
(
ui
*
UiLib
)
Open
(
path
string
)
{
container
:=
NewQmlApplication
(
path
[
7
:
],
ui
)
component
,
err
:=
ui
.
engine
.
LoadFile
(
path
[
7
:
])
app
:=
NewExtApplication
(
container
,
ui
)
if
err
!=
nil
{
logger
.
Debugln
(
err
)
}
win
:=
component
.
CreateWindow
(
nil
)
go
func
()
{
go
app
.
run
()
win
.
Show
()
win
.
Wait
()
}()
}
}
func
(
ui
*
UiLib
)
OpenHtml
(
path
string
)
{
func
(
ui
*
UiLib
)
OpenHtml
(
path
string
)
{
...
...
ethereum/javascript_runtime.go
View file @
08de13a5
...
@@ -144,7 +144,7 @@ func (self *JSRE) initStdFuncs() {
...
@@ -144,7 +144,7 @@ func (self *JSRE) initStdFuncs() {
eth
.
Set
(
"require"
,
self
.
require
)
eth
.
Set
(
"require"
,
self
.
require
)
eth
.
Set
(
"stopMining"
,
self
.
stopMining
)
eth
.
Set
(
"stopMining"
,
self
.
stopMining
)
eth
.
Set
(
"startMining"
,
self
.
startMining
)
eth
.
Set
(
"startMining"
,
self
.
startMining
)
eth
.
Set
(
"
blockDo
"
,
self
.
execBlock
)
eth
.
Set
(
"
execBlock
"
,
self
.
execBlock
)
}
}
/*
/*
...
@@ -221,7 +221,7 @@ func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value {
...
@@ -221,7 +221,7 @@ func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value {
return
otto
.
UndefinedValue
()
return
otto
.
UndefinedValue
()
}
}
err
=
self
.
ethereum
.
BlockDo
(
ethutil
.
FromHex
(
hash
))
err
=
utils
.
BlockDo
(
self
.
ethereum
,
ethutil
.
FromHex
(
hash
))
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
return
otto
.
FalseValue
()
return
otto
.
FalseValue
()
...
...
ethereum/repl.go
View file @
08de13a5
package
main
package
main
import
(
import
(
"bufio"
"fmt"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/otto"
"github.com/obscuren/otto"
"io"
"os"
"path"
)
)
type
Repl
interface
{
type
Repl
interface
{
...
@@ -16,20 +21,40 @@ type JSRepl struct {
...
@@ -16,20 +21,40 @@ type JSRepl struct {
re
*
JSRE
re
*
JSRE
prompt
string
prompt
string
history
*
os
.
File
}
}
func
NewJSRepl
(
ethereum
*
eth
.
Ethereum
)
*
JSRepl
{
func
NewJSRepl
(
ethereum
*
eth
.
Ethereum
)
*
JSRepl
{
return
&
JSRepl
{
re
:
NewJSRE
(
ethereum
),
prompt
:
"> "
}
hist
,
err
:=
os
.
OpenFile
(
path
.
Join
(
ethutil
.
Config
.
ExecPath
,
"history"
),
os
.
O_RDWR
|
os
.
O_CREATE
,
os
.
ModePerm
)
if
err
!=
nil
{
panic
(
err
)
}
return
&
JSRepl
{
re
:
NewJSRE
(
ethereum
),
prompt
:
"> "
,
history
:
hist
}
}
}
func
(
self
*
JSRepl
)
Start
()
{
func
(
self
*
JSRepl
)
Start
()
{
logger
.
Infoln
(
"init JS Console"
)
logger
.
Infoln
(
"init JS Console"
)
reader
:=
bufio
.
NewReader
(
self
.
history
)
for
{
line
,
err
:=
reader
.
ReadString
(
'\n'
)
if
err
!=
nil
&&
err
==
io
.
EOF
{
break
}
else
if
err
!=
nil
{
fmt
.
Println
(
"error reading history"
,
err
)
break
}
addHistory
(
line
[
:
len
(
line
)
-
1
])
}
self
.
read
()
self
.
read
()
}
}
func
(
self
*
JSRepl
)
Stop
()
{
func
(
self
*
JSRepl
)
Stop
()
{
self
.
re
.
Stop
()
self
.
re
.
Stop
()
logger
.
Infoln
(
"exit JS Console"
)
logger
.
Infoln
(
"exit JS Console"
)
self
.
history
.
Close
()
}
}
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
...
...
ethereum/repl_darwin.go
View file @
08de13a5
...
@@ -102,7 +102,9 @@ L:
...
@@ -102,7 +102,9 @@ L:
break
L
break
L
}
}
addHistory
(
str
[
:
len
(
str
)
-
1
])
//allow user to recall this line
hist
:=
str
[
:
len
(
str
)
-
1
]
addHistory
(
hist
)
//allow user to recall this line
self
.
history
.
WriteString
(
str
)
self
.
parseInput
(
str
)
self
.
parseInput
(
str
)
...
...
utils/cmd.go
View file @
08de13a5
...
@@ -219,3 +219,21 @@ func StopMining(ethereum *eth.Ethereum) bool {
...
@@ -219,3 +219,21 @@ func StopMining(ethereum *eth.Ethereum) bool {
}
}
return
false
return
false
}
}
// Replay block
func
BlockDo
(
ethereum
*
eth
.
Ethereum
,
hash
[]
byte
)
error
{
block
:=
ethereum
.
BlockChain
()
.
GetBlock
(
hash
)
if
block
==
nil
{
return
fmt
.
Errorf
(
"unknown block %x"
,
hash
)
}
parent
:=
ethereum
.
BlockChain
()
.
GetBlock
(
block
.
PrevHash
)
_
,
err
:=
ethereum
.
StateManager
()
.
ApplyDiff
(
parent
.
State
(),
parent
,
block
)
if
err
!=
nil
{
return
err
}
return
nil
}
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