From c31cbf6ce6b54b95ee4d9c1e3f9265a739d51fe6 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Thu, 18 Jul 2024 09:02:02 -0400 Subject: [PATCH] Has History (doesn't build) --- app/history.go | 44 ++ frontend/src/components/global/Menu.tsx | 1 + frontend/src/components/global/Routes.tsx | 3 +- frontend/src/views/History/HistoryView.tsx | 34 ++ frontend/src/views/index.tsx | 3 +- frontend/wailsjs/go/app/App.d.ts | 4 + frontend/wailsjs/go/app/App.js | 8 + frontend/wailsjs/go/base/Address.d.ts | 51 ++ frontend/wailsjs/go/base/Address.js | 91 ++++ frontend/wailsjs/go/models.ts | 575 ++++++++++++++++++++- frontend/wailsjs/go/types/Transaction.d.ts | 25 + frontend/wailsjs/go/types/Transaction.js | 43 ++ frontend/wailsjs/runtime/package.json | 0 frontend/wailsjs/runtime/runtime.d.ts | 0 frontend/wailsjs/runtime/runtime.js | 0 main.go | 3 + 16 files changed, 880 insertions(+), 5 deletions(-) create mode 100644 app/history.go create mode 100644 frontend/src/views/History/HistoryView.tsx create mode 100755 frontend/wailsjs/go/base/Address.d.ts create mode 100755 frontend/wailsjs/go/base/Address.js create mode 100755 frontend/wailsjs/go/types/Transaction.d.ts create mode 100755 frontend/wailsjs/go/types/Transaction.js mode change 100644 => 100755 frontend/wailsjs/runtime/package.json mode change 100644 => 100755 frontend/wailsjs/runtime/runtime.d.ts mode change 100644 => 100755 frontend/wailsjs/runtime/runtime.js diff --git a/app/history.go b/app/history.go new file mode 100644 index 0000000..ab34ff1 --- /dev/null +++ b/app/history.go @@ -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]) +} diff --git a/frontend/src/components/global/Menu.tsx b/frontend/src/components/global/Menu.tsx index a6ac1d8..802677e 100644 --- a/frontend/src/components/global/Menu.tsx +++ b/frontend/src/components/global/Menu.tsx @@ -23,6 +23,7 @@ function Menu() { { route: "/dalle", label: "Dalle", icon: }, { route: "/names", label: "Names", icon: }, { route: "/series", label: "Series", icon: }, + { route: "/history", label: "History", icon: }, { route: "/settings", label: "Settings", icon: }, ]; diff --git a/frontend/src/components/global/Routes.tsx b/frontend/src/components/global/Routes.tsx index a8f89a0..c78f5f3 100644 --- a/frontend/src/components/global/Routes.tsx +++ b/frontend/src/components/global/Routes.tsx @@ -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 = () => { @@ -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 }, ]; diff --git a/frontend/src/views/History/HistoryView.tsx b/frontend/src/views/History/HistoryView.tsx new file mode 100644 index 0000000..5ebb6a1 --- /dev/null +++ b/frontend/src/views/History/HistoryView.tsx @@ -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(""); + const [cnt, setCnt] = useState(0); + const [txs, setTxs] = useState([]); + + useEffect(() => { + setAddress("0xf503017d7baf7fbc0fff7492b751025c6a78179b"); + GetHistoryCnt(address).then((cnt: number) => { + setCnt(cnt); + }); + GetHistory(address, 0, 20).then((txs: types.Transaction[]) => { + setTxs(txs); + }); + }, []); + + return ( + + History Title + +
{address}
+
{cnt}
+
{JSON.stringify(txs)}
+
+ Status / Progress +
+ ); +} diff --git a/frontend/src/views/index.tsx b/frontend/src/views/index.tsx index caeb9b3..1390647 100644 --- a/frontend/src/views/index.tsx +++ b/frontend/src/views/index.tsx @@ -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"; diff --git a/frontend/wailsjs/go/app/App.d.ts b/frontend/wailsjs/go/app/App.d.ts index f20c20f..ad97eaa 100755 --- a/frontend/wailsjs/go/app/App.d.ts +++ b/frontend/wailsjs/go/app/App.d.ts @@ -18,6 +18,10 @@ export function GetFilelist(arg1:string):Promise>; export function GetFilename(arg1:string):Promise; +export function GetHistory(arg1:string,arg2:number,arg3:number):Promise>; + +export function GetHistoryCnt(arg1:string):Promise; + export function GetJson(arg1:string):Promise; export function GetLast(arg1:string):Promise; diff --git a/frontend/wailsjs/go/app/App.js b/frontend/wailsjs/go/app/App.js index ba773b4..fc728e6 100755 --- a/frontend/wailsjs/go/app/App.js +++ b/frontend/wailsjs/go/app/App.js @@ -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); } diff --git a/frontend/wailsjs/go/base/Address.d.ts b/frontend/wailsjs/go/base/Address.d.ts new file mode 100755 index 0000000..754dc27 --- /dev/null +++ b/frontend/wailsjs/go/base/Address.d.ts @@ -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; + +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 new file mode 100755 index 0000000..6f44a02 --- /dev/null +++ b/frontend/wailsjs/go/base/Address.js @@ -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'](); +} diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index 5611ece..66356c9 100755 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -148,10 +148,149 @@ export namespace dalle { export namespace types { + export class Parameter { + components?: Parameter[]; + indexed?: boolean; + internalType?: string; + name: string; + strDefault?: string; + type: string; + value?: any; - export class Name { + static createFrom(source: any = {}) { + return new Parameter(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.components = this.convertValues(source["components"], Parameter); + this.indexed = source["indexed"]; + this.internalType = source["internalType"]; + this.name = source["name"]; + this.strDefault = source["strDefault"]; + this.type = source["type"]; + this.value = source["value"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + export class Function { + anonymous?: boolean; + constant?: boolean; + encoding: string; + inputs: Parameter[]; + message?: string; + name: string; + outputs: Parameter[]; + signature?: string; + stateMutability?: string; + type: string; + + static createFrom(source: any = {}) { + return new Function(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.anonymous = source["anonymous"]; + this.constant = source["constant"]; + this.encoding = source["encoding"]; + this.inputs = this.convertValues(source["inputs"], Parameter); + this.message = source["message"]; + this.name = source["name"]; + this.outputs = this.convertValues(source["outputs"], Parameter); + this.signature = source["signature"]; + this.stateMutability = source["stateMutability"]; + this.type = source["type"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + export class Log { + address: base.Address; + articulatedLog?: Function; // Go type: base - address: any; + blockHash: any; + blockNumber: number; + data?: string; + logIndex: number; + timestamp?: number; + topics?: base.Hash[]; + // Go type: base + transactionHash: any; + transactionIndex: number; + + static createFrom(source: any = {}) { + return new Log(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.address = this.convertValues(source["address"], base.Address); + this.articulatedLog = this.convertValues(source["articulatedLog"], Function); + this.blockHash = this.convertValues(source["blockHash"], null); + this.blockNumber = source["blockNumber"]; + this.data = source["data"]; + this.logIndex = source["logIndex"]; + this.timestamp = source["timestamp"]; + this.topics = this.convertValues(source["topics"], base.Hash); + this.transactionHash = this.convertValues(source["transactionHash"], null); + this.transactionIndex = source["transactionIndex"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + + export class Name { + address: base.Address; decimals: number; deleted?: boolean; isContract?: boolean; @@ -172,7 +311,7 @@ export namespace types { constructor(source: any = {}) { if ('string' === typeof source) source = JSON.parse(source); - this.address = this.convertValues(source["address"], null); + this.address = this.convertValues(source["address"], base.Address); this.decimals = source["decimals"]; this.deleted = source["deleted"]; this.isContract = source["isContract"]; @@ -205,6 +344,436 @@ export namespace types { return a; } } + + export class Receipt { + // Go type: base + blockHash?: any; + blockNumber: number; + contractAddress?: base.Address; + cumulativeGasUsed?: number; + effectiveGasPrice?: number; + from?: base.Address; + gasUsed: number; + isError?: boolean; + logs: Log[]; + status: number; + to?: base.Address; + // Go type: base + transactionHash: any; + transactionIndex: number; + + static createFrom(source: any = {}) { + return new Receipt(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.blockHash = this.convertValues(source["blockHash"], null); + this.blockNumber = source["blockNumber"]; + this.contractAddress = this.convertValues(source["contractAddress"], base.Address); + this.cumulativeGasUsed = source["cumulativeGasUsed"]; + this.effectiveGasPrice = source["effectiveGasPrice"]; + this.from = this.convertValues(source["from"], base.Address); + this.gasUsed = source["gasUsed"]; + this.isError = source["isError"]; + this.logs = this.convertValues(source["logs"], Log); + this.status = source["status"]; + this.to = this.convertValues(source["to"], base.Address); + this.transactionHash = this.convertValues(source["transactionHash"], null); + this.transactionIndex = source["transactionIndex"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + export class Rewards { + // Go type: base + block: any; + // Go type: base + nephew: any; + // Go type: base + txFee: any; + // Go type: base + uncle: any; + + static createFrom(source: any = {}) { + return new Rewards(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.block = this.convertValues(source["block"], null); + this.nephew = this.convertValues(source["nephew"], null); + this.txFee = this.convertValues(source["txFee"], null); + this.uncle = this.convertValues(source["uncle"], null); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + export class TraceResult { + address?: base.Address; + code?: string; + gasUsed?: number; + output?: string; + + static createFrom(source: any = {}) { + return new TraceResult(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.address = this.convertValues(source["address"], base.Address); + this.code = source["code"]; + this.gasUsed = source["gasUsed"]; + this.output = source["output"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + export class TraceAction { + address?: base.Address; + author?: base.Address; + // Go type: base + balance?: any; + callType: string; + from: base.Address; + gas: number; + init?: string; + input?: string; + refundAddress?: base.Address; + rewardType?: string; + selfDestructed?: base.Address; + to: base.Address; + // Go type: base + value: any; + + static createFrom(source: any = {}) { + return new TraceAction(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.address = this.convertValues(source["address"], base.Address); + this.author = this.convertValues(source["author"], base.Address); + this.balance = this.convertValues(source["balance"], null); + this.callType = source["callType"]; + this.from = this.convertValues(source["from"], base.Address); + this.gas = source["gas"]; + this.init = source["init"]; + this.input = source["input"]; + this.refundAddress = this.convertValues(source["refundAddress"], base.Address); + this.rewardType = source["rewardType"]; + this.selfDestructed = this.convertValues(source["selfDestructed"], base.Address); + this.to = this.convertValues(source["to"], base.Address); + this.value = this.convertValues(source["value"], null); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + export class Trace { + action?: TraceAction; + articulatedTrace?: Function; + // Go type: base + blockHash: any; + blockNumber: number; + error?: string; + result?: TraceResult; + subtraces: number; + timestamp: number; + traceAddress: number[]; + // Go type: base + transactionHash: any; + transactionIndex: number; + type?: string; + transactionPosition?: number; + + static createFrom(source: any = {}) { + return new Trace(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.action = this.convertValues(source["action"], TraceAction); + this.articulatedTrace = this.convertValues(source["articulatedTrace"], Function); + this.blockHash = this.convertValues(source["blockHash"], null); + this.blockNumber = source["blockNumber"]; + this.error = source["error"]; + this.result = this.convertValues(source["result"], TraceResult); + this.subtraces = source["subtraces"]; + this.timestamp = source["timestamp"]; + this.traceAddress = source["traceAddress"]; + this.transactionHash = this.convertValues(source["transactionHash"], null); + this.transactionIndex = source["transactionIndex"]; + this.type = source["type"]; + this.transactionPosition = source["transactionPosition"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + + + export class Statement { + accountedFor: base.Address; + // Go type: base + amountIn?: any; + // Go type: base + amountOut?: any; + assetAddr: base.Address; + assetSymbol: string; + // Go type: base + begBal: any; + blockNumber: number; + // Go type: base + correctingIn?: any; + // Go type: base + correctingOut?: any; + correctingReason?: string; + decimals: number; + // Go type: base + endBal: any; + // Go type: base + gasOut?: any; + // Go type: base + internalIn?: any; + // Go type: base + internalOut?: any; + logIndex: number; + // Go type: base + minerBaseRewardIn?: any; + // Go type: base + minerNephewRewardIn?: any; + // Go type: base + minerTxFeeIn?: any; + // Go type: base + minerUncleRewardIn?: any; + // Go type: base + prefundIn?: any; + // Go type: base + prevBal?: any; + priceSource: string; + recipient: base.Address; + // Go type: base + selfDestructIn?: any; + // Go type: base + selfDestructOut?: any; + sender: base.Address; + spotPrice: number; + timestamp: number; + // Go type: base + transactionHash: any; + transactionIndex: number; + + static createFrom(source: any = {}) { + return new Statement(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.accountedFor = this.convertValues(source["accountedFor"], base.Address); + this.amountIn = this.convertValues(source["amountIn"], null); + this.amountOut = this.convertValues(source["amountOut"], null); + this.assetAddr = this.convertValues(source["assetAddr"], base.Address); + this.assetSymbol = source["assetSymbol"]; + this.begBal = this.convertValues(source["begBal"], null); + this.blockNumber = source["blockNumber"]; + this.correctingIn = this.convertValues(source["correctingIn"], null); + this.correctingOut = this.convertValues(source["correctingOut"], null); + this.correctingReason = source["correctingReason"]; + this.decimals = source["decimals"]; + this.endBal = this.convertValues(source["endBal"], null); + this.gasOut = this.convertValues(source["gasOut"], null); + this.internalIn = this.convertValues(source["internalIn"], null); + this.internalOut = this.convertValues(source["internalOut"], null); + this.logIndex = source["logIndex"]; + this.minerBaseRewardIn = this.convertValues(source["minerBaseRewardIn"], null); + this.minerNephewRewardIn = this.convertValues(source["minerNephewRewardIn"], null); + this.minerTxFeeIn = this.convertValues(source["minerTxFeeIn"], null); + this.minerUncleRewardIn = this.convertValues(source["minerUncleRewardIn"], null); + this.prefundIn = this.convertValues(source["prefundIn"], null); + this.prevBal = this.convertValues(source["prevBal"], null); + this.priceSource = source["priceSource"]; + this.recipient = this.convertValues(source["recipient"], base.Address); + this.selfDestructIn = this.convertValues(source["selfDestructIn"], null); + this.selfDestructOut = this.convertValues(source["selfDestructOut"], null); + this.sender = this.convertValues(source["sender"], base.Address); + this.spotPrice = source["spotPrice"]; + this.timestamp = source["timestamp"]; + this.transactionHash = this.convertValues(source["transactionHash"], null); + this.transactionIndex = source["transactionIndex"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } + export class Transaction { + articulatedTx?: Function; + // Go type: base + blockHash: any; + blockNumber: number; + from: base.Address; + gas: number; + gasPrice: number; + gasUsed: number; + hasToken: boolean; + // Go type: base + hash: any; + input: string; + isError: boolean; + maxFeePerGas: number; + maxPriorityFeePerGas: number; + nonce: number; + receipt?: Receipt; + timestamp: number; + to: base.Address; + traces: Trace[]; + transactionIndex: number; + type: string; + // Go type: base + value: any; + statements?: Statement[]; + + static createFrom(source: any = {}) { + return new Transaction(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.articulatedTx = this.convertValues(source["articulatedTx"], Function); + this.blockHash = this.convertValues(source["blockHash"], null); + this.blockNumber = source["blockNumber"]; + this.from = this.convertValues(source["from"], base.Address); + this.gas = source["gas"]; + this.gasPrice = source["gasPrice"]; + this.gasUsed = source["gasUsed"]; + this.hasToken = source["hasToken"]; + this.hash = this.convertValues(source["hash"], null); + this.input = source["input"]; + this.isError = source["isError"]; + this.maxFeePerGas = source["maxFeePerGas"]; + this.maxPriorityFeePerGas = source["maxPriorityFeePerGas"]; + this.nonce = source["nonce"]; + this.receipt = this.convertValues(source["receipt"], Receipt); + this.timestamp = source["timestamp"]; + this.to = this.convertValues(source["to"], base.Address); + this.traces = this.convertValues(source["traces"], Trace); + this.transactionIndex = source["transactionIndex"]; + this.type = source["type"]; + this.value = this.convertValues(source["value"], null); + this.statements = this.convertValues(source["statements"], Statement); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } } diff --git a/frontend/wailsjs/go/types/Transaction.d.ts b/frontend/wailsjs/go/types/Transaction.d.ts new file mode 100755 index 0000000..41fb9ca --- /dev/null +++ b/frontend/wailsjs/go/types/Transaction.d.ts @@ -0,0 +1,25 @@ +// 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 new file mode 100755 index 0000000..971af49 --- /dev/null +++ b/frontend/wailsjs/go/types/Transaction.js @@ -0,0 +1,43 @@ +// @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/frontend/wailsjs/runtime/package.json b/frontend/wailsjs/runtime/package.json old mode 100644 new mode 100755 diff --git a/frontend/wailsjs/runtime/runtime.d.ts b/frontend/wailsjs/runtime/runtime.d.ts old mode 100644 new mode 100755 diff --git a/frontend/wailsjs/runtime/runtime.js b/frontend/wailsjs/runtime/runtime.js old mode 100644 new mode 100755 diff --git a/main.go b/main.go index 0c33cb2..a7daae7 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ 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" @@ -42,7 +43,9 @@ func main() { LogLevel: wLogger.ERROR, Bind: []interface{}{ a, + &base.Address{}, &types.Name{}, + &types.Transaction{}, }, StartHidden: true, AssetServer: &assetserver.Options{