Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/more examples 11 #3674

Merged
merged 9 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.10
2.5.11
16 changes: 8 additions & 8 deletions docs/content/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
license:
name: GPL 3.0
url: http://www.gnu.org/licenses/
version: 2.5.10-release
version: 2.5.11-release
description: >
A REST layer over the TrueBlocks chifra command line. With `chifra daemon`, you can
run this on your own machine, and make calls to `localhost`.
Expand Down Expand Up @@ -3487,7 +3487,7 @@ components:
compressedTx:
type: string
format: string
description: "truncated, more readable version of the articulation"
description: "truncated, more readable version of the articulation (calculated)"
withdrawal:
description: "withdrawal record for post-Shanghai withdrawals from the consensus layer"
type: object
Expand All @@ -3510,7 +3510,7 @@ components:
description: "the number of this block"
index:
type: number
format: numeral
format: index
description: "a monotonically increasing zero-based index that increments by 1 per withdrawal to uniquely identify each withdrawal"
timestamp:
type: number
Expand All @@ -3522,7 +3522,7 @@ components:
description: "the timestamp as a date (calculated)"
validatorIndex:
type: number
format: numeral
format: index
description: "the validator_index of the validator on the consensus layer the withdrawal corresponds to"
receipt:
description: "receipt data as returned from the RPC (with slight enhancements)"
Expand Down Expand Up @@ -3613,7 +3613,7 @@ components:
compressedLog:
type: string
format: string
description: "a truncated, more readable version of the articulation"
description: "a truncated, more readable version of the articulation (calculated)"
logFilter:
description: "used by the fast path log queries for various commands"
type: object
Expand Down Expand Up @@ -3699,7 +3699,7 @@ components:
compressedTrace:
type: string
format: string
description: "a compressed string version of the articulated trace"
description: "a compressed string version of the articulated trace (calculated)"
traceAction:
description: "trace action data as returned from the RPC (with slight enhancements)"
type: object
Expand Down Expand Up @@ -4626,7 +4626,7 @@ components:
ether:
type: string
format: ether
description: "if --ether is specified, the value in ether"
description: "if --ether is specified, the value in ether (calculated)"
gas:
type: number
format: gas
Expand All @@ -4651,7 +4651,7 @@ components:
compressedTx:
type: string
format: string
description: "truncated, more readable version of the articulation"
description: "truncated, more readable version of the articulation (calculated)"
isError:
type: boolean
format: boolean
Expand Down
40 changes: 20 additions & 20 deletions docs/content/data-model/chaindata.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Transactions consist of the following fields:
| articulatedTx | | [Function](/data-model/other/#function) |
| hasToken | `true` if the transaction is token related, `false` otherwise | bool |
| isError | `true` if the transaction ended in error, `false` otherwise | bool |
| compressedTx | truncated, more readable version of the articulation | string |
| compressedTx | truncated, more readable version of the articulation (calculated) | string |

## Withdrawal

Expand All @@ -101,10 +101,10 @@ Withdrawals consist of the following fields:
| amount | a nonzero amount of ether given in gwei (1e9 wei) | wei |
| ether | if --ether is specified, the amount in ether (calculated) | ether |
| blockNumber | the number of this block | blknum |
| index | a monotonically increasing zero-based index that increments by 1 per withdrawal to uniquely identify each withdrawal | numeral |
| index | a monotonically increasing zero-based index that increments by 1 per withdrawal to uniquely identify each withdrawal | index |
| timestamp | the timestamp for this block | timestamp |
| date | the timestamp as a date (calculated) | datetime |
| validatorIndex | the validator_index of the validator on the consensus layer the withdrawal corresponds to | numeral |
| validatorIndex | the validator_index of the validator on the consensus layer the withdrawal corresponds to | index |

## Receipt

Expand Down Expand Up @@ -163,7 +163,7 @@ Logs consist of the following fields:
| transactionHash | the hash of the transction | hash |
| blockHash | the hash of the block | hash |
| articulatedLog | a human-readable version of the topic and data fields | [Function](/data-model/other/#function) |
| compressedLog | a truncated, more readable version of the articulation | string |
| compressedLog | a truncated, more readable version of the articulation (calculated) | string |

## LogFilter

Expand Down Expand Up @@ -203,21 +203,21 @@ The following commands produce and manage Traces:

Traces consist of the following fields:

| Field | Description | Type |
| ---------------- | --------------------------------------------------------- | ------------------------------------------------- |
| blockHash | the hash of the block containing this trace | hash |
| blockNumber | the number of the block | blknum |
| timestamp | the timestamp of the block | timestamp |
| date | the timestamp as a date (calculated) | datetime |
| transactionHash | the transaction's hash containing this trace | hash |
| transactionIndex | the zero-indexed position of the transaction in the block | txnum |
| traceAddress | a particular trace's address in the trace tree | uint64[] |
| subtraces | the number of children traces that the trace hash | uint64 |
| type | the type of the trace | string |
| action | the trace action for this trace | [TraceAction](/data-model/chaindata/#traceaction) |
| result | the trace result of this trace | [TraceResult](/data-model/chaindata/#traceresult) |
| articulatedTrace | human readable version of the trace action input data | [Function](/data-model/other/#function) |
| compressedTrace | a compressed string version of the articulated trace | string |
| Field | Description | Type |
| ---------------- | ----------------------------------------------------------------- | ------------------------------------------------- |
| blockHash | the hash of the block containing this trace | hash |
| blockNumber | the number of the block | blknum |
| timestamp | the timestamp of the block | timestamp |
| date | the timestamp as a date (calculated) | datetime |
| transactionHash | the transaction's hash containing this trace | hash |
| transactionIndex | the zero-indexed position of the transaction in the block | txnum |
| traceAddress | a particular trace's address in the trace tree | uint64[] |
| subtraces | the number of children traces that the trace hash | uint64 |
| type | the type of the trace | string |
| action | the trace action for this trace | [TraceAction](/data-model/chaindata/#traceaction) |
| result | the trace result of this trace | [TraceResult](/data-model/chaindata/#traceresult) |
| articulatedTrace | human readable version of the trace action input data | [Function](/data-model/other/#function) |
| compressedTrace | a compressed string version of the articulated trace (calculated) | string |

### Notes

Expand Down Expand Up @@ -412,10 +412,10 @@ This documentation mentions the following basic data types.
| ether | a big number float | as a string |
| gas | a 64-bit unsigned integer | |
| hash | an '0x'-prefixed 32-byte hex string | lowercase |
| index | an alias for a uint64 | |
| int64 | a 64-bit signed integer | |
| lognum | an alias for a uint64 | |
| nonce | a 64-bit unsigned integer | |
| numeral | an alias for a uint64 | |
| string | a normal character string | |
| timestamp | a 64-bit unsigned integer | Unix timestamp |
| topic | an '0x'-prefixed 32-byte hex string | lowercase |
Expand Down
6 changes: 3 additions & 3 deletions docs/content/data-model/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ Slurps consist of the following fields:
| from | address from which the transaction was sent | address |
| to | address to which the transaction was sent | address |
| value | the amount of wei sent with this transactions | wei |
| ether | if --ether is specified, the value in ether | ether |
| ether | if --ether is specified, the value in ether (calculated) | ether |
| gas | the maximum number of gas allowed for this transaction | gas |
| gasPrice | the number of wei per unit of gas the sender is willing to spend | gas |
| input | byte data either containing a message or funcational data for a smart contracts. See the --articulate | bytes |
| hasToken | `true` if the transaction is token related, `false` otherwise | bool |
| articulatedTx | if present, the function that was called in the transaction | [Function](/data-model/other/#function) |
| compressedTx | truncated, more readable version of the articulation | string |
| compressedTx | truncated, more readable version of the articulation (calculated) | string |
| isError | `true` if the transaction ended in error, `false` otherwise | bool |

## SlurpCount
Expand Down Expand Up @@ -198,9 +198,9 @@ This documentation mentions the following basic data types.
| ether | a big number float | as a string |
| gas | a 64-bit unsigned integer | |
| hash | an '0x'-prefixed 32-byte hex string | lowercase |
| index | an alias for a uint64 | |
| int64 | a 64-bit signed integer | |
| nonce | a 64-bit unsigned integer | |
| numeral | an alias for a uint64 | |
| string | a normal character string | |
| timestamp | a 64-bit unsigned integer | Unix timestamp |
| txnum | an alias for a uint64 | |
Expand Down
11 changes: 7 additions & 4 deletions examples/balanceChart/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ func getBalances(names []types.Name, chain string, start, end gostradamus.DateTi
Chain: chain,
},
}

clamps, _, _ := clamp.When()
if start.UnixTimestamp() < clamps[0].Timestamp {
start = gostradamus.FromUnixTimestamp(clamps[0].Timestamp)
sTs := base.Timestamp(start.UnixTimestamp())
eTs := base.Timestamp(end.UnixTimestamp())
if sTs < clamps[0].Timestamp {
start = gostradamus.FromUnixTimestamp(int64(clamps[0].Timestamp))
}
if end.UnixTimestamp() > clamps[1].Timestamp {
end = gostradamus.FromUnixTimestamp(clamps[1].Timestamp - 1)
if eTs > clamps[1].Timestamp {
end = gostradamus.FromUnixTimestamp(int64(clamps[1].Timestamp - 1))
}

whenOpts := sdk.WhenOptions{
Expand Down
3 changes: 1 addition & 2 deletions src/apps/chifra/internal/chunks/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
outputHelpers "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output/helpers"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/tslib"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -155,7 +154,7 @@ func GetChunkStats(chain, path string) (s types.ChunkStats, err error) {
ts, _ := tslib.FromBnToTs(chain, chunk.Range.Last)
s = types.ChunkStats{
Range: chunk.Range.String(),
RangeEnd: utils.FormattedDate(ts),
RangeEnd: base.FormattedDate(ts),
NBlocks: uint64(chunk.Range.Last - chunk.Range.First + 1),
NAddrs: uint64(chunk.Index.Header.AddressCount),
NApps: uint64(chunk.Index.Header.AppearanceCount),
Expand Down
4 changes: 2 additions & 2 deletions src/apps/chifra/internal/explore/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ func (opts *ExploreOptions) idToTxHash(arg string, isBlockHash func(arg string)
}

if isBlockHash(parts[0]) {
return opts.Conn.GetTransactionHashByHashAndID(parts[0], base.MustParseNumeral(parts[1]))
return opts.Conn.GetTransactionHashByHashAndID(parts[0], base.MustParseIndex(parts[1]))
}

blockNum := base.MustParseBlknum(parts[0])
txId := base.MustParseNumeral(parts[1])
txId := base.MustParseIndex(parts[1])
hash, err := opts.Conn.GetTransactionHashByNumberAndID(blockNum, base.Txnum(txId))
return hash.Hex(), err
}
2 changes: 1 addition & 1 deletion src/apps/chifra/internal/export/handle_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (opts *ExportOptions) HandleTraces(monitorArray []monitor.Monitor) error {
items := make([]*types.Trace, 0, len(thisMap))
for _, tx := range thisMap {
for index, trace := range tx.Traces {
trace.TraceIndex = base.TraceId(index)
trace.TraceIndex = base.Tracenum(index)
isCreate := trace.Action.CallType == "creation" || trace.TraceType == "create"
if !opts.Factory || isCreate {
if opts.Articulate {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/chifra/internal/scrape/scrape_consolidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (bm *BlazeManager) AsciiFileToAppearanceMap(fn string) (map[string][]types.
if len(parts) == 3 { // shouldn't be needed, but just in case...
addr := strings.ToLower(parts[0])
bn := base.MustParseBlknum(strings.TrimLeft(parts[1], "0"))
txid := base.MustParseNumeral(strings.TrimLeft(parts[2], "0"))
txid := base.MustParseIndex(strings.TrimLeft(parts[2], "0"))
// See #3252
if addr == base.SentinalAddr.Hex() && txid == types.MisconfigReward {
continue
Expand Down
2 changes: 1 addition & 1 deletion src/apps/chifra/internal/traces/handle_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (opts *TracesOptions) HandleFilter() error {
errorChan <- err // continue even with an error
}
}
traces[index].TraceIndex = base.TraceId(index)
traces[index].TraceIndex = base.Tracenum(index)
tr = append(tr, traces[index])
}
value.Traces = append(value.Traces, tr...)
Expand Down
2 changes: 1 addition & 1 deletion src/apps/chifra/internal/when/handle_ts_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (opts *WhenOptions) HandleTimestampsShow() error {
s := types.Timestamp{
BlockNumber: base.Blknum(ts.Bn),
Timestamp: base.Timestamp(ts.Ts),
Diff: base.Timestamp(ts.Ts) - prev,
Diff: int64(base.Timestamp(ts.Ts) - prev),
}
if bn == 0 {
s.Diff = 0
Expand Down
2 changes: 1 addition & 1 deletion src/apps/chifra/pkg/base/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (h Hash) MarshalText() ([]byte, error) {
}

func (h *Hash) UnmarshalJSON(data []byte) error {
if string(data) == "\"0x0\"" {
if string(data) == "\"0x0\"" || string(data) == "\"\"" {
return nil
}
return h.Hash.UnmarshalJSON(data)
Expand Down
Loading
Loading