forked from cerc-io/plugeth
Added some lookup helper methods for name reg
This commit is contained in:
parent
d5d1e50365
commit
dc944f7518
@ -22,6 +22,8 @@ Rectangle {
|
||||
|
||||
var me = eth.key().address;
|
||||
if((to == me|| from == me) && message.input.length == 128) {
|
||||
var to = eth.lookupName(to)
|
||||
var from = eth.lookupName(from)
|
||||
txModel.insert(0, {confirmations: blockNumber - message.number, from: from, to: to, value: value})
|
||||
}
|
||||
}
|
||||
@ -151,7 +153,11 @@ Rectangle {
|
||||
Button {
|
||||
text: "Send"
|
||||
onClicked: {
|
||||
eth.transact({from: eth.key().privateKey, to:address, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]})
|
||||
var lookup = eth.lookupAddress(address)
|
||||
if(lookup.length == 0)
|
||||
lookup = address
|
||||
|
||||
eth.transact({from: eth.key().privateKey, to:lookup, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,9 @@ Rectangle {
|
||||
function addTxs(messages) {
|
||||
for(var i = 0; i < messages.length; i++) {
|
||||
var message = messages.get(i);
|
||||
txModel.insert(0, {num: txModel.count, from: message.from, to: message.to, value: eth.numberToHuman(message.value)})
|
||||
var to = eth.lookupName(message.to);
|
||||
var from = eth.lookupName(message.from);
|
||||
txModel.insert(0, {num: txModel.count, from: from, to: to, value: eth.numberToHuman(message.value)})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,32 @@ func (self *UiLib) LookupDomain(domain string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *UiLib) LookupName(addr string) string {
|
||||
var (
|
||||
nameReg = self.World().Config().Get("NameReg")
|
||||
lookup = nameReg.Storage(ethutil.Hex2Bytes(addr))
|
||||
)
|
||||
|
||||
if lookup.Len() != 0 {
|
||||
return strings.Trim(lookup.Str(), "\x00")
|
||||
}
|
||||
|
||||
return addr
|
||||
}
|
||||
|
||||
func (self *UiLib) LookupAddress(name string) string {
|
||||
var (
|
||||
nameReg = self.World().Config().Get("NameReg")
|
||||
lookup = nameReg.Storage(ethutil.RightPadBytes([]byte(name), 32))
|
||||
)
|
||||
|
||||
if lookup.Len() != 0 {
|
||||
return ethutil.Bytes2Hex(lookup.Bytes())
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *UiLib) PastPeers() *ethutil.List {
|
||||
return ethutil.NewList(eth.PastPeers())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user