Skip to content

Commit

Permalink
Best Version Yet
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Jul 22, 2024
1 parent ad666ae commit 578bbf8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
18 changes: 14 additions & 4 deletions app/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ var addrToHistoryMap = map[base.Address][]TransactionEx{}
var m = sync.Mutex{}

func (a *App) GetHistoryPage(addr string, first, pageSize int) []TransactionEx {
address := base.HexToAddress(addr)
address, ok := a.ConvertToAddress(addr)
if !ok {
a.SendMessage(base.ZeroAddr, Error, "Invalid address")
return []TransactionEx{}
}

m.Lock()
_, exists := addrToHistoryMap[address]
Expand Down Expand Up @@ -78,7 +82,11 @@ func (a *App) GetHistoryPage(addr string, first, pageSize int) []TransactionEx {
}

func (a *App) GetHistoryCnt(addr string) int64 {
address := base.HexToAddress(addr)
address, ok := a.ConvertToAddress(addr)
if !ok {
a.SendMessage(base.ZeroAddr, Error, "Invalid address")
return 0
}

opts := sdk.ListOptions{
Addrs: []string{addr},
Expand All @@ -93,14 +101,16 @@ func (a *App) GetHistoryCnt(addr string) int64 {
return monitors[0].NRecords
}

var e sync.Mutex

func (a *App) ConvertToAddress(addr string) (base.Address, bool) {
if !strings.HasSuffix(addr, ".eth") {
ret := base.HexToAddress(addr)
return ret, ret != base.ZeroAddr
}

m.Lock()
defer m.Unlock()
e.Lock()
defer e.Unlock()
if ensAddr, exists := a.ensMap[addr]; exists {
return ensAddr, true
}
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/views/History/HistoryView.module.css
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.small {
width: 10px;
max-width: 10px;
min-width: 10px;
width: 30px;
max-width: 30px;
min-width: 30px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
}

.small-centered {
width: 10px;
max-width: 10px;
min-width: 10px;
width: 30px;
max-width: 30px;
min-width: 30px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
Expand Down
11 changes: 1 addition & 10 deletions frontend/src/views/History/HistoryView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ import { EditableSelect, View, ViewStatus } from "@components";
import { useKeyboardPaging2 } from "@hooks";

export function HistoryView() {
// const [address, setAddress] = useState<string>("0x5088d623ba0fcf0131e0897a91734a4d83596aa0");
// const [address, setAddress] = useState<string>("0xee906d7d5f1748258174be4cbc38930302ab7b42");
// const [address, setAddress] = useState<string>("0x8bae48f227d978d084b009b775222baaf61ed9fe");
// const [address, setAddress] = useState<string>("0x3fb1cd2cd96c6d5c0b5eb3322d807b34482481d4");
// const [address, setAddress] = useState<string>("0x5ed8cee6b63b1c6afce3ad7c92f4fd7e1b8fad9f");
// const [address, setAddress] = useState<string>("0x1db3439a222c519ab44bb1144fc28167b4fa6ee6");
// const [address, setAddress] = useState<string>("0xd8da6bf26964af9d7eed9e03e53415d37aa96045");
// const [address, setAddress] = useState<string>("0x9531c059098e3d194ff87febb587ab07b30b1306");
// const [address, setAddress] = useState<string>("0xf503017d7baf7fbc0fff7492b751025c6a78179b");
const [address, setAddress] = useState<string>("trueblocks.eth");
const [count, setCount] = useState<number>(0);
const [loading, setLoading] = useState<boolean>(false);
Expand All @@ -38,8 +29,8 @@ export function HistoryView() {
}, [count, curItem, perPage]);

useEffect(() => {
setLoading(true);
try {
setLoading(true);
const fetch = async (addr: string, currentItem: number, itemsPerPage: number) => {
const cnt = await GetHistoryCnt(addr);
setCount(cnt);
Expand Down

0 comments on commit 578bbf8

Please sign in to comment.