diff --git a/app/app.go b/app/app.go index 1efb45b..88dc08b 100644 --- a/app/app.go +++ b/app/app.go @@ -13,8 +13,10 @@ import ( "text/template" "time" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-dalledress/pkg/config" "github.com/TrueBlocks/trueblocks-dalledress/pkg/dalle" @@ -35,6 +37,29 @@ type App struct { Series dalle.Series `json:"series"` names []types.Name dalleCache map[string]*dalle.DalleDress + renderCtxs map[base.Address][]output.RenderCtx +} + +func (a *App) RegisterRenderCtx(addr base.Address, ctx output.RenderCtx) { + if a.renderCtxs == nil { + a.renderCtxs = make(map[base.Address][]output.RenderCtx) + } + a.renderCtxs[addr] = append(a.renderCtxs[addr], ctx) +} + +func (a *App) Cancel(addr base.Address) (int, bool) { + if len(a.renderCtxs) == 0 { + return 0, false + } + if a.renderCtxs[addr] == nil { + return 0, true + } + n := len(a.renderCtxs[addr]) + for i := 0; i < len(a.renderCtxs[addr]); i++ { + a.renderCtxs[addr][i].Cancel() + } + a.renderCtxs[addr] = nil + return n, true } func NewApp() *App { @@ -62,6 +87,7 @@ func NewApp() *App { if a.authorTemplate, err = template.New("author").Parse(authorTemplate); err != nil { logger.Fatal("could not create prompt template:", err) } + logger.Info() logger.Info("Compiled templates") a.ReloadDatabases() diff --git a/app/backend.go b/app/backend.go index 634f5f5..931a1ae 100644 --- a/app/backend.go +++ b/app/backend.go @@ -6,7 +6,7 @@ import ( "strings" "sync" - "github.com/TrueBlocks/trueblocks-core/sdk" + "github.com/TrueBlocks/trueblocks-core/sdk/v3" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" "github.com/TrueBlocks/trueblocks-dalledress/pkg/dalle" diff --git a/app/history.go b/app/history.go index ab34ff1..cbc8961 100644 --- a/app/history.go +++ b/app/history.go @@ -5,7 +5,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) -var historyMap = map[base.Address][]types.Transaction{} +var addrToHistoryMap = map[base.Address][]types.Transaction{} func (a *App) GetHistory(addr string, first, pageSize int) []types.Transaction { address := base.HexToAddress(addr) @@ -14,25 +14,28 @@ func (a *App) GetHistory(addr string, first, pageSize int) []types.Transaction { { TransactionIndex: 1, BlockNumber: 1, + BlockHash: base.HexToHash("0x730724cb08a6eb17bf6b3296359d261570d343ea7944a17a9d7287d77900db01"), }, { TransactionIndex: 2, BlockNumber: 2, + BlockHash: base.HexToHash("0x730724cb08a6eb17bf6b3296359d261570d343ea7944a17a9d7287d77900db02"), }, { TransactionIndex: 3, BlockNumber: 3, + BlockHash: base.HexToHash("0x730724cb08a6eb17bf6b3296359d261570d343ea7944a17a9d7287d77900db03"), }, } } var ret []types.Transaction - if len(historyMap[address]) == 0 { + if len(addrToHistoryMap[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] + first = base.Max(0, base.Min(first, len(addrToHistoryMap[address])-1)) + last := base.Min(len(addrToHistoryMap[address]), first+pageSize) + return addrToHistoryMap[address][first:last] } func (a *App) GetHistoryCnt(addr string) int { @@ -40,5 +43,5 @@ func (a *App) GetHistoryCnt(addr string) int { if address.IsZero() { return 3 } - return len(historyMap[address]) + return len(addrToHistoryMap[address]) } diff --git a/app/names.go b/app/names.go index 01d1597..7e3b9e3 100644 --- a/app/names.go +++ b/app/names.go @@ -1,7 +1,7 @@ package app import ( - "github.com/TrueBlocks/trueblocks-core/sdk" + "github.com/TrueBlocks/trueblocks-core/sdk/v3" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) diff --git a/frontend/wailsjs/go/app/App.d.ts b/frontend/wailsjs/go/app/App.d.ts index ad97eaa..97f44ae 100755 --- a/frontend/wailsjs/go/app/App.d.ts +++ b/frontend/wailsjs/go/app/App.d.ts @@ -1,8 +1,12 @@ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // This file is automatically generated. DO NOT EDIT +import {base} from '../models'; import {types} from '../models'; import {config} from '../models'; import {dalle} from '../models'; +import {output} from '../models'; + +export function Cancel(arg1:base.Address):Promise; export function GenerateEnhanced(arg1:string):Promise; @@ -46,6 +50,8 @@ export function LoadSeries():Promise; export function MakeDalleDress(arg1:string):Promise; +export function RegisterRenderCtx(arg1:base.Address,arg2:output.RenderCtx):Promise; + export function ReloadDatabases():Promise; export function Save(arg1:string):Promise; diff --git a/frontend/wailsjs/go/app/App.js b/frontend/wailsjs/go/app/App.js index fc728e6..27f1abd 100755 --- a/frontend/wailsjs/go/app/App.js +++ b/frontend/wailsjs/go/app/App.js @@ -2,6 +2,10 @@ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // This file is automatically generated. DO NOT EDIT +export function Cancel(arg1) { + return window['go']['app']['App']['Cancel'](arg1); +} + export function GenerateEnhanced(arg1) { return window['go']['app']['App']['GenerateEnhanced'](arg1); } @@ -86,6 +90,10 @@ export function MakeDalleDress(arg1) { return window['go']['app']['App']['MakeDalleDress'](arg1); } +export function RegisterRenderCtx(arg1, arg2) { + return window['go']['app']['App']['RegisterRenderCtx'](arg1, arg2); +} + export function ReloadDatabases() { return window['go']['app']['App']['ReloadDatabases'](); } diff --git a/frontend/wailsjs/go/base/Address.d.ts b/frontend/wailsjs/go/base/Address.d.ts deleted file mode 100755 index 754dc27..0000000 --- a/frontend/wailsjs/go/base/Address.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -// 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; - -export function Bytes():Promise>; - -export function CheckSum():Promise; - -export function Cmp(arg1:common.Address):Promise; - -export function Common():Promise; - -export function Encoded32():Promise; - -export function Format(arg1:fmt.State,arg2:number):Promise; - -export function Hex():Promise; - -export function ImplementsGraphQLType(arg1:string):Promise; - -export function IsZero():Promise; - -export function MarshalText():Promise>; - -export function Pad32():Promise; - -export function Prefix(arg1:number):Promise; - -export function Scan(arg1:any):Promise; - -export function SetBytes(arg1:Array):Promise; - -export function SetCommon(arg1:common.Address):Promise; - -export function SetHex(arg1:string):Promise; - -export function String():Promise; - -export function UnmarshalGraphQL(arg1:any):Promise; - -export function UnmarshalJSON(arg1:Array):Promise; - -export function UnmarshalText(arg1:Array):Promise; - -export function Value():Promise; diff --git a/frontend/wailsjs/go/base/Address.js b/frontend/wailsjs/go/base/Address.js deleted file mode 100755 index 6f44a02..0000000 --- a/frontend/wailsjs/go/base/Address.js +++ /dev/null @@ -1,91 +0,0 @@ -// @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'](); -} diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index 06f1bf2..bfd6967 100755 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -175,6 +175,23 @@ export namespace dalle { } +export namespace output { + + export class RenderCtx { + + + static createFrom(source: any = {}) { + return new RenderCtx(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + + } + } + +} + export namespace types { export class Parameter { diff --git a/frontend/wailsjs/go/types/Transaction.d.ts b/frontend/wailsjs/go/types/Transaction.d.ts deleted file mode 100755 index 41fb9ca..0000000 --- a/frontend/wailsjs/go/types/Transaction.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL -// This file is automatically generated. DO NOT EDIT -import {base} from '../models'; -import {io} from '../models'; -import {types} from '../models'; - -export function CacheId():Promise; - -export function CacheLocation():Promise; - -export function CacheName():Promise; - -export function Date():Promise; - -export function FinishUnmarshal():Promise; - -export function GasCost():Promise; - -export function MarshalCache(arg1:io.Writer):Promise; - -export function Model(arg1:string,arg2:string,arg3:boolean,arg4:{[key: string]: any}):Promise; - -export function String():Promise; - -export function UnmarshalCache(arg1:number,arg2:io.Reader):Promise; diff --git a/frontend/wailsjs/go/types/Transaction.js b/frontend/wailsjs/go/types/Transaction.js deleted file mode 100755 index 971af49..0000000 --- a/frontend/wailsjs/go/types/Transaction.js +++ /dev/null @@ -1,43 +0,0 @@ -// @ts-check -// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL -// This file is automatically generated. DO NOT EDIT - -export function CacheId() { - return window['go']['types']['Transaction']['CacheId'](); -} - -export function CacheLocation() { - return window['go']['types']['Transaction']['CacheLocation'](); -} - -export function CacheName() { - return window['go']['types']['Transaction']['CacheName'](); -} - -export function Date() { - return window['go']['types']['Transaction']['Date'](); -} - -export function FinishUnmarshal() { - return window['go']['types']['Transaction']['FinishUnmarshal'](); -} - -export function GasCost() { - return window['go']['types']['Transaction']['GasCost'](); -} - -export function MarshalCache(arg1) { - return window['go']['types']['Transaction']['MarshalCache'](arg1); -} - -export function Model(arg1, arg2, arg3, arg4) { - return window['go']['types']['Transaction']['Model'](arg1, arg2, arg3, arg4); -} - -export function String() { - return window['go']['types']['Transaction']['String'](); -} - -export function UnmarshalCache(arg1, arg2) { - return window['go']['types']['Transaction']['UnmarshalCache'](arg1, arg2); -} diff --git a/go.mod b/go.mod index 874b057..109bbff 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ replace ( require ( git.sr.ht/~sbinet/gg v0.5.0 - github.com/TrueBlocks/trueblocks-core/sdk v0.0.0-20240605222744-1cbeec2938e0 + github.com/TrueBlocks/trueblocks-core/sdk/v3 v3.0.0-20240718213142-3cffd1bf17f0 github.com/TrueBlocks/trueblocks-core/src/apps/chifra v0.0.0-20240718044519-2c9304344dd6 github.com/joho/godotenv v1.5.1 github.com/lucasb-eyer/go-colorful v1.2.0 diff --git a/go.sum b/go.sum index b5bb404..17394b7 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/TrueBlocks/trueblocks-core/sdk/v3 v3.0.0-20240718213142-3cffd1bf17f0 h1:wWeaGbu8mv+NLwDJ3EKPNpoX4UxYxL8jjtFNQdhP2tg= +github.com/TrueBlocks/trueblocks-core/sdk/v3 v3.0.0-20240718213142-3cffd1bf17f0/go.mod h1:r01Zts5Fl/rEdb5iU94jg5cMu+fPn8msgiAL3u1MIxg= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= diff --git a/main.go b/main.go index a7daae7..4ef8414 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "path/filepath" "strings" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-dalledress/app" @@ -43,7 +42,6 @@ func main() { LogLevel: wLogger.ERROR, Bind: []interface{}{ a, - &base.Address{}, &types.Name{}, &types.Transaction{}, }, diff --git a/package.json b/package.json index 9f26ca3..6a7e293 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "scripts": { - "dev": "wails dev --debounce 2000 2>&1 | grep -v AssetHandler" + "dev": "wails dev --debounce 2000 2>&1 | grep -v AssetHandler | grep -v base | grep -v types" }, "name": "trueblocks-dalledress", "version": "1.0.0",