Skip to content

Commit

Permalink
Has History (doesn't build)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Jul 18, 2024
1 parent 98558cf commit c31cbf6
Show file tree
Hide file tree
Showing 16 changed files with 880 additions and 5 deletions.
44 changes: 44 additions & 0 deletions app/history.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package app

import (
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
)

var historyMap = map[base.Address][]types.Transaction{}

func (a *App) GetHistory(addr string, first, pageSize int) []types.Transaction {
address := base.HexToAddress(addr)
if address.IsZero() {
return []types.Transaction{
{
TransactionIndex: 1,
BlockNumber: 1,
},
{
TransactionIndex: 2,
BlockNumber: 2,
},
{
TransactionIndex: 3,
BlockNumber: 3,
},
}
}

var ret []types.Transaction
if len(historyMap[address]) == 0 {
return ret
}
first = base.Max(0, base.Min(first, len(historyMap[address])-1))
last := base.Min(len(historyMap[address]), first+pageSize)
return historyMap[address][first:last]
}

func (a *App) GetHistoryCnt(addr string) int {
address := base.HexToAddress(addr)
if address.IsZero() {
return 3
}
return len(historyMap[address])
}
1 change: 1 addition & 0 deletions frontend/src/components/global/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function Menu() {
{ route: "/dalle", label: "Dalle", icon: <IconSpider /> },
{ route: "/names", label: "Names", icon: <IconTag /> },
{ route: "/series", label: "Series", icon: <IconList /> },
{ route: "/history", label: "History", icon: <IconList /> },
{ route: "/settings", label: "Settings", icon: <IconSettings /> },
];

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/global/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from "react";
import { Route, Switch, useLocation } from "wouter";
import classes from "@/App.module.css";
import { DalleView, NamesView, HomeView, SeriesView, SettingsView } from "@/views";
import { DalleView, NamesView, HomeView, SeriesView, HistoryView, SettingsView } from "@/views";
import { GetLast } from "@gocode/app/App";

export const Routes = () => {
Expand All @@ -17,6 +17,7 @@ export const Routes = () => {
{ route: "/dalle", component: DalleView },
{ route: "/names", component: NamesView },
{ route: "/series", component: SeriesView },
{ route: "/history", component: HistoryView },
{ route: "/settings", component: SettingsView },
{ route: "/", component: HomeView },
];
Expand Down
34 changes: 34 additions & 0 deletions frontend/src/views/History/HistoryView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { useState, useEffect } from "react";
import { GetHistory, GetHistoryCnt } from "@gocode/app/App";
import classes from "@/App.module.css";
import { View, ViewStatus } from "@/components/view";
import { Stack, Title } from "@mantine/core";
import { types } from "@gocode/models";

export function HistoryView() {
const [address, setAddress] = useState<string>("");
const [cnt, setCnt] = useState<number>(0);
const [txs, setTxs] = useState<types.Transaction[]>([]);

useEffect(() => {
setAddress("0xf503017d7baf7fbc0fff7492b751025c6a78179b");
GetHistoryCnt(address).then((cnt: number) => {
setCnt(cnt);
});
GetHistory(address, 0, 20).then((txs: types.Transaction[]) => {
setTxs(txs);
});
}, []);

return (
<View>
<Title order={3}>History Title</Title>
<Stack className={classes.mainContent}>
<div>{address}</div>
<div>{cnt}</div>
<div>{JSON.stringify(txs)}</div>
</Stack>
<ViewStatus>Status / Progress</ViewStatus>
</View>
);
}
3 changes: 2 additions & 1 deletion frontend/src/views/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./Dalle/DalleView";
export * from "./Home/HomeView";
export * from "./Names/NamesView";
export * from "./Settings/SettingsView";
export * from "./Series/SeriesView";
export * from "./History/HistoryView";
export * from "./Settings/SettingsView";
4 changes: 4 additions & 0 deletions frontend/wailsjs/go/app/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function GetFilelist(arg1:string):Promise<Array<string>>;

export function GetFilename(arg1:string):Promise<string>;

export function GetHistory(arg1:string,arg2:number,arg3:number):Promise<Array<types.Transaction>>;

export function GetHistoryCnt(arg1:string):Promise<number>;

export function GetJson(arg1:string):Promise<string>;

export function GetLast(arg1:string):Promise<string>;
Expand Down
8 changes: 8 additions & 0 deletions frontend/wailsjs/go/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export function GetFilename(arg1) {
return window['go']['app']['App']['GetFilename'](arg1);
}

export function GetHistory(arg1, arg2, arg3) {
return window['go']['app']['App']['GetHistory'](arg1, arg2, arg3);
}

export function GetHistoryCnt(arg1) {
return window['go']['app']['App']['GetHistoryCnt'](arg1);
}

export function GetJson(arg1) {
return window['go']['app']['App']['GetJson'](arg1);
}
Expand Down
51 changes: 51 additions & 0 deletions frontend/wailsjs/go/base/Address.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {big} from '../models';
import {common} from '../models';
import {fmt} from '../models';
import {base} from '../models';
import {driver} from '../models';

export function Big():Promise<big.Int>;

export function Bytes():Promise<Array<number>>;

export function CheckSum():Promise<string>;

export function Cmp(arg1:common.Address):Promise<number>;

export function Common():Promise<common.Address>;

export function Encoded32():Promise<string>;

export function Format(arg1:fmt.State,arg2:number):Promise<void>;

export function Hex():Promise<string>;

export function ImplementsGraphQLType(arg1:string):Promise<boolean>;

export function IsZero():Promise<boolean>;

export function MarshalText():Promise<Array<number>>;

export function Pad32():Promise<string>;

export function Prefix(arg1:number):Promise<string>;

export function Scan(arg1:any):Promise<void>;

export function SetBytes(arg1:Array<number>):Promise<void>;

export function SetCommon(arg1:common.Address):Promise<base.Address>;

export function SetHex(arg1:string):Promise<void>;

export function String():Promise<string>;

export function UnmarshalGraphQL(arg1:any):Promise<void>;

export function UnmarshalJSON(arg1:Array<number>):Promise<void>;

export function UnmarshalText(arg1:Array<number>):Promise<void>;

export function Value():Promise<driver.Value>;
91 changes: 91 additions & 0 deletions frontend/wailsjs/go/base/Address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

export function Big() {
return window['go']['base']['Address']['Big']();
}

export function Bytes() {
return window['go']['base']['Address']['Bytes']();
}

export function CheckSum() {
return window['go']['base']['Address']['CheckSum']();
}

export function Cmp(arg1) {
return window['go']['base']['Address']['Cmp'](arg1);
}

export function Common() {
return window['go']['base']['Address']['Common']();
}

export function Encoded32() {
return window['go']['base']['Address']['Encoded32']();
}

export function Format(arg1, arg2) {
return window['go']['base']['Address']['Format'](arg1, arg2);
}

export function Hex() {
return window['go']['base']['Address']['Hex']();
}

export function ImplementsGraphQLType(arg1) {
return window['go']['base']['Address']['ImplementsGraphQLType'](arg1);
}

export function IsZero() {
return window['go']['base']['Address']['IsZero']();
}

export function MarshalText() {
return window['go']['base']['Address']['MarshalText']();
}

export function Pad32() {
return window['go']['base']['Address']['Pad32']();
}

export function Prefix(arg1) {
return window['go']['base']['Address']['Prefix'](arg1);
}

export function Scan(arg1) {
return window['go']['base']['Address']['Scan'](arg1);
}

export function SetBytes(arg1) {
return window['go']['base']['Address']['SetBytes'](arg1);
}

export function SetCommon(arg1) {
return window['go']['base']['Address']['SetCommon'](arg1);
}

export function SetHex(arg1) {
return window['go']['base']['Address']['SetHex'](arg1);
}

export function String() {
return window['go']['base']['Address']['String']();
}

export function UnmarshalGraphQL(arg1) {
return window['go']['base']['Address']['UnmarshalGraphQL'](arg1);
}

export function UnmarshalJSON(arg1) {
return window['go']['base']['Address']['UnmarshalJSON'](arg1);
}

export function UnmarshalText(arg1) {
return window['go']['base']['Address']['UnmarshalText'](arg1);
}

export function Value() {
return window['go']['base']['Address']['Value']();
}
Loading

0 comments on commit c31cbf6

Please sign in to comment.