-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updates a few of the build scripts * Adds, but does not implement, chifra init --examples * There should be no files other than .gitignore files in working folder * Adds back missing working folders * Fixes tests * Adds UnmarshalJSON to both base.Address and base.Hash * Improves the testRunner a bit * Implements chifra init --example <name> * De-lints * Adds usesSDK example * Makes output for Blocks.baseFeePerGas into Wei not uint64 - breaking * Working on usesSDK * Stringer for types is now non-pointer * Stringer for types is now non-pointer * Fixes lints
- Loading branch information
Showing
96 changed files
with
1,271 additions
and
221 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,3 @@ | ||
# [{NAME}] | ||
|
||
Test case for [{NAME}]. |
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,8 @@ | ||
module github.com/TrueBlocks/trueblocks-core/examples/[{LOWER}] | ||
|
||
// Go Version | ||
go 1.22 | ||
|
||
replace github.com/TrueBlocks/trueblocks-core/sdk => ../../sdk | ||
|
||
require github.com/TrueBlocks/trueblocks-core v2.5.8-release.0.20240422010715-cf442e547b61+incompatible // indirect |
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,28 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
) | ||
|
||
func main() { | ||
opts := sdk.BlocksOptions{ | ||
BlockIds: []string{"latest"}, | ||
} | ||
|
||
blocks, _, err := opts.Blocks() | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
|
||
fmt.Println("[") | ||
for i, block := range blocks { | ||
if i > 0 { | ||
fmt.Println(",") | ||
} | ||
fmt.Println(block.String()) | ||
} | ||
fmt.Println("]") | ||
} |
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,9 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMainFunction(t *testing.T) { | ||
main() | ||
} |
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,22 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" | ||
) | ||
|
||
// DoAbis tests the When sdk function | ||
func DoAbis() { | ||
logger.Info("DoAbis") | ||
|
||
opts := sdk.AbisOptions{ | ||
Addrs: []string{"uniswap.eth"}, | ||
} | ||
|
||
if functions, _, err := opts.Abis(); err != nil { | ||
logger.Fatal(err) | ||
} else { | ||
SaveToFile[types.Function]("usesSDK/abis.json", functions) | ||
} | ||
} |
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,72 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" | ||
) | ||
|
||
// DoBlocks tests the Blocks sdk function | ||
func DoBlocks() { | ||
logger.Info("DoBlocks") | ||
|
||
opts := sdk.BlocksOptions{ | ||
BlockIds: testBlocks, | ||
Globals: sdk.Globals{ | ||
Cache: true, | ||
}, | ||
} | ||
|
||
if blocks, _, err := opts.Blocks(); err != nil { | ||
logger.Fatal(err) | ||
} else { | ||
SaveToFile[types.Block[types.Transaction]]("usesSDK/blocks.json", blocks) | ||
} | ||
|
||
opts.Hashes = true | ||
if blocks, _, err := opts.BlocksHashes(); err != nil { | ||
logger.Fatal(err) | ||
} else { | ||
SaveToFile[types.Block[string]]("usesSDK/blocks-hashes.json", blocks) | ||
} | ||
|
||
opts.Hashes = false | ||
opts.Traces = true | ||
if traces, _, err := opts.BlocksTraces(); err != nil { | ||
logger.Fatal(err) | ||
} else { | ||
SaveToFile[types.Trace]("usesSDK/blocks-traces.json", traces) | ||
} | ||
|
||
opts.Traces = false | ||
opts.Uniq = true | ||
// if apps, _, err := opts.BlocksUniq(); err != nil { | ||
// logger.Fatal(err) | ||
// } else { | ||
// SaveToFile[types.Appearance]("usesSDK/blocks-uniq.json", apps) | ||
// } | ||
|
||
opts.Uniq = false | ||
opts.Logs = true | ||
if logs, _, err := opts.BlocksLogs(); err != nil { | ||
logger.Fatal(err) | ||
} else { | ||
SaveToFile[types.Log]("usesSDK/blocks-logs.json", logs) | ||
} | ||
|
||
opts.Logs = false | ||
opts.Withdrawals = true | ||
if withdrawals, _, err := opts.BlocksWithdrawals(); err != nil { | ||
logger.Fatal(err) | ||
} else { | ||
SaveToFile[types.Withdrawal]("usesSDK/blocks-withdrawals.json", withdrawals) | ||
} | ||
|
||
opts.Withdrawals = false | ||
opts.Count = false | ||
if counts, _, err := opts.BlocksCount(); err != nil { | ||
logger.Fatal(err) | ||
} else { | ||
SaveToFile[types.BlockCount]("usesSDK/blocks-count.json", counts) | ||
} | ||
} |
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 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
) | ||
|
||
// DoChunks tests the When sdk function | ||
func DoChunks() { | ||
logger.Info("DoChunks") | ||
|
||
opts := sdk.ChunksOptions{ | ||
Mode: sdk.CMIndex, | ||
} | ||
|
||
buf := bytes.Buffer{} | ||
if err := opts.ChunksBytes(&buf); err != nil { | ||
logger.Fatal(err) | ||
} | ||
|
||
file.StringToAsciiFile("usesSDK/chunks.json", buf.String()) | ||
fmt.Println(buf.String()) | ||
} | ||
// func (opts *ChunksOptions) ChunksManifest() ([]types.ChunkRecord, *types.MetaData, error) { | ||
// func (opts *ChunksOptions) ChunksIndex() ([]types.ChunkIndex, *types.MetaData, error) { | ||
// func (opts *ChunksOptions) ChunksBlooms() ([]types.ChunkBloom, *types.MetaData, error) { | ||
// func (opts *ChunksOptions) ChunksPins() ([]types.ChunkPinReport, *types.MetaData, error) { | ||
// func (opts *ChunksOptions) ChunksAddresses() ([]types.ChunkAddress, *types.MetaData, error) { | ||
// // func (opts *ChunksOptions) ChunksAppearances() ([]types.ChunkAppearance, *types.MetaData, error) { | ||
// func (opts *ChunksOptions) ChunkStats() ([]types.ChunkStats, *types.MetaData, error) { |
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,27 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
) | ||
|
||
// DoConfig tests the When sdk function | ||
func DoConfig() { | ||
logger.Info("DoConfig") | ||
|
||
opts := sdk.ConfigOptions{ | ||
Mode: sdk.CMShow, | ||
} | ||
|
||
buf := bytes.Buffer{} | ||
if err := opts.ConfigBytes(&buf); err != nil { | ||
logger.Fatal(err) | ||
} | ||
|
||
file.StringToAsciiFile("usesSDK/config.json", buf.String()) | ||
fmt.Println(buf.String()) | ||
} |
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,22 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
) | ||
|
||
// DoDaemon tests the When sdk function | ||
func DoDaemon() { | ||
logger.Info("DoDaemon") | ||
|
||
// opts := sdk.DaemonOptions{ | ||
// Mode: sdk.CMIndex, | ||
// } | ||
|
||
// buf := bytes.Buffer{} | ||
// if err := opts.Daemon(&buf); err != nil { | ||
// logger.Fatal(err) | ||
// } | ||
|
||
file.StringToAsciiFile("usesSDK/daemon.json", "daemon is not an sdk option") | ||
} |
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,22 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
) | ||
|
||
// DoExplore tests the When sdk function | ||
func DoExplore() { | ||
logger.Info("DoExplore") | ||
|
||
// opts := sdk.ExploreOptions{ | ||
// Mode: sdk.CMIndex, | ||
// } | ||
|
||
// buf := bytes.Buffer{} | ||
// if err := opts.Explore(&buf); err != nil { | ||
// logger.Fatal(err) | ||
// } | ||
|
||
file.StringToAsciiFile("usesSDK/explore.json", "explore is not an SDK option") | ||
} |
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,36 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
) | ||
|
||
// DoExport tests the When sdk function | ||
func DoExport() { | ||
logger.Info("DoExport") | ||
|
||
opts := sdk.ExportOptions{ | ||
Addrs: []string{testAddrs[0]}, | ||
} | ||
|
||
buf := bytes.Buffer{} | ||
if err := opts.ExportBytes(&buf); err != nil { | ||
logger.Fatal(err) | ||
} | ||
|
||
file.StringToAsciiFile("usesSDK/export.json", buf.String()) | ||
fmt.Println(buf.String()) | ||
} | ||
// func (opts *ExportOptions) Export() ([]types.Transaction, *types.MetaData, error) { | ||
// func (opts *ExportOptions) ExportAppearances() ([]types.Appearance, *types.MetaData, error) { | ||
// func (opts *ExportOptions) ExportReceipts() ([]types.Receipt, *types.MetaData, error) { | ||
// func (opts *ExportOptions) ExportLogs() ([]types.Log, *types.MetaData, error) { | ||
// func (opts *ExportOptions) ExportTraces() ([]types.Trace, *types.MetaData, error) { | ||
// func (opts *ExportOptions) ExportStatements() ([]types.Statement, *types.MetaData, error) { | ||
// func (opts *ExportOptions) ExportBalances() ([]types.State, *types.MetaData, error) { | ||
// func (opts *ExportOptions) ExportWithdrawals() ([]types.Withdrawal, *types.MetaData, error) { | ||
// func (opts *ExportOptions) ExportCount() ([]types.AppearanceCount, *types.MetaData, error) { |
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,8 @@ | ||
module github.com/TrueBlocks/trueblocks-core/examples/usesSdk | ||
|
||
// Go Version | ||
go 1.22 | ||
|
||
replace github.com/TrueBlocks/trueblocks-core/sdk => ../../sdk | ||
|
||
require github.com/TrueBlocks/trueblocks-core v2.5.8-release.0.20240422010715-cf442e547b61+incompatible // indirect |
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,28 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
) | ||
|
||
// DoInit tests the When sdk function | ||
func DoInit() { | ||
logger.Info("DoInit") | ||
|
||
opts := sdk.InitOptions{ | ||
All: true, | ||
} | ||
|
||
buf := bytes.Buffer{} | ||
if err := opts.InitBytes(&buf); err != nil { | ||
logger.Fatal(err) | ||
} | ||
|
||
file.StringToAsciiFile("usesSDK/init.json", buf.String()) | ||
fmt.Println(buf.String()) | ||
} | ||
// func (opts *InitOptions) InitAll() ([]bool, *types.MetaData, error) { |
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,30 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
) | ||
|
||
// DoList tests the When sdk function | ||
func DoList() { | ||
logger.Info("DoList") | ||
|
||
opts := sdk.ListOptions{ | ||
Addrs: []string{testAddrs[0]}, | ||
} | ||
|
||
buf := bytes.Buffer{} | ||
if err := opts.ListBytes(&buf); err != nil { | ||
logger.Fatal(err) | ||
} | ||
|
||
file.StringToAsciiFile("usesSDK/list.json", buf.String()) | ||
fmt.Println(buf.String()) | ||
} | ||
// func (opts *ListOptions) List() ([]types.Appearance, *types.MetaData, error) { | ||
// func (opts *ListOptions) ListCount() ([]types.AppearanceCount, *types.MetaData, error) { | ||
// func (opts *ListOptions) ListBounds() ([]types.Bounds, *types.MetaData, error) { |
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,28 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/sdk" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" | ||
) | ||
|
||
// DoLogs tests the When sdk function | ||
func DoLogs() { | ||
logger.Info("DoLogs") | ||
|
||
opts := sdk.LogsOptions{ | ||
TransactionIds: []string{"10001002.0"}, | ||
} | ||
|
||
buf := bytes.Buffer{} | ||
if err := opts.LogsBytes(&buf); err != nil { | ||
logger.Fatal(err) | ||
} | ||
|
||
file.StringToAsciiFile("usesSDK/logs.json", buf.String()) | ||
fmt.Println(buf.String()) | ||
} | ||
// func (opts *LogsOptions) Logs() ([]types.Log, *types.MetaData, error) { |
Oops, something went wrong.