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/go sdk 2 #3524

Merged
merged 23 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
More work on sdk
  • Loading branch information
tjayrush committed Feb 25, 2024
commit 3d51dea9e10637861017303cc636f014657a9e06
19 changes: 19 additions & 0 deletions sdk/go/abis.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,26 @@ 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)
}
Expand Down
28 changes: 12 additions & 16 deletions sdk/go/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,36 +63,32 @@ func (opts *BlocksOptions) Blocks(w io.Writer) error {
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.Count {
values.Set("count", "true")
}
if opts.BigRange > 0 {
values.Set("bigRange", fmt.Sprintf("%d", opts.BigRange))
}
if opts.Flow != NoBF {
values.Set("flow", opts.Flow.String())
}
if len(opts.Emitter) > 0 {
for _, emitter := range opts.Emitter {
values.Add("emitter", emitter)
}
}
if len(opts.Topic) > 0 {
for _, topic := range opts.Topic {
values.Add("topic", topic)
}
if opts.Count {
values.Set("count", "true")
}
opts.Globals.mapGlobals(values)
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return blocks.Blocks(w, values)
}
Expand Down
16 changes: 16 additions & 0 deletions sdk/go/chunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,23 @@ func (opts *ChunksOptions) Chunks(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// mode - the type of data to process (required)
// One of [ manifest | index | blooms | pins | addresses | appearances | stats ]
// blocks - an optional list of blocks to intersect with chunk ranges
// -c, --check check the manifest, index, or blooms for internal consistency
// -i, --pin pin the manifest or each index chunk and bloom
// -p, --publish publish the manifest to the Unchained Index smart contract
// -r, --remote prior to processing, retrieve the manifest from the Unchained Index smart contract
// -b, --belongs strings in index mode only, checks the address(es) for inclusion in the given index chunk
// -F, --first_block uint first block to process (inclusive)
// -L, --last_block uint last block to process (inclusive)
// -m, --max_addrs uint the max number of addresses to process in a given chunk
// -d, --deep if true, dig more deeply during checking (manifest only)
// -e, --rewrite for the --pin --deep mode only, writes the manifest back to the index folder (see notes)
// -U, --count for the pins mode only, display only the count of records
// -s, --sleep float for --remote pinning only, seconds to sleep between API calls
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return chunks.Chunks(w, values)
}
Expand Down
4 changes: 4 additions & 0 deletions sdk/go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func (opts *ConfigOptions) Config(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// mode - either show or edit the configuration
// One of [ show | edit ]
// -a, --paths show the configuration paths for the system
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return config.Config(w, values)
}
Expand Down
3 changes: 3 additions & 0 deletions sdk/go/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ func (opts *DaemonOptions) Daemon(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// -u, --url string specify the API server's url and optionally its port (default "localhost:8080")
// -g, --grpc run gRPC server to serve names
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return daemon.Daemon(w, values)
}
Expand Down
4 changes: 4 additions & 0 deletions sdk/go/explore.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ func (opts *ExploreOptions) Explore(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// terms - one or more address, name, block, or transaction identifier
// -l, --local open the local TrueBlocks explorer
// -g, --google search google excluding popular blockchain explorers
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return explore.Explore(w, values)
}
Expand Down
31 changes: 31 additions & 0 deletions sdk/go/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,38 @@ func (opts *ExportOptions) Export(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// addrs - one or more addresses (0x...) to export (required)
// topics - filter by one or more log topics (only for --logs option)
// fourbytes - filter by one or more fourbytes (only for transactions and trace options)
// -p, --appearances export a list of appearances
// -r, --receipts export receipts instead of transactional data
// -l, --logs export logs instead of transactional data
// -t, --traces export traces instead of transactional data
// -n, --neighbors export the neighbors of the given address
// -C, --accounting attach accounting records to the exported data (applies to transactions export only)
// -A, --statements for the accounting options only, export only statements
// -b, --balances traverse the transaction history and show each change in ETH balances
// -i, --withdrawals export withdrawals for the given address
// -a, --articulate articulate transactions, traces, logs, and outputs
// -R, --cache_traces force the transaction's traces into the cache
// -U, --count for --appearances mode only, display only the count of records
// -c, --first_record uint the first record to process
// -e, --max_records uint the maximum number of records to process (default 250)
// -N, --relevant for log and accounting export only, export only logs relevant to one of the given export addresses
// -m, --emitter strings for the --logs option only, filter logs to show only those logs emitted by the given address(es)
// -B, --topic strings for the --logs option only, filter logs to show only those with this topic(s)
// -V, --reverted export only transactions that were reverted
// -P, --asset strings for the accounting options only, export statements only for this asset
// -f, --flow string for the accounting options only, export statements with incoming, outgoing, or zero value
// One of [ in | out | zero ]
// -y, --factory for --traces only, report addresses created by (or self-destructed by) the given address(es)
// -u, --unripe export transactions labeled upripe (i.e. less than 28 blocks old)
// -E, --reversed produce results in reverse chronological order
// -z, --no_zero for the --count option only, suppress the display of zero appearance accounts
// -F, --first_block uint first block to process (inclusive)
// -L, --last_block uint last block to process (inclusive)
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return export.Export(w, values)
}
Expand Down
11 changes: 11 additions & 0 deletions sdk/go/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,15 @@ func (g Globals) mapGlobals(values url.Values) {
if g.Verbose {
values.Set("verbose", "true")
}
// Wei bool `json:"wei,omitempty"`
// Ether bool `json:"ether,omitempty"`
// Help bool `json:"help,omitempty"`
// File string `json:"file,omitempty"`
// Version bool `json:"version,omitempty"`
// Noop bool `json:"noop,omitempty"`
// NoColor bool `json:"noColor,omitempty"`
// Cache bool `json:"cache,omitempty"`
// Decache bool `json:"decache,omitempty"`
// Caps caps.Capability `json:"-"`
// output.OutputOptions
}
6 changes: 6 additions & 0 deletions sdk/go/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ func (opts *InitOptions) Init(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// chifra init [flags]
// -a, --all in addition to Bloom filters, download full index chunks (recommended)
// -d, --dry_run display the results of the download without actually downloading
// -F, --first_block uint do not download any chunks earlier than this block
// -s, --sleep float seconds to sleep between downloads
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return initPkg.Init(w, values)
}
Expand Down
12 changes: 12 additions & 0 deletions sdk/go/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ func (opts *ListOptions) List(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// addrs - one or more addresses (0x...) to list (required)
// -U, --count display only the count of records for each monitor
// -z, --no_zero for the --count option only, suppress the display of zero appearance accounts
// -b, --bounds report first and last block this address appears
// -u, --unripe list transactions labeled upripe (i.e. less than 28 blocks old)
// -s, --silent freshen the monitor only (no reporting)
// -c, --first_record uint the first record to process
// -e, --max_records uint the maximum number of records to process (default 250)
// -E, --reversed produce results in reverse chronological order
// -F, --first_block uint first block to export (inclusive, ignored when freshening)
// -L, --last_block uint last block to export (inclusive, ignored when freshening)
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return list.List(w, values)
}
Expand Down
5 changes: 5 additions & 0 deletions sdk/go/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ func (opts *LogsOptions) Logs(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// transactions - a space-separated list of one or more transaction identifiers (required)
// -m, --emitter strings filter logs to show only those logs emitted by the given address(es)
// -B, --topic strings filter logs to show only those with this topic(s)
// -a, --articulate articulate the retrieved data if ABIs can be found
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return logs.Logs(w, values)
}
Expand Down
12 changes: 12 additions & 0 deletions sdk/go/monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ func (opts *MonitorsOptions) Monitors(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// addrs - one or more addresses (0x...) to process
// --delete delete a monitor, but do not remove it
// --undelete undelete a previously deleted monitor
// --remove remove a previously deleted monitor
// -C, --clean clean (i.e. remove duplicate appearances) from monitors
// -l, --list list monitors in the cache (--verbose for more detail)
// -w, --watch continually scan for new blocks and extract data as per the command file
// -a, --watchlist string available with --watch option only, a file containing the addresses to watch
// -c, --commands string available with --watch option only, the file containing the list of commands to apply to each watched address
// -b, --batch_size uint available with --watch option only, the number of monitors to process in each batch (default 8)
// -s, --sleep float available with --watch option only, the number of seconds to sleep between runs (default 14)
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return monitors.Monitors(w, values)
}
Expand Down
13 changes: 13 additions & 0 deletions sdk/go/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,20 @@ func (opts *NamesOptions) Names(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// terms - a space separated list of one or more search terms (required)
// -e, --expand expand search to include all fields (search name, address, and symbol otherwise)
// -m, --match_case do case-sensitive search
// -a, --all include all (including custom) names in the search
// -c, --custom include only custom named accounts in the search
// -p, --prefund include prefund accounts in the search
// -s, --addr display only addresses in the results (useful for scripting, assumes --no_header)
// -g, --tags export the list of tags and subtags only
// -C, --clean clean the data (addrs to lower case, sort by addr)
// -r, --regular only available with --clean, cleans regular names database
// -d, --dry_run only available with --clean or --autoname, outputs changes to stdout instead of updating databases
// -A, --autoname string an address assumed to be a token, added automatically to names database if true
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return names.Names(w, values)
}
Expand Down
3 changes: 3 additions & 0 deletions sdk/go/receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func (opts *ReceiptsOptions) Receipts(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// transactions - a space-separated list of one or more transaction identifiers (required)
// -a, --articulate articulate the retrieved data if ABIs can be found
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return receipts.Receipts(w, values)
}
Expand Down
4 changes: 4 additions & 0 deletions sdk/go/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ func (opts *ScrapeOptions) Scrape(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// -n, --block_cnt uint maximum number of blocks to process per pass (default 2000)
// -s, --sleep float seconds to sleep between scraper passes (default 14)
// -l, --touch uint first block to visit when scraping (snapped back to most recent snap_to_grid mark)
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return scrape.Scrape(w, values)
}
Expand Down
11 changes: 11 additions & 0 deletions sdk/go/slurp.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ func (opts *SlurpOptions) Slurp(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// addrs - one or more addresses to slurp from Etherscan (required)
// blocks - an optional range of blocks to slurp
// -t, --types strings which types of transactions to request
// One or more of [ ext | int | token | nfts | 1155 | miner | uncles | withdrawals | all ]
// -p, --appearances show only the blocknumber.tx_id appearances of the exported transactions
// -a, --articulate articulate the retrieved data if ABIs can be found
// -S, --source string the source of the slurped data
// One of [ etherscan | key ] (default "etherscan")
// -U, --count for --appearances mode only, display only the count of records
// -s, --sleep float seconds to sleep between requests (default 0.25)
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return slurp.Slurp(w, values)
}
Expand Down
10 changes: 10 additions & 0 deletions sdk/go/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ func (opts *StateOptions) State(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// addrs - one or more addresses (0x...) from which to retrieve balances (required)
// blocks - an optional list of one or more blocks at which to report balances, defaults to 'latest'
// -p, --parts strings control which state to export
// One or more of [ none | some | all | balance | nonce | code | proxy | deployed | accttype ]
// -c, --changes only report a balance when it changes from one block to the next
// -z, --no_zero suppress the display of zero balance accounts
// -l, --call string call a smart contract with a solidity syntax, a four-byte and parameters, or encoded call data
// -a, --articulate for the --call option only, articulate the retrieved data if ABIs can be found
// -r, --proxy_for string for the --call option only, redirects calls to this implementation
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return state.State(w, values)
}
Expand Down
7 changes: 7 additions & 0 deletions sdk/go/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ func (opts *StatusOptions) Status(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// modes - the (optional) name of the binary cache to report on, terse otherwise
// One or more of [ index | blooms | blocks | transactions | traces | logs | statements | results | state | tokens | monitors | names | abis | slurps | staging | unripe | maps | some | all ]
// -d, --diagnose same as the default but with additional diagnostics
// -c, --first_record uint the first record to process
// -e, --max_records uint the maximum number of records to process (default 10000)
// -a, --chains include a list of chain configurations in the output
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return status.Status(w, values)
}
Expand Down
8 changes: 8 additions & 0 deletions sdk/go/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ func (opts *TokensOptions) Tokens(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// addrs - two or more addresses (0x...), the first is an ERC20 token, balances for the rest are reported (required)
// blocks - an optional list of one or more blocks at which to report balances, defaults to 'latest'
// -p, --parts strings which parts of the token information to retrieve
// One or more of [ name | symbol | decimals | totalSupply | version | all ]
// -b, --by_acct consider each address an ERC20 token except the last, whose balance is reported for each token
// -c, --changes only report a balance when it changes from one block to the next
// -z, --no_zero suppress the display of zero balance accounts
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return tokens.Tokens(w, values)
}
Expand Down
5 changes: 5 additions & 0 deletions sdk/go/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ func (opts *TracesOptions) Traces(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// transactions - a space-separated list of one or more transaction identifiers (required)
// -a, --articulate articulate the retrieved data if ABIs can be found
// -f, --filter string call the node's trace_filter routine with bang-separated filter
// -U, --count display only the number of traces for the transaction (fast)
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return traces.Traces(w, values)
}
Expand Down
10 changes: 10 additions & 0 deletions sdk/go/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ func (opts *TransactionsOptions) Transactions(w io.Writer) error {
values := make(url.Values)

// EXISTING_CODE
// transactions - a space-separated list of one or more transaction identifiers (required)
// -a, --articulate articulate the retrieved data if ABIs can be found
// -t, --traces include the transaction's traces in the results
// -u, --uniq display a list of uniq addresses found in the transaction
// -f, --flow string for the uniq option only, export only from or to (including trace from or to)
// One of [ from | to ]
// -l, --logs display only the logs found in the transaction(s)
// -m, --emitter strings for the --logs option only, filter logs to show only those logs emitted by the given address(es)
// -B, --topic strings for the --logs option only, filter logs to show only those with this topic(s)
// EXISTING_CODE
opts.Globals.mapGlobals(values)

return transactions.Transactions(w, values)
}
Expand Down
Loading
Loading