-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
880 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'](); | ||
} |
Oops, something went wrong.