-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3524 from TrueBlocks/feature/go-sdk-2
Feature/go sdk 2
- Loading branch information
Showing
166 changed files
with
5,981 additions
and
829 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
go 1.22 | ||
|
||
use ./src/apps/chifra | ||
|
||
use ./src/examples/usesSDK | ||
|
||
use ./sdk/go |
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,65 @@ | ||
// Copyright 2024 The TrueBlocks Authors. All rights reserved. | ||
// Use of this source code is governed by a license that can | ||
// be found in the LICENSE file. | ||
/* | ||
* Parts of this file were generated with makeClass --run. Edit only those parts of | ||
* the code inside of 'EXISTING_CODE' tags. | ||
*/ | ||
|
||
package sdk | ||
|
||
import ( | ||
// EXISTING_CODE | ||
"io" | ||
"net/url" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" | ||
abis "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" | ||
// EXISTING_CODE | ||
) | ||
|
||
type AbisOptions struct { | ||
Addrs []string // allow for ENS names and addresses | ||
Known bool | ||
ProxyFor base.Address | ||
Find []string | ||
Hint []string | ||
Encode string | ||
Globals | ||
|
||
// EXISTING_CODE | ||
// EXISTING_CODE | ||
} | ||
|
||
// Abis implements the chifra abis command for the SDK. | ||
func (opts *AbisOptions) Abis(w io.Writer) error { | ||
values := make(url.Values) | ||
|
||
// EXISTING_CODE | ||
for _, addr := range opts.Addrs { | ||
values.Add("addrs", addr) | ||
} | ||
if opts.Known { | ||
values.Set("known", "true") | ||
} | ||
if !opts.ProxyFor.IsZero() { | ||
values.Set("proxy_for", opts.ProxyFor.Hex()) | ||
} | ||
for _, find := range opts.Find { | ||
values.Add("find", find) | ||
} | ||
for _, hint := range opts.Hint { | ||
values.Add("hint", hint) | ||
} | ||
if opts.Encode != "" { | ||
values.Set("encode", opts.Encode) | ||
} | ||
// EXISTING_CODE | ||
opts.Globals.mapGlobals(values) | ||
|
||
return abis.Abis(w, values) | ||
} | ||
|
||
// EXISTING_CODE | ||
// EXISTING_CODE | ||
|
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,111 @@ | ||
// Copyright 2024 The TrueBlocks Authors. All rights reserved. | ||
// Use of this source code is governed by a license that can | ||
// be found in the LICENSE file. | ||
/* | ||
* Parts of this file were generated with makeClass --run. Edit only those parts of | ||
* the code inside of 'EXISTING_CODE' tags. | ||
*/ | ||
|
||
package sdk | ||
|
||
import ( | ||
// EXISTING_CODE | ||
"fmt" | ||
"io" | ||
"net/url" | ||
|
||
blocks "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" | ||
// EXISTING_CODE | ||
) | ||
|
||
type BlocksOptions struct { | ||
BlockIds []string // allow for block ranges and steps | ||
Hashes bool | ||
Uncles bool | ||
Traces bool | ||
Uniq bool | ||
Flow BlocksFlow | ||
Logs bool | ||
Emitter []string // allow for ENS names and addresses | ||
Topic []string // topics are strings | ||
Withdrawals bool | ||
Articulate bool | ||
BigRange uint64 | ||
Count bool | ||
Globals | ||
|
||
// EXISTING_CODE | ||
// EXISTING_CODE | ||
} | ||
|
||
// Blocks implements the chifra blocks command for the SDK. | ||
func (opts *BlocksOptions) Blocks(w io.Writer) error { | ||
values := make(url.Values) | ||
|
||
// EXISTING_CODE | ||
for _, blockId := range opts.BlockIds { | ||
values.Add("blocks", blockId) | ||
} | ||
if opts.Hashes { | ||
values.Set("hashes", "true") | ||
} | ||
if opts.Uncles { | ||
values.Set("uncles", "true") | ||
} | ||
if opts.Traces { | ||
values.Set("traces", "true") | ||
} | ||
if opts.Uniq { | ||
values.Set("uniq", "true") | ||
} | ||
if opts.Flow != NoBF { | ||
values.Set("flow", opts.Flow.String()) | ||
} | ||
if opts.Logs { | ||
values.Set("logs", "true") | ||
} | ||
for _, emitter := range opts.Emitter { | ||
values.Add("emitter", emitter) | ||
} | ||
for _, topic := range opts.Topic { | ||
values.Add("topic", topic) | ||
} | ||
if opts.Withdrawals { | ||
values.Set("withdrawals", "true") | ||
} | ||
if opts.Articulate { | ||
values.Set("articulate", "true") | ||
} | ||
if opts.BigRange > 0 { | ||
values.Set("bigRange", fmt.Sprintf("%d", opts.BigRange)) | ||
} | ||
if opts.Count { | ||
values.Set("count", "true") | ||
} | ||
// EXISTING_CODE | ||
opts.Globals.mapGlobals(values) | ||
|
||
return blocks.Blocks(w, values) | ||
} | ||
|
||
type BlocksFlow int | ||
|
||
const ( | ||
NoBF BlocksFlow = iota | ||
BFFrom | ||
BFTo | ||
BFReward | ||
) | ||
|
||
func (v BlocksFlow) String() string { | ||
return []string{ | ||
"nobf", | ||
"from", | ||
"to", | ||
"reward", | ||
}[v] | ||
} | ||
|
||
// EXISTING_CODE | ||
// EXISTING_CODE | ||
|
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,124 @@ | ||
// Copyright 2024 The TrueBlocks Authors. All rights reserved. | ||
// Use of this source code is governed by a license that can | ||
// be found in the LICENSE file. | ||
/* | ||
* Parts of this file were generated with makeClass --run. Edit only those parts of | ||
* the code inside of 'EXISTING_CODE' tags. | ||
*/ | ||
|
||
package sdk | ||
|
||
import ( | ||
// EXISTING_CODE | ||
"fmt" | ||
"io" | ||
"net/url" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" | ||
chunks "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" | ||
// EXISTING_CODE | ||
) | ||
|
||
type ChunksOptions struct { | ||
Mode ChunksMode | ||
BlockIds []string // allow for block ranges and steps | ||
Check bool | ||
Pin bool | ||
Publish bool | ||
Remote bool | ||
Belongs []string // allow for ENS names and addresses | ||
FirstBlock base.Blknum | ||
LastBlock base.Blknum | ||
MaxAddrs base.Blknum | ||
Deep bool | ||
Rewrite bool | ||
Count bool | ||
Sleep float64 | ||
Globals | ||
|
||
// EXISTING_CODE | ||
// EXISTING_CODE | ||
} | ||
|
||
// Chunks implements the chifra chunks command for the SDK. | ||
func (opts *ChunksOptions) Chunks(w io.Writer) error { | ||
values := make(url.Values) | ||
|
||
// EXISTING_CODE | ||
if opts.Mode != NoCM2 { | ||
values.Set("mode", opts.Mode.String()) | ||
} | ||
for _, v := range opts.BlockIds { | ||
values.Add("blocks", v) | ||
} | ||
if opts.Check { | ||
values.Set("check", "true") | ||
} | ||
if opts.Pin { | ||
values.Set("pin", "true") | ||
} | ||
if opts.Publish { | ||
values.Set("publish", "true") | ||
} | ||
if opts.Remote { | ||
values.Set("remote", "true") | ||
} | ||
for _, v := range opts.Belongs { | ||
values.Add("belongs", v) | ||
} | ||
if opts.FirstBlock > 0 { | ||
values.Set("first_block", fmt.Sprint(opts.FirstBlock)) | ||
} | ||
if opts.LastBlock > 0 { | ||
values.Set("last_block", fmt.Sprint(opts.LastBlock)) | ||
} | ||
if opts.MaxAddrs > 0 { | ||
values.Set("max_addrs", fmt.Sprint(opts.MaxAddrs)) | ||
} | ||
if opts.Deep { | ||
values.Set("deep", "true") | ||
} | ||
if opts.Rewrite { | ||
values.Set("rewrite", "true") | ||
} | ||
if opts.Count { | ||
values.Set("count", "true") | ||
} | ||
if opts.Sleep > 0 { | ||
values.Set("sleep", fmt.Sprint(opts.Sleep)) | ||
} | ||
// EXISTING_CODE | ||
opts.Globals.mapGlobals(values) | ||
|
||
return chunks.Chunks(w, values) | ||
} | ||
|
||
type ChunksMode int | ||
|
||
const ( | ||
NoCM2 ChunksMode = iota | ||
CMManifest | ||
CMIndex | ||
CMBlooms | ||
CMPins | ||
CMAddresses | ||
CMAppearances | ||
CMStats | ||
) | ||
|
||
func (v ChunksMode) String() string { | ||
return []string{ | ||
"nocm2", | ||
"manifest", | ||
"index", | ||
"blooms", | ||
"pins", | ||
"addresses", | ||
"appearances", | ||
"stats", | ||
}[v] | ||
} | ||
|
||
// EXISTING_CODE | ||
// EXISTING_CODE | ||
|
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,64 @@ | ||
// Copyright 2024 The TrueBlocks Authors. All rights reserved. | ||
// Use of this source code is governed by a license that can | ||
// be found in the LICENSE file. | ||
/* | ||
* Parts of this file were generated with makeClass --run. Edit only those parts of | ||
* the code inside of 'EXISTING_CODE' tags. | ||
*/ | ||
|
||
package sdk | ||
|
||
import ( | ||
// EXISTING_CODE | ||
"io" | ||
"net/url" | ||
|
||
config "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" | ||
// EXISTING_CODE | ||
) | ||
|
||
type ConfigOptions struct { | ||
Mode ConfigMode | ||
Paths bool | ||
Globals | ||
|
||
// EXISTING_CODE | ||
// EXISTING_CODE | ||
} | ||
|
||
// Config implements the chifra config command for the SDK. | ||
func (opts *ConfigOptions) Config(w io.Writer) error { | ||
values := make(url.Values) | ||
|
||
// EXISTING_CODE | ||
if opts.Mode != NoCM1 { | ||
values.Set("mode", opts.Mode.String()) | ||
} | ||
if opts.Paths { | ||
values.Set("paths", "true") | ||
} | ||
// EXISTING_CODE | ||
opts.Globals.mapGlobals(values) | ||
|
||
return config.Config(w, values) | ||
} | ||
|
||
type ConfigMode int | ||
|
||
const ( | ||
NoCM1 ConfigMode = iota | ||
CMShow | ||
CMEdit | ||
) | ||
|
||
func (v ConfigMode) String() string { | ||
return []string{ | ||
"nocm1", | ||
"show", | ||
"edit", | ||
}[v] | ||
} | ||
|
||
// EXISTING_CODE | ||
// EXISTING_CODE | ||
|
Oops, something went wrong.