Skip to content

Commit dc944f7

Browse files
committed
Added some lookup helper methods for name reg
1 parent d5d1e50 commit dc944f7

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

mist/assets/qml/views/jeffcoin/jeffcoin.qml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Rectangle {
2222

2323
var me = eth.key().address;
2424
if((to == me|| from == me) && message.input.length == 128) {
25+
var to = eth.lookupName(to)
26+
var from = eth.lookupName(from)
2527
txModel.insert(0, {confirmations: blockNumber - message.number, from: from, to: to, value: value})
2628
}
2729
}
@@ -151,7 +153,11 @@ Rectangle {
151153
Button {
152154
text: "Send"
153155
onClicked: {
154-
eth.transact({from: eth.key().privateKey, to:address, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]})
156+
var lookup = eth.lookupAddress(address)
157+
if(lookup.length == 0)
158+
lookup = address
159+
160+
eth.transact({from: eth.key().privateKey, to:lookup, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]})
155161
}
156162
}
157163
}

mist/assets/qml/views/wallet.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ Rectangle {
160160
function addTxs(messages) {
161161
for(var i = 0; i < messages.length; i++) {
162162
var message = messages.get(i);
163-
txModel.insert(0, {num: txModel.count, from: message.from, to: message.to, value: eth.numberToHuman(message.value)})
163+
var to = eth.lookupName(message.to);
164+
var from = eth.lookupName(message.from);
165+
txModel.insert(0, {num: txModel.count, from: from, to: to, value: eth.numberToHuman(message.value)})
164166
}
165167
}
166168
}

mist/ui_lib.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,32 @@ func (self *UiLib) LookupDomain(domain string) string {
7171
}
7272
}
7373

74+
func (self *UiLib) LookupName(addr string) string {
75+
var (
76+
nameReg = self.World().Config().Get("NameReg")
77+
lookup = nameReg.Storage(ethutil.Hex2Bytes(addr))
78+
)
79+
80+
if lookup.Len() != 0 {
81+
return strings.Trim(lookup.Str(), "\x00")
82+
}
83+
84+
return addr
85+
}
86+
87+
func (self *UiLib) LookupAddress(name string) string {
88+
var (
89+
nameReg = self.World().Config().Get("NameReg")
90+
lookup = nameReg.Storage(ethutil.RightPadBytes([]byte(name), 32))
91+
)
92+
93+
if lookup.Len() != 0 {
94+
return ethutil.Bytes2Hex(lookup.Bytes())
95+
}
96+
97+
return ""
98+
}
99+
74100
func (self *UiLib) PastPeers() *ethutil.List {
75101
return ethutil.NewList(eth.PastPeers())
76102
}

0 commit comments

Comments
 (0)