Skip to content

Commit f5091e5

Browse files
viktor32karalabe
authored andcommitted
internal/ethapi: fix js tracer to properly decode addresses (#15297)
* Add method getBalanceFromJs for work with address as bytes * expect []byte instead of common.Address in ethapi tracer
1 parent 0dbf55d commit f5091e5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

internal/ethapi/tracer.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,28 +130,28 @@ type dbWrapper struct {
130130
}
131131

132132
// getBalance retrieves an account's balance
133-
func (dw *dbWrapper) getBalance(addr common.Address) *big.Int {
134-
return dw.db.GetBalance(addr)
133+
func (dw *dbWrapper) getBalance(addr []byte) *big.Int {
134+
return dw.db.GetBalance(common.BytesToAddress(addr))
135135
}
136136

137137
// getNonce retrieves an account's nonce
138-
func (dw *dbWrapper) getNonce(addr common.Address) uint64 {
139-
return dw.db.GetNonce(addr)
138+
func (dw *dbWrapper) getNonce(addr []byte) uint64 {
139+
return dw.db.GetNonce(common.BytesToAddress(addr))
140140
}
141141

142142
// getCode retrieves an account's code
143-
func (dw *dbWrapper) getCode(addr common.Address) []byte {
144-
return dw.db.GetCode(addr)
143+
func (dw *dbWrapper) getCode(addr []byte) []byte {
144+
return dw.db.GetCode(common.BytesToAddress(addr))
145145
}
146146

147147
// getState retrieves an account's state data for the given hash
148-
func (dw *dbWrapper) getState(addr common.Address, hash common.Hash) common.Hash {
149-
return dw.db.GetState(addr, hash)
148+
func (dw *dbWrapper) getState(addr []byte, hash common.Hash) common.Hash {
149+
return dw.db.GetState(common.BytesToAddress(addr), hash)
150150
}
151151

152152
// exists returns true iff the account exists
153-
func (dw *dbWrapper) exists(addr common.Address) bool {
154-
return dw.db.Exist(addr)
153+
func (dw *dbWrapper) exists(addr []byte) bool {
154+
return dw.db.Exist(common.BytesToAddress(addr))
155155
}
156156

157157
// toValue returns an otto.Value for the dbWrapper

0 commit comments

Comments
 (0)