diff --git a/.gitignore b/.gitignore
index 98fe00b3..5cc7d1f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ build/*.deb
.bin-image
.deb-image
\.idea/
+__debug*
\ No newline at end of file
diff --git a/api/worker.go b/api/worker.go
index bab95444..864c6314 100644
--- a/api/worker.go
+++ b/api/worker.go
@@ -569,6 +569,27 @@ func (w *Worker) getContractDescriptorInfo(cd bchain.AddressDescriptor, typeFrom
glog.Errorf("StoreContractInfo error %v, contract %v", err, cd)
}
}
+ } else if (len(contractInfo.Name) > 0 && contractInfo.Name[0] == 0) || (len(contractInfo.Symbol) > 0 && contractInfo.Symbol[0] == 0) {
+ // fix contract name/symbol that was parsed as a string consisting of zeroes
+ blockchainContractInfo, err := w.chain.GetContractInfo(cd)
+ if err != nil {
+ glog.Errorf("GetContractInfo from chain error %v, contract %v", err, cd)
+ } else {
+ if len(blockchainContractInfo.Name) > 0 && blockchainContractInfo.Name[0] != 0 {
+ contractInfo.Name = blockchainContractInfo.Name
+ } else {
+ contractInfo.Name = ""
+ }
+ if len(blockchainContractInfo.Symbol) > 0 && blockchainContractInfo.Symbol[0] != 0 {
+ contractInfo.Symbol = blockchainContractInfo.Symbol
+ } else {
+ contractInfo.Symbol = ""
+ }
+ contractInfo.Decimals = blockchainContractInfo.Decimals
+ if err = w.db.StoreContractInfo(contractInfo); err != nil {
+ glog.Errorf("StoreContractInfo error %v, contract %v", err, cd)
+ }
+ }
}
return contractInfo, validContract, nil
}
@@ -957,8 +978,10 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto
totalResults = int(ca.TotalTxs)
} else if filter.Vout == 0 {
totalResults = int(ca.NonContractTxs)
- } else if filter.Vout > 0 && filter.Vout-1 < len(ca.Contracts) {
- totalResults = int(ca.Contracts[filter.Vout-1].Txs)
+ } else if filter.Vout == db.InternalTxIndexOffset {
+ totalResults = int(ca.InternalTxs)
+ } else if filter.Vout >= db.ContractIndexOffset && filter.Vout-db.ContractIndexOffset < len(ca.Contracts) {
+ totalResults = int(ca.Contracts[filter.Vout-db.ContractIndexOffset].Txs)
} else if filter.Vout == AddressFilterVoutQueryNotNecessary {
totalResults = 0
}
@@ -972,16 +995,17 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto
BalanceSat: *b,
}
}
- // special handling if filtering for a contract, check the ballance of it in the blockchain
- if len(filterDesc) > 0 && details >= AccountDetailsTokens {
- t, err := w.getEthereumContractBalanceFromBlockchain(addrDesc, filterDesc, details)
- if err != nil {
- return nil, nil, nil, 0, 0, 0, 0, err
- }
- tokens = []Token{*t}
- // switch off query for transactions, there are no transactions
- filter.Vout = AddressFilterVoutQueryNotNecessary
+ }
+ // special handling if filtering for a contract, return the contract details even though the address had no transactions with it
+ if len(tokens) == 0 && len(filterDesc) > 0 && details >= AccountDetailsTokens {
+ t, err := w.getEthereumContractBalanceFromBlockchain(addrDesc, filterDesc, details)
+ if err != nil {
+ return nil, nil, nil, 0, 0, 0, 0, err
}
+ tokens = []Token{*t}
+ // switch off query for transactions, there are no transactions
+ filter.Vout = AddressFilterVoutQueryNotNecessary
+ totalResults = -1
}
return ba, tokens, ci, n, nonContractTxs, internalTxs, totalResults, nil
}
diff --git a/db/rocksdb_ethereumtype.go b/db/rocksdb_ethereumtype.go
index b29a8fe9..b16429b3 100644
--- a/db/rocksdb_ethereumtype.go
+++ b/db/rocksdb_ethereumtype.go
@@ -812,6 +812,10 @@ func (d *RocksDB) storeContractInfo(wb *grocksdb.WriteBatch, contractInfo *bchai
contractInfo = storedCI
}
wb.PutCF(d.cfh[cfContracts], key, packContractInfo(contractInfo))
+ cacheKey := string(key)
+ cachedContractsMux.Lock()
+ delete(cachedContracts, cacheKey)
+ cachedContractsMux.Unlock()
}
return nil
}
diff --git a/server/public_ethereumtype_test.go b/server/public_ethereumtype_test.go
index 221ef57f..41d31643 100644
--- a/server/public_ethereumtype_test.go
+++ b/server/public_ethereumtype_test.go
@@ -24,7 +24,7 @@ func httpTestsEthereumType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "text/html; charset=utf-8",
body: []string{
- `
Trezor Fake Coin ExplorerAddress 0.000000000123450123 FAKE
0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b
Confirmed
| Balance | 0.000000000123450123 FAKE |
| Transactions | 2 |
| Non-contract Transactions | 0 |
| Internal Transactions | 0 |
| Nonce | 123 |
| ERC20 Tokens | |
| ERC721 Tokens | |
Transactions
ERC721 Token Transfers
| 0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b |
Fee: 0.00008794500041041 FAKE
Unconfirmed Transaction!0 FAKE
ERC20 Token Transfers
| 0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b |
871.180000950184 S74
| 0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b |
7.674999999999991915 S13
Fee: 0.000216368 FAKE
Unconfirmed Transaction!0 FAKE
`,
+ `Trezor Fake Coin ExplorerAddress 0.000000000123450123 FAKE
0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b
Confirmed
| Balance | 0.000000000123450123 FAKE |
| Transactions | 2 |
| Non-contract Transactions | 0 |
| Internal Transactions | 0 |
| Nonce | 123 |
| ERC20 Tokens | |
| ERC721 Tokens | |
Transactions
ERC721 Token Transfers
| 0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b |
Fee: 0.00008794500041041 FAKE
Unconfirmed Transaction!0 FAKE
ERC20 Token Transfers
| 0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b |
871.180000950184 S74
| 0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b |
7.674999999999991915 S13
Fee: 0.000216368 FAKE
Unconfirmed Transaction!0 FAKE
`,
},
},
{
@@ -33,7 +33,7 @@ func httpTestsEthereumType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "text/html; charset=utf-8",
body: []string{
- `Trezor Fake Coin ExplorerAddress 0.000000000123450093 FAKE
0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e
Confirmed
| Balance | 0.000000000123450093 FAKE |
| Transactions | 1 |
| Non-contract Transactions | 1 |
| Internal Transactions | 0 |
| Nonce | 93 |
| ERC1155 Tokens | |
Transactions
| 0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e |
0 FAKE
ERC1155 Token Transfers
| 0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e |
1 S111 of ID
1776, 10 S111 of ID
1898Fee: 0.000081891755740665 FAKE
Unconfirmed Transaction!0 FAKE
`,
+ `Trezor Fake Coin ExplorerAddress 0.000000000123450093 FAKE
0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e
Confirmed
| Balance | 0.000000000123450093 FAKE |
| Transactions | 1 |
| Non-contract Transactions | 1 |
| Internal Transactions | 0 |
| Nonce | 93 |
| ERC1155 Tokens | |
Transactions
| 0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e |
0 FAKE
ERC1155 Token Transfers
| 0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e |
1 S111 of ID
1776, 10 S111 of ID
1898Fee: 0.000081891755740665 FAKE
Unconfirmed Transaction!0 FAKE
`,
},
},
{
diff --git a/static/templates/address.html b/static/templates/address.html
index 590da4a7..c3bc0c9e 100644
--- a/static/templates/address.html
+++ b/static/templates/address.html
@@ -1,5 +1,5 @@
{{define "specific"}}{{$cs := .CoinShortcut}}{{$addr := .Address}}{{$data := .}}
-{{if $addr.ContractInfo}}Contract {{$addr.ContractInfo.Name}} ({{$addr.ContractInfo.Symbol}}){{else}}Address{{end}} {{formatAmount $addr.BalanceSat}} {{$cs}}
+{{if $addr.ContractInfo}}Contract {{$addr.ContractInfo.Name}}{{if $addr.ContractInfo.Symbol}} ({{$addr.ContractInfo.Symbol}}){{end}}{{else}}Address{{end}} {{formatAmount $addr.BalanceSat}} {{$cs}}
{{$addr.AddrStr}}
@@ -10,6 +10,26 @@
{{- if eq .ChainType 1 -}}
+ {{if $addr.ContractInfo}}
+ {{if $addr.ContractInfo.Type}}
+
+ | Contract type |
+ {{$addr.ContractInfo.Type}} |
+
+ {{end}}
+ {{if $addr.ContractInfo.CreatedInBlock}}
+
+ | Created in Block |
+ {{$addr.ContractInfo.CreatedInBlock}} |
+
+ {{end}}
+ {{if $addr.ContractInfo.DestructedInBlock}}
+
+ | Destructed in Block |
+ {{$addr.ContractInfo.DestructedInBlock}} |
+
+ {{end}}
+ {{end}}
| Balance |
{{formatAmount $addr.BalanceSat}} {{$cs}} |
@@ -158,19 +178,31 @@
{{- end}}{{if or $addr.Transactions $addr.Filter -}}
Transactions
-