From 211b4c2221dbb7e75efe4b2320732d388fa857d0 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Fri, 13 Dec 2024 16:17:35 -0500 Subject: [PATCH 1/6] First working version of tx send highly suspect --- examples | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples b/examples index 39ff54ebde..8026b19f5d 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 39ff54ebde3ef22690c21cebd3312419f21d8e97 +Subproject commit 8026b19f5df21c08805f4bfb60ec50cd03e6c87c From 9663a94a4371c9f040e8ef88bd3d42131e9aa4bd Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Fri, 13 Dec 2024 23:52:41 -0500 Subject: [PATCH 2/6] --call to --calldata --- docs | 2 +- sdk | 2 +- src/apps/chifra/cmd/state.go | 2 +- src/apps/chifra/internal/abis/options.go | 2 +- src/apps/chifra/internal/blocks/options.go | 2 +- src/apps/chifra/internal/chunks/options.go | 2 +- src/apps/chifra/internal/config/options.go | 2 +- src/apps/chifra/internal/daemon/options.go | 2 +- src/apps/chifra/internal/explore/options.go | 2 +- src/apps/chifra/internal/export/options.go | 2 +- src/apps/chifra/internal/init/options.go | 2 +- src/apps/chifra/internal/list/options.go | 2 +- src/apps/chifra/internal/logs/options.go | 2 +- src/apps/chifra/internal/monitors/options.go | 2 +- src/apps/chifra/internal/names/options.go | 2 +- src/apps/chifra/internal/receipts/options.go | 2 +- src/apps/chifra/internal/scrape/options.go | 2 +- src/apps/chifra/internal/slurp/options.go | 2 +- src/apps/chifra/internal/state/README.md | 12 +++-- src/apps/chifra/internal/state/options.go | 20 +++---- src/apps/chifra/internal/state/output.go | 2 +- src/apps/chifra/internal/state/validate.go | 2 +- src/apps/chifra/internal/status/options.go | 2 +- src/apps/chifra/internal/tokens/options.go | 2 +- src/apps/chifra/internal/traces/options.go | 2 +- .../chifra/internal/transactions/options.go | 2 +- src/apps/chifra/internal/when/options.go | 2 +- .../goMaker/templates/cmd-line-options.csv | 2 +- ...apps_chifra_internal_route_options.go.tmpl | 2 +- src/dev_tools/sdkFuzzer/state.go | 6 +-- src/dev_tools/testRunner/testCases/state.csv | 52 +++++++++---------- tests | 2 +- 32 files changed, 74 insertions(+), 72 deletions(-) diff --git a/docs b/docs index 1aa6343df5..39c854363a 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 1aa6343df572fd6ee049e30ddf4337046691dd4c +Subproject commit 39c854363a4c55f8c75d8c42e66bf4cbbb3ee7ce diff --git a/sdk b/sdk index 3782f77fcf..46037e03ae 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 3782f77fcf9577bdacd99a86df32f4190a559795 +Subproject commit 46037e03ae49af126b50310761089c5505ca675c diff --git a/src/apps/chifra/cmd/state.go b/src/apps/chifra/cmd/state.go index 5ce0b04aa0..eb1707d53a 100644 --- a/src/apps/chifra/cmd/state.go +++ b/src/apps/chifra/cmd/state.go @@ -71,7 +71,7 @@ func init() { One or more of [ balance | nonce | code | proxy | deployed | accttype | some | all ]`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Changes, "changes", "c", false, `only report a balance when it changes from one block to the next`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().NoZero, "no_zero", "z", false, `suppress the display of zero balance accounts`) - stateCmd.Flags().StringVarP(&statePkg.GetOptions().Call, "call", "l", "", `write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings`) + stateCmd.Flags().StringVarP(&statePkg.GetOptions().Calldata, "calldata", "l", "", `write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings`) stateCmd.Flags().StringVarP(&statePkg.GetOptions().Send, "send", "s", "", `send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Articulate, "articulate", "a", false, `for the --call option only, articulate the retrieved data if ABIs can be found`) stateCmd.Flags().StringVarP(&statePkg.GetOptions().ProxyFor, "proxy_for", "r", "", `for the --call option only, redirects calls to this implementation`) diff --git a/src/apps/chifra/internal/abis/options.go b/src/apps/chifra/internal/abis/options.go index 71aaeeba60..beb6df3ace 100644 --- a/src/apps/chifra/internal/abis/options.go +++ b/src/apps/chifra/internal/abis/options.go @@ -131,7 +131,7 @@ func abisFinishParse(args []string) *AbisOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/blocks/options.go b/src/apps/chifra/internal/blocks/options.go index ced2b623bf..3454bc82e7 100644 --- a/src/apps/chifra/internal/blocks/options.go +++ b/src/apps/chifra/internal/blocks/options.go @@ -155,7 +155,7 @@ func blocksFinishParse(args []string) *BlocksOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/chunks/options.go b/src/apps/chifra/internal/chunks/options.go index 6677fcb681..44eee6d576 100644 --- a/src/apps/chifra/internal/chunks/options.go +++ b/src/apps/chifra/internal/chunks/options.go @@ -194,7 +194,7 @@ func chunksFinishParse(args []string) *ChunksOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/config/options.go b/src/apps/chifra/internal/config/options.go index 2591bff2b2..70a792f64a 100644 --- a/src/apps/chifra/internal/config/options.go +++ b/src/apps/chifra/internal/config/options.go @@ -98,7 +98,7 @@ func configFinishParse(args []string) *ConfigOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/daemon/options.go b/src/apps/chifra/internal/daemon/options.go index ab10039e43..35d225c4be 100644 --- a/src/apps/chifra/internal/daemon/options.go +++ b/src/apps/chifra/internal/daemon/options.go @@ -135,7 +135,7 @@ func daemonFinishParse(args []string) *DaemonOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/explore/options.go b/src/apps/chifra/internal/explore/options.go index 45aba7152d..4e349e8338 100644 --- a/src/apps/chifra/internal/explore/options.go +++ b/src/apps/chifra/internal/explore/options.go @@ -113,7 +113,7 @@ func exploreFinishParse(args []string) *ExploreOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/export/options.go b/src/apps/chifra/internal/export/options.go index 9c5e9d0737..f67b9cbb65 100644 --- a/src/apps/chifra/internal/export/options.go +++ b/src/apps/chifra/internal/export/options.go @@ -244,7 +244,7 @@ func exportFinishParse(args []string) *ExportOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/init/options.go b/src/apps/chifra/internal/init/options.go index 65a87724b5..70bee0863b 100644 --- a/src/apps/chifra/internal/init/options.go +++ b/src/apps/chifra/internal/init/options.go @@ -115,7 +115,7 @@ func initFinishParse(args []string) *InitOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/list/options.go b/src/apps/chifra/internal/list/options.go index c649f3bb1a..f4635201ad 100644 --- a/src/apps/chifra/internal/list/options.go +++ b/src/apps/chifra/internal/list/options.go @@ -149,7 +149,7 @@ func listFinishParse(args []string) *ListOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/logs/options.go b/src/apps/chifra/internal/logs/options.go index d92ee4bda9..3c4bce9408 100644 --- a/src/apps/chifra/internal/logs/options.go +++ b/src/apps/chifra/internal/logs/options.go @@ -115,7 +115,7 @@ func logsFinishParse(args []string) *LogsOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/monitors/options.go b/src/apps/chifra/internal/monitors/options.go index 27a3f4846a..f240ca529e 100644 --- a/src/apps/chifra/internal/monitors/options.go +++ b/src/apps/chifra/internal/monitors/options.go @@ -153,7 +153,7 @@ func monitorsFinishParse(args []string) *MonitorsOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/names/options.go b/src/apps/chifra/internal/names/options.go index e6bdb70cff..b41d22cd62 100644 --- a/src/apps/chifra/internal/names/options.go +++ b/src/apps/chifra/internal/names/options.go @@ -167,7 +167,7 @@ func namesFinishParse(args []string) *NamesOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/receipts/options.go b/src/apps/chifra/internal/receipts/options.go index f6feaadbd7..4eb1c5d818 100644 --- a/src/apps/chifra/internal/receipts/options.go +++ b/src/apps/chifra/internal/receipts/options.go @@ -100,7 +100,7 @@ func receiptsFinishParse(args []string) *ReceiptsOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/scrape/options.go b/src/apps/chifra/internal/scrape/options.go index 1cdb599b21..e9d349a8c0 100644 --- a/src/apps/chifra/internal/scrape/options.go +++ b/src/apps/chifra/internal/scrape/options.go @@ -152,7 +152,7 @@ func scrapeFinishParse(args []string) *ScrapeOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/slurp/options.go b/src/apps/chifra/internal/slurp/options.go index 82024d24ee..b185475587 100644 --- a/src/apps/chifra/internal/slurp/options.go +++ b/src/apps/chifra/internal/slurp/options.go @@ -174,7 +174,7 @@ func slurpFinishParse(args []string) *SlurpOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/state/README.md b/src/apps/chifra/internal/state/README.md index 5b173a4aaa..24f91af14c 100644 --- a/src/apps/chifra/internal/state/README.md +++ b/src/apps/chifra/internal/state/README.md @@ -23,10 +23,10 @@ Flags: One or more of [ balance | nonce | code | proxy | deployed | accttype | some | all ] -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 write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings - -s, --send string send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string - -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 + -l, --call write-only call (a query) to a smart contract + -d, --calldata string for commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send) + -a, --articulate for commands only, articulate the retrieved data if ABIs can be found + -r, --proxy_for string for commands only, redirects calls to this implementation -H, --ether specify value in ether -o, --cache force the results of the query into the cache -D, --decache removes related items from the cache @@ -40,11 +40,13 @@ Notes: - If the queried node does not store historical state, the results are undefined. - Special blocks are detailed under chifra when --list. - Balance is the default mode. To select a single mode use none first, followed by that mode. - - Valid parameters for --call include Solidity-like syntax: balanceOf(0x316b...183d), a four-byte followed by parameters: 0x70a08231(0x316b...183d), or encoded input data. + - Valid parameters for --calldata include Solidity-like syntax: balanceOf(0x316b...), a four-byte followed by parameters: 0x70a08231(0x316b...), or encoded input data. - You may specify multiple parts on a single line. - In the --call string, you may separate multiple calls with a colon. - Your use of the unaudited --send option legally absolves, in any jurisdiction, TrueBlocks, LLC or any associated parties from liability or loss related to such use. - The --send option does not validate its input before sending your transaction to the network. If you provide invalid data, you may lose your funds. Be warned. + - As of version 4.0.0, use --call --calldata to provide your command. + - --calldata may be one or more solidity calls, four-byte plus parameters, or encoded call data strings. ``` Data models produced by this tool: diff --git a/src/apps/chifra/internal/state/options.go b/src/apps/chifra/internal/state/options.go index f843c6ab62..4ca1299082 100644 --- a/src/apps/chifra/internal/state/options.go +++ b/src/apps/chifra/internal/state/options.go @@ -35,7 +35,7 @@ type StateOptions struct { Parts []string `json:"parts,omitempty"` // Control which state to export Changes bool `json:"changes,omitempty"` // Only report a balance when it changes from one block to the next NoZero bool `json:"noZero,omitempty"` // Suppress the display of zero balance accounts - Call string `json:"call,omitempty"` // Write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings + Calldata string `json:"calldata,omitempty"` // Write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings Send string `json:"send,omitempty"` // Send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string Articulate bool `json:"articulate,omitempty"` // For the --call option only, articulate the retrieved data if ABIs can be found ProxyFor string `json:"proxyFor,omitempty"` // For the --call option only, redirects calls to this implementation @@ -56,7 +56,7 @@ func (opts *StateOptions) testLog() { logger.TestLog(len(opts.Parts) > 0, "Parts: ", opts.Parts) logger.TestLog(opts.Changes, "Changes: ", opts.Changes) logger.TestLog(opts.NoZero, "NoZero: ", opts.NoZero) - logger.TestLog(len(opts.Call) > 0, "Call: ", opts.Call) + logger.TestLog(len(opts.Calldata) > 0, "Calldata: ", opts.Calldata) logger.TestLog(len(opts.Send) > 0, "Send: ", opts.Send) logger.TestLog(opts.Articulate, "Articulate: ", opts.Articulate) logger.TestLog(len(opts.ProxyFor) > 0, "ProxyFor: ", opts.ProxyFor) @@ -104,8 +104,8 @@ func StateFinishParseInternal(w io.Writer, values url.Values) *StateOptions { opts.Changes = true case "noZero": opts.NoZero = true - case "call": - opts.Call = value[0] + case "calldata": + opts.Calldata = value[0] case "send": opts.Send = value[0] case "articulate": @@ -124,8 +124,8 @@ func StateFinishParseInternal(w io.Writer, values url.Values) *StateOptions { opts.Conn = opts.Globals.FinishParseApi(w, values, opts.getCaches()) // EXISTING_CODE - opts.Call = strings.Replace(strings.Trim(opts.Call, "'"), "'", "\"", -1) - opts.Calls = strings.Split(opts.Call, ":") + opts.Calldata = strings.Replace(strings.Trim(opts.Calldata, "'"), "'", "\"", -1) + opts.Calls = strings.Split(opts.Calldata, ":") if len(opts.Blocks) == 0 { if opts.Globals.TestMode { opts.Blocks = []string{"17000000"} @@ -147,7 +147,7 @@ func stateFinishParse(args []string) *StateOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ @@ -167,8 +167,8 @@ func stateFinishParse(args []string) *StateOptions { opts.Blocks = append(opts.Blocks, arg) } } - opts.Call = strings.Replace(strings.Trim(opts.Call, "'"), "'", "\"", -1) - opts.Calls = strings.Split(opts.Call, ":") + opts.Calldata = strings.Replace(strings.Trim(opts.Calldata, "'"), "'", "\"", -1) + opts.Calls = strings.Split(opts.Calldata, ":") if len(opts.Blocks) == 0 { if opts.Globals.TestMode { opts.Blocks = []string{"17000000"} @@ -218,7 +218,7 @@ func (opts *StateOptions) getCaches() (caches map[walk.CacheType]bool) { // EXISTING_CODE caches = map[walk.CacheType]bool{ walk.Cache_State: true, - walk.Cache_Results: len(opts.Call) > 0, + walk.Cache_Results: len(opts.Calldata) > 0, } // EXISTING_CODE return diff --git a/src/apps/chifra/internal/state/output.go b/src/apps/chifra/internal/state/output.go index 000c267ba9..e24cb965ed 100644 --- a/src/apps/chifra/internal/state/output.go +++ b/src/apps/chifra/internal/state/output.go @@ -56,7 +56,7 @@ func (opts *StateOptions) StateInternal(rCtx *output.RenderCtx) error { // EXISTING_CODE if opts.Globals.Decache { err = opts.HandleDecache(rCtx) - } else if len(opts.Call) > 0 { + } else if len(opts.Calldata) > 0 { err = opts.HandleCall(rCtx) } else if len(opts.Send) > 0 { err = opts.HandleSend(rCtx) diff --git a/src/apps/chifra/internal/state/validate.go b/src/apps/chifra/internal/state/validate.go index a93a384e0d..056f7da35b 100644 --- a/src/apps/chifra/internal/state/validate.go +++ b/src/apps/chifra/internal/state/validate.go @@ -37,7 +37,7 @@ func (opts *StateOptions) validateState() error { // do nothing for now } else { - if len(opts.Call) > 0 { + if len(opts.Calldata) > 0 { if len(opts.Parts) > 0 { return validate.Usage("The {0} option is not available{1}.", "--parts", " with the --call option") } diff --git a/src/apps/chifra/internal/status/options.go b/src/apps/chifra/internal/status/options.go index a14e4b5c48..be24d3838a 100644 --- a/src/apps/chifra/internal/status/options.go +++ b/src/apps/chifra/internal/status/options.go @@ -127,7 +127,7 @@ func statusFinishParse(args []string) *StatusOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/tokens/options.go b/src/apps/chifra/internal/tokens/options.go index 99e4385d98..5b78f91af7 100644 --- a/src/apps/chifra/internal/tokens/options.go +++ b/src/apps/chifra/internal/tokens/options.go @@ -134,7 +134,7 @@ func tokensFinishParse(args []string) *TokensOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/traces/options.go b/src/apps/chifra/internal/traces/options.go index 172aded724..3ee583e924 100644 --- a/src/apps/chifra/internal/traces/options.go +++ b/src/apps/chifra/internal/traces/options.go @@ -108,7 +108,7 @@ func tracesFinishParse(args []string) *TracesOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/transactions/options.go b/src/apps/chifra/internal/transactions/options.go index 6b6837514f..52e3f6822e 100644 --- a/src/apps/chifra/internal/transactions/options.go +++ b/src/apps/chifra/internal/transactions/options.go @@ -137,7 +137,7 @@ func transactionsFinishParse(args []string) *TransactionsOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/apps/chifra/internal/when/options.go b/src/apps/chifra/internal/when/options.go index fcdb1fb528..a38c3a5a89 100644 --- a/src/apps/chifra/internal/when/options.go +++ b/src/apps/chifra/internal/when/options.go @@ -132,7 +132,7 @@ func whenFinishParse(args []string) *WhenOptions { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/dev_tools/goMaker/templates/cmd-line-options.csv b/src/dev_tools/goMaker/templates/cmd-line-options.csv index 724ac1aa9b..1abd238a3d 100644 --- a/src/dev_tools/goMaker/templates/cmd-line-options.csv +++ b/src/dev_tools/goMaker/templates/cmd-line-options.csv @@ -206,7 +206,7 @@ num,folder,group,route,tool,longName,hotKey,def_val,attributes,handler,option_ty 32040,tools,Chain State,state,getState,parts,p,,visible|docs,,flag,list,,,,,control which state to export 32050,tools,Chain State,state,getState,changes,c,,visible|docs,,switch,,,,,,only report a balance when it changes from one block to the next 32060,tools,Chain State,state,getState,no_zero,z,,visible|docs,,switch,,,,,,suppress the display of zero balance accounts -32070,tools,Chain State,state,getState,call,l,,visible|docs,1,flag,,result,,,,write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings +32070,tools,Chain State,state,getState,calldata,l,,visible|docs,1,flag,,result,,,,write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings 32075,tools,Chain State,state,getState,send,s,,visible|docs,2,flag,,result,,,,send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string 32080,tools,Chain State,state,getState,articulate,a,,visible|docs,,switch,,,,,,for the --call option only, articulate the retrieved data if ABIs can be found 32090,tools,Chain State,state,getState,proxy_for,r,,visible|docs,,flag,
,,,,,for the --call option only, redirects calls to this implementation diff --git a/src/dev_tools/goMaker/templates/generators/routes/src_apps_chifra_internal_route_options.go.tmpl b/src/dev_tools/goMaker/templates/generators/routes/src_apps_chifra_internal_route_options.go.tmpl index 3f8e282b35..d404820ea9 100644 --- a/src/dev_tools/goMaker/templates/generators/routes/src_apps_chifra_internal_route_options.go.tmpl +++ b/src/dev_tools/goMaker/templates/generators/routes/src_apps_chifra_internal_route_options.go.tmpl @@ -74,7 +74,7 @@ func {{toLower .Route}}FinishParse(args []string) *{{toProper .Route}}Options { if len(args) > 0 { tmp := []string{} for _, arg := range args { - if value := dedup[arg]; value == 0 { + if cnt := dedup[arg]; cnt == 0 { tmp = append(tmp, arg) } dedup[arg]++ diff --git a/src/dev_tools/sdkFuzzer/state.go b/src/dev_tools/sdkFuzzer/state.go index 760a1acee8..fe72468dd1 100644 --- a/src/dev_tools/sdkFuzzer/state.go +++ b/src/dev_tools/sdkFuzzer/state.go @@ -135,11 +135,11 @@ func TestState(which, value, fn string, opts *sdk.StateOptions) { ReportOkay(fn) } } - case "call": - if call, _, err := opts.StateCall(value); err != nil { + case "calldata": + if calldata, _, err := opts.StateCalldata(value); err != nil { ReportError(fn, opts, err) } else { - if err := SaveToFile[types.Result](fn, call); err != nil { + if err := SaveToFile[types.Result](fn, calldata); err != nil { ReportError2(fn, err) } else { ReportOkay(fn) diff --git a/src/dev_tools/testRunner/testCases/state.csv b/src/dev_tools/testRunner/testCases/state.csv index 17babab021..9c12cc26d5 100644 --- a/src/dev_tools/testRunner/testCases/state.csv +++ b/src/dev_tools/testRunner/testCases/state.csv @@ -53,39 +53,39 @@ on ,both ,fast ,state ,tools ,getState ,fmt_junk ,y on ,both ,fast ,state ,tools ,getState ,get_range ,y ,addrs = 0xbb9bc244d798123fde783fcc1c72d3bb8c189413 & blocks = 1428000-1438000:200 on ,both ,fast ,state ,tools ,getState ,ens_test ,y ,addrs = trueblocks.eth & blocks = 8854700-8854900:20 -on ,both ,fast ,state ,tools ,getState ,contract_call_fail1 ,y ,call = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875 & blocks = 6523977-6540000:2000 -on ,both ,fast ,state ,tools ,getState ,contract_call_fail2 ,y ,call = '12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 -on ,both ,fast ,state ,tools ,getState ,contract_call_fail4 ,y ,call = '0x12065fe01()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 -on ,both ,fast ,state ,tools ,getState ,contract_call ,y ,call = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 -on ,api ,fast ,state ,tools ,getState ,contract_call2_api ,y ,"call = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,cmd ,fast ,state ,tools ,getState ,contract_call2_cmd ,y ,"call = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,api ,fast ,state ,tools ,getState ,contract_call2_api_ens ,y ,"call = 'manifestHashMap(trueblocks.eth,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,cmd ,fast ,state ,tools ,getState ,contract_call2_cmd_ens ,y ,"call = 'manifestHashMap(trueblocks.eth,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,both ,fast ,state ,tools ,getState ,contract_call3_two ,y ,"call = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet""):owner()' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,both ,fast ,state ,tools ,getState ,contract_call3_two_ens ,y ,"call = 'manifestHashMap(trueblocks.eth,""mainnet""):0x8da5cb5b' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,both ,fast ,state ,tools ,getState ,uniswap_factory_getPair ,n ,call = 0xe6a439050000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 & addrs = 0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f & blocks = 10092000 & fmt = csv -on ,both ,fast ,state ,tools ,getState ,uniswap_token0 ,y ,call = '0x0dfe1681()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,uniswap_token0_name ,n ,call = '0x06fdde03()' & addrs = 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 & blocks = 10092000 & fmt = txt -on ,both ,fast ,state ,tools ,getState ,uniswap_token1 ,y ,call = '0xd21220a7()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -local ,both ,fast ,state ,tools ,getState ,uniswap_token1_name ,y ,call = '0x06fdde03()' & addrs = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,uniswap_name ,y ,call = '0x06fdde03()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,uniswap_reserve ,n ,call = '0x0902f1ac()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 & fmt = csv -on ,both ,fast ,state ,tools ,getState ,uniswap_fail ,y ,call = '0x0902f1ad()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,proxy_fail ,y ,call = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,proxy_call_direct ,y ,call = '0x0902f1ac()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,proxy_for ,y ,call = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & proxy_for = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,contract_call_fail1 ,y ,calldata = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,contract_call_fail2 ,y ,calldata = '12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,contract_call_fail4 ,y ,calldata = '0x12065fe01()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,contract_call ,y ,calldata = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,api ,fast ,state ,tools ,getState ,contract_call2_api ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,cmd ,fast ,state ,tools ,getState ,contract_call2_cmd ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,api ,fast ,state ,tools ,getState ,contract_call2_api_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,cmd ,fast ,state ,tools ,getState ,contract_call2_cmd_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,both ,fast ,state ,tools ,getState ,contract_call3_two ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet""):owner()' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,both ,fast ,state ,tools ,getState ,contract_call3_two_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet""):0x8da5cb5b' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,both ,fast ,state ,tools ,getState ,uniswap_factory_getPair ,n ,calldata = 0xe6a439050000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 & addrs = 0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f & blocks = 10092000 & fmt = csv +on ,both ,fast ,state ,tools ,getState ,uniswap_token0 ,y ,calldata = '0x0dfe1681()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,uniswap_token0_name ,n ,calldata = '0x06fdde03()' & addrs = 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 & blocks = 10092000 & fmt = txt +on ,both ,fast ,state ,tools ,getState ,uniswap_token1 ,y ,calldata = '0xd21220a7()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +local ,both ,fast ,state ,tools ,getState ,uniswap_token1_name ,y ,calldata = '0x06fdde03()' & addrs = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,uniswap_name ,y ,calldata = '0x06fdde03()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,uniswap_reserve ,n ,calldata = '0x0902f1ac()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 & fmt = csv +on ,both ,fast ,state ,tools ,getState ,uniswap_fail ,y ,calldata = '0x0902f1ad()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,proxy_fail ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,proxy_call_direct ,y ,calldata = '0x0902f1ac()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,proxy_for ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & proxy_for = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 on ,both ,fast ,state ,tools ,getState ,proxy_2 ,y ,parts = all & addrs = 0x7cfb89D6DF1b89A678Dcaf42B9c262593e881E22 & fmt = json & blocks = 14000000 on ,both ,fast ,state ,tools ,getState ,fail_art_not_call ,y ,addrs = 0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359 & parts = accttype & blocks = 2500000 & articulate # Not sure why this fails... -on ,both ,fast ,state ,tools ,getState ,contract_call_fail3 ,y ,call & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,contract_call_fail3 ,y ,calldata & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 # This started failing when we went to sync.Map for the abiMap and at the same time started using IterateOverMap. Possibly ordering changes in the map? -on ,both ,fast ,state ,tools ,getState ,proxy_imp ,n ,call = '0xbb82aa5e()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & blocks = 10092000 & fmt = csv +on ,both ,fast ,state ,tools ,getState ,proxy_imp ,n ,calldata = '0xbb82aa5e()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & blocks = 10092000 & fmt = csv -on ,both ,fast ,state ,tools ,getState ,not_call_and_parts ,y ,call = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & parts = some -on ,both ,fast ,state ,tools ,getState ,not_call_and_changes ,y ,call = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & changes -on ,both ,fast ,state ,tools ,getState ,not_call_and_nozero ,y ,call = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & no_zero +on ,both ,fast ,state ,tools ,getState ,not_call_and_parts ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & parts = some +on ,both ,fast ,state ,tools ,getState ,not_call_and_changes ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & changes +on ,both ,fast ,state ,tools ,getState ,not_call_and_nozero ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & no_zero on ,both ,fast ,state ,tools ,getState ,with_no_block ,y ,addrs = 0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359 on ,both ,fast ,state ,tools ,getState ,not_not_call_and_proxy ,y ,addrs = 0xf6f1cd99578ea87b67ae2bf7e9ca3e7e99d0fb98 & proxy_for = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 diff --git a/tests b/tests index c45987f6c3..c340db1718 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit c45987f6c3d50341b043232e74f6b5e991429e10 +Subproject commit c340db17186b2e1f36330449ca78e8b78acdbb20 From fb15c7f7fdbe624dec6322a5a580ced0e5099eeb Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Sat, 14 Dec 2024 00:23:39 -0500 Subject: [PATCH 3/6] --call to --calldata in chifra state --- docs | 2 +- sdk | 2 +- src/apps/chifra/cmd/state.go | 17 +++++++++++------ src/apps/chifra/internal/state/README.md | 12 +++++------- src/apps/chifra/internal/state/options.go | 14 +++++++------- src/apps/chifra/internal/state/output.go | 2 +- .../goMaker/templates/cmd-line-options.csv | 12 +++++++----- src/dev_tools/sdkFuzzer/state.go | 12 ++++++------ tests | 2 +- 9 files changed, 40 insertions(+), 35 deletions(-) diff --git a/docs b/docs index 39c854363a..0fa5096201 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 39c854363a4c55f8c75d8c42e66bf4cbbb3ee7ce +Subproject commit 0fa5096201b929e0d2fc21b5b815be10087c0d02 diff --git a/sdk b/sdk index 46037e03ae..108f2a8934 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 46037e03ae49af126b50310761089c5505ca675c +Subproject commit 108f2a8934804a157c899fbf717a927216a98a68 diff --git a/src/apps/chifra/cmd/state.go b/src/apps/chifra/cmd/state.go index eb1707d53a..e1ba6de5b2 100644 --- a/src/apps/chifra/cmd/state.go +++ b/src/apps/chifra/cmd/state.go @@ -52,11 +52,13 @@ Notes: - If the queried node does not store historical state, the results are undefined. - Special blocks are detailed under chifra when --list. - Balance is the default mode. To select a single mode use none first, followed by that mode. - - Valid parameters for --call include Solidity-like syntax: balanceOf(0x316b...183d), a four-byte followed by parameters: 0x70a08231(0x316b...183d), or encoded input data. + - Valid parameters for --calldata include Solidity-like syntax: balanceOf(0x316b...), a four-byte followed by parameters: 0x70a08231(0x316b...), or encoded input data. - You may specify multiple parts on a single line. - In the --call string, you may separate multiple calls with a colon. - Your use of the unaudited --send option legally absolves, in any jurisdiction, TrueBlocks, LLC or any associated parties from liability or loss related to such use. - - The --send option does not validate its input before sending your transaction to the network. If you provide invalid data, you may lose your funds. Be warned.` + - The --send option does not validate its input before sending your transaction to the network. If you provide invalid data, you may lose your funds. Be warned. + - As of version 4.0.0, use --call --calldata to provide your command. + - --calldata may be one or more solidity calls, four-byte plus parameters, or encoded call data strings.` func init() { var capabilities caps.Capability // capabilities for chifra state @@ -71,10 +73,13 @@ func init() { One or more of [ balance | nonce | code | proxy | deployed | accttype | some | all ]`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Changes, "changes", "c", false, `only report a balance when it changes from one block to the next`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().NoZero, "no_zero", "z", false, `suppress the display of zero balance accounts`) - stateCmd.Flags().StringVarP(&statePkg.GetOptions().Calldata, "calldata", "l", "", `write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings`) - stateCmd.Flags().StringVarP(&statePkg.GetOptions().Send, "send", "s", "", `send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string`) - stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Articulate, "articulate", "a", false, `for the --call option only, articulate the retrieved data if ABIs can be found`) - stateCmd.Flags().StringVarP(&statePkg.GetOptions().ProxyFor, "proxy_for", "r", "", `for the --call option only, redirects calls to this implementation`) + stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Send, "send", "s", false, `writes a transaction to an address (see docs for more information) (hidden)`) + stateCmd.Flags().StringVarP(&statePkg.GetOptions().Calldata, "calldata", "d", "", `for commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send)`) + stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Articulate, "articulate", "a", false, `for commands only, articulate the retrieved data if ABIs can be found`) + stateCmd.Flags().StringVarP(&statePkg.GetOptions().ProxyFor, "proxy_for", "r", "", `for commands only, redirects calls to this implementation`) + if os.Getenv("TEST_MODE") != "true" { + _ = stateCmd.Flags().MarkHidden("send") + } globals.InitGlobals("state", stateCmd, &statePkg.GetOptions().Globals, capabilities) stateCmd.SetUsageTemplate(UsageWithNotes(notesState)) diff --git a/src/apps/chifra/internal/state/README.md b/src/apps/chifra/internal/state/README.md index 24f91af14c..001932176c 100644 --- a/src/apps/chifra/internal/state/README.md +++ b/src/apps/chifra/internal/state/README.md @@ -23,10 +23,10 @@ Flags: One or more of [ balance | nonce | code | proxy | deployed | accttype | some | all ] -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 write-only call (a query) to a smart contract - -d, --calldata string for commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send) - -a, --articulate for commands only, articulate the retrieved data if ABIs can be found - -r, --proxy_for string for commands only, redirects calls to this implementation + -l, --calldata string write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings + -s, --send string send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string + -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 -H, --ether specify value in ether -o, --cache force the results of the query into the cache -D, --decache removes related items from the cache @@ -40,13 +40,11 @@ Notes: - If the queried node does not store historical state, the results are undefined. - Special blocks are detailed under chifra when --list. - Balance is the default mode. To select a single mode use none first, followed by that mode. - - Valid parameters for --calldata include Solidity-like syntax: balanceOf(0x316b...), a four-byte followed by parameters: 0x70a08231(0x316b...), or encoded input data. + - Valid parameters for --call include Solidity-like syntax: balanceOf(0x316b...183d), a four-byte followed by parameters: 0x70a08231(0x316b...183d), or encoded input data. - You may specify multiple parts on a single line. - In the --call string, you may separate multiple calls with a colon. - Your use of the unaudited --send option legally absolves, in any jurisdiction, TrueBlocks, LLC or any associated parties from liability or loss related to such use. - The --send option does not validate its input before sending your transaction to the network. If you provide invalid data, you may lose your funds. Be warned. - - As of version 4.0.0, use --call --calldata to provide your command. - - --calldata may be one or more solidity calls, four-byte plus parameters, or encoded call data strings. ``` Data models produced by this tool: diff --git a/src/apps/chifra/internal/state/options.go b/src/apps/chifra/internal/state/options.go index 4ca1299082..2a3bf969ab 100644 --- a/src/apps/chifra/internal/state/options.go +++ b/src/apps/chifra/internal/state/options.go @@ -35,10 +35,10 @@ type StateOptions struct { Parts []string `json:"parts,omitempty"` // Control which state to export Changes bool `json:"changes,omitempty"` // Only report a balance when it changes from one block to the next NoZero bool `json:"noZero,omitempty"` // Suppress the display of zero balance accounts - Calldata string `json:"calldata,omitempty"` // Write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings - Send string `json:"send,omitempty"` // Send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string - Articulate bool `json:"articulate,omitempty"` // For the --call option only, articulate the retrieved data if ABIs can be found - ProxyFor string `json:"proxyFor,omitempty"` // For the --call option only, redirects calls to this implementation + Send bool `json:"send,omitempty"` // Writes a transaction to an address (see docs for more information) + Calldata string `json:"calldata,omitempty"` // For commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send) + Articulate bool `json:"articulate,omitempty"` // For commands only, articulate the retrieved data if ABIs can be found + ProxyFor string `json:"proxyFor,omitempty"` // For commands only, redirects calls to this implementation Globals globals.GlobalOptions `json:"globals,omitempty"` // The global options Conn *rpc.Connection `json:"conn,omitempty"` // The connection to the RPC server BadFlag error `json:"badFlag,omitempty"` // An error flag if needed @@ -56,8 +56,8 @@ func (opts *StateOptions) testLog() { logger.TestLog(len(opts.Parts) > 0, "Parts: ", opts.Parts) logger.TestLog(opts.Changes, "Changes: ", opts.Changes) logger.TestLog(opts.NoZero, "NoZero: ", opts.NoZero) + logger.TestLog(opts.Send, "Send: ", opts.Send) logger.TestLog(len(opts.Calldata) > 0, "Calldata: ", opts.Calldata) - logger.TestLog(len(opts.Send) > 0, "Send: ", opts.Send) logger.TestLog(opts.Articulate, "Articulate: ", opts.Articulate) logger.TestLog(len(opts.ProxyFor) > 0, "ProxyFor: ", opts.ProxyFor) opts.Conn.TestLog(opts.getCaches()) @@ -104,10 +104,10 @@ func StateFinishParseInternal(w io.Writer, values url.Values) *StateOptions { opts.Changes = true case "noZero": opts.NoZero = true + case "send": + opts.Send = true case "calldata": opts.Calldata = value[0] - case "send": - opts.Send = value[0] case "articulate": opts.Articulate = true case "proxyFor": diff --git a/src/apps/chifra/internal/state/output.go b/src/apps/chifra/internal/state/output.go index e24cb965ed..10b12e26bb 100644 --- a/src/apps/chifra/internal/state/output.go +++ b/src/apps/chifra/internal/state/output.go @@ -58,7 +58,7 @@ func (opts *StateOptions) StateInternal(rCtx *output.RenderCtx) error { err = opts.HandleDecache(rCtx) } else if len(opts.Calldata) > 0 { err = opts.HandleCall(rCtx) - } else if len(opts.Send) > 0 { + } else if opts.Send { err = opts.HandleSend(rCtx) } else { err = opts.HandleShow(rCtx) diff --git a/src/dev_tools/goMaker/templates/cmd-line-options.csv b/src/dev_tools/goMaker/templates/cmd-line-options.csv index 1abd238a3d..9791330f7f 100644 --- a/src/dev_tools/goMaker/templates/cmd-line-options.csv +++ b/src/dev_tools/goMaker/templates/cmd-line-options.csv @@ -206,20 +206,22 @@ num,folder,group,route,tool,longName,hotKey,def_val,attributes,handler,option_ty 32040,tools,Chain State,state,getState,parts,p,,visible|docs,,flag,list,,,,,control which state to export 32050,tools,Chain State,state,getState,changes,c,,visible|docs,,switch,,,,,,only report a balance when it changes from one block to the next 32060,tools,Chain State,state,getState,no_zero,z,,visible|docs,,switch,,,,,,suppress the display of zero balance accounts -32070,tools,Chain State,state,getState,calldata,l,,visible|docs,1,flag,,result,,,,write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings -32075,tools,Chain State,state,getState,send,s,,visible|docs,2,flag,,result,,,,send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string -32080,tools,Chain State,state,getState,articulate,a,,visible|docs,,switch,,,,,,for the --call option only, articulate the retrieved data if ABIs can be found -32090,tools,Chain State,state,getState,proxy_for,r,,visible|docs,,flag,
,,,,,for the --call option only, redirects calls to this implementation +32073,tools,Chain State,state,getState,send,s,,,2,switch,,result,,,,writes a transaction to an address (see docs for more information) +32087,tools,Chain State,state,getState,calldata,d,,visible|docs,1,flag,,result,,,,for commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send) +32080,tools,Chain State,state,getState,articulate,a,,visible|docs,,switch,,,,,,for commands only, articulate the retrieved data if ABIs can be found +32090,tools,Chain State,state,getState,proxy_for,r,,visible|docs,,flag,
,,,,,for commands only, redirects calls to this implementation 32100,tools,Chain State,state,getState,n1,,,,,note,,,,,,An `address` must be either an ENS name or start with '0x' and be forty-two characters long. 32110,tools,Chain State,state,getState,n2,,,,,note,,,,,,`Blocks` is a space-separated list of values, a start-end range, a `special`, or any combination. 32120,tools,Chain State,state,getState,n3,,,,,note,,,,,,If the queried node does not store historical state, the results are undefined. 32130,tools,Chain State,state,getState,n4,,,,,note,,,,,,`Special` blocks are detailed under `chifra when --list`. 32140,tools,Chain State,state,getState,n5,,,,,note,,,,,,`Balance` is the default mode. To select a single mode use `none` first, followed by that mode. -32150,tools,Chain State,state,getState,n6,,,,,note,,,,,,Valid parameters for --call include Solidity-like syntax: balanceOf(0x316b...183d), a four-byte followed by parameters: 0x70a08231(0x316b...183d), or encoded input data. +32150,tools,Chain State,state,getState,n6,,,,,note,,,,,,Valid parameters for --calldata include Solidity-like syntax: balanceOf(0x316b...), a four-byte followed by parameters: 0x70a08231(0x316b...), or encoded input data. 32160,tools,Chain State,state,getState,n7,,,,,note,,,,,,You may specify multiple `parts` on a single line. 32170,tools,Chain State,state,getState,n8,,,,,note,,,,,,In the --call string, you may separate multiple calls with a colon. 32180,tools,Chain State,state,getState,n9,,,,,note,,,,,,Your use of the unaudited --send option legally absolves, in any jurisdiction, TrueBlocks, LLC or any associated parties from liability or loss related to such use. 32185,tools,Chain State,state,getState,n10,,,,,note,,,,,,The --send option does not validate its input before sending your transaction to the network. If you provide invalid data, you may lose your funds. Be warned. +32190,tools,Chain State,state,getState,n11,,,,,note,,,,,,As of version 4.0.0, use `--call --calldata ` to provide your command. +32195,tools,Chain State,state,getState,n12,,,,,note,,,,,,--calldata may be one or more solidity calls, four-byte plus parameters, or encoded call data strings. # 33000,tools,Chain State,tokens,getTokens,,,,visible|docs,,command,,,Get token balance(s),[flags]
[address...] [block...],default|caching|names|,Retrieve token balance(s) for one or more addresses at given block(s). 33020,tools,Chain State,tokens,getTokens,addrs,,,required|visible|docs,2,positional,list,token,,,,two or more addresses (0x...), the first is an ERC20 token, balances for the rest are reported diff --git a/src/dev_tools/sdkFuzzer/state.go b/src/dev_tools/sdkFuzzer/state.go index fe72468dd1..a7187e8346 100644 --- a/src/dev_tools/sdkFuzzer/state.go +++ b/src/dev_tools/sdkFuzzer/state.go @@ -135,21 +135,21 @@ func TestState(which, value, fn string, opts *sdk.StateOptions) { ReportOkay(fn) } } - case "calldata": - if calldata, _, err := opts.StateCalldata(value); err != nil { + case "send": + if send, _, err := opts.StateSend(); err != nil { ReportError(fn, opts, err) } else { - if err := SaveToFile[types.Result](fn, calldata); err != nil { + if err := SaveToFile[types.Result](fn, send); err != nil { ReportError2(fn, err) } else { ReportOkay(fn) } } - case "send": - if send, _, err := opts.StateSend(value); err != nil { + case "calldata": + if calldata, _, err := opts.StateCalldata(value); err != nil { ReportError(fn, opts, err) } else { - if err := SaveToFile[types.Result](fn, send); err != nil { + if err := SaveToFile[types.Result](fn, calldata); err != nil { ReportError2(fn, err) } else { ReportOkay(fn) diff --git a/tests b/tests index c340db1718..93d96acc1f 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit c340db17186b2e1f36330449ca78e8b78acdbb20 +Subproject commit 93d96acc1fc5f993f7dff87554eacc82fb032dfc From b499679f70d58497399376563359c7fae6561090 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Sat, 14 Dec 2024 00:48:04 -0500 Subject: [PATCH 4/6] Adds --call back in as switch --- docs | 2 +- sdk | 2 +- src/apps/chifra/cmd/state.go | 1 + src/apps/chifra/internal/state/README.md | 12 ++-- src/apps/chifra/internal/state/options.go | 4 ++ src/apps/chifra/internal/state/output.go | 2 +- .../goMaker/templates/cmd-line-options.csv | 3 +- src/dev_tools/sdkFuzzer/state.go | 13 +++-- src/dev_tools/testRunner/testCases/state.csv | 58 ++++++++++--------- tests | 2 +- 10 files changed, 57 insertions(+), 42 deletions(-) diff --git a/docs b/docs index 0fa5096201..dd7e1bb286 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 0fa5096201b929e0d2fc21b5b815be10087c0d02 +Subproject commit dd7e1bb286a9fc91af6a324905379bc7eb5012ae diff --git a/sdk b/sdk index 108f2a8934..f431490bba 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 108f2a8934804a157c899fbf717a927216a98a68 +Subproject commit f431490bba6a730fc56f19143a473f0636ac1872 diff --git a/src/apps/chifra/cmd/state.go b/src/apps/chifra/cmd/state.go index e1ba6de5b2..7eb309d026 100644 --- a/src/apps/chifra/cmd/state.go +++ b/src/apps/chifra/cmd/state.go @@ -73,6 +73,7 @@ func init() { One or more of [ balance | nonce | code | proxy | deployed | accttype | some | all ]`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Changes, "changes", "c", false, `only report a balance when it changes from one block to the next`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().NoZero, "no_zero", "z", false, `suppress the display of zero balance accounts`) + stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Call, "call", "l", false, `write-only call (a query) to a smart contract`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Send, "send", "s", false, `writes a transaction to an address (see docs for more information) (hidden)`) stateCmd.Flags().StringVarP(&statePkg.GetOptions().Calldata, "calldata", "d", "", `for commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send)`) stateCmd.Flags().BoolVarP(&statePkg.GetOptions().Articulate, "articulate", "a", false, `for commands only, articulate the retrieved data if ABIs can be found`) diff --git a/src/apps/chifra/internal/state/README.md b/src/apps/chifra/internal/state/README.md index 001932176c..24f91af14c 100644 --- a/src/apps/chifra/internal/state/README.md +++ b/src/apps/chifra/internal/state/README.md @@ -23,10 +23,10 @@ Flags: One or more of [ balance | nonce | code | proxy | deployed | accttype | some | all ] -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, --calldata string write-only call to a smart contract with one or more solidity calls, four-byte plus parameters, or encoded call data strings - -s, --send string send a transaction to a smart contract using a solidity function, a four-byte plus parameters, or an encoded call data string - -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 + -l, --call write-only call (a query) to a smart contract + -d, --calldata string for commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send) + -a, --articulate for commands only, articulate the retrieved data if ABIs can be found + -r, --proxy_for string for commands only, redirects calls to this implementation -H, --ether specify value in ether -o, --cache force the results of the query into the cache -D, --decache removes related items from the cache @@ -40,11 +40,13 @@ Notes: - If the queried node does not store historical state, the results are undefined. - Special blocks are detailed under chifra when --list. - Balance is the default mode. To select a single mode use none first, followed by that mode. - - Valid parameters for --call include Solidity-like syntax: balanceOf(0x316b...183d), a four-byte followed by parameters: 0x70a08231(0x316b...183d), or encoded input data. + - Valid parameters for --calldata include Solidity-like syntax: balanceOf(0x316b...), a four-byte followed by parameters: 0x70a08231(0x316b...), or encoded input data. - You may specify multiple parts on a single line. - In the --call string, you may separate multiple calls with a colon. - Your use of the unaudited --send option legally absolves, in any jurisdiction, TrueBlocks, LLC or any associated parties from liability or loss related to such use. - The --send option does not validate its input before sending your transaction to the network. If you provide invalid data, you may lose your funds. Be warned. + - As of version 4.0.0, use --call --calldata to provide your command. + - --calldata may be one or more solidity calls, four-byte plus parameters, or encoded call data strings. ``` Data models produced by this tool: diff --git a/src/apps/chifra/internal/state/options.go b/src/apps/chifra/internal/state/options.go index 2a3bf969ab..2bc888671d 100644 --- a/src/apps/chifra/internal/state/options.go +++ b/src/apps/chifra/internal/state/options.go @@ -35,6 +35,7 @@ type StateOptions struct { Parts []string `json:"parts,omitempty"` // Control which state to export Changes bool `json:"changes,omitempty"` // Only report a balance when it changes from one block to the next NoZero bool `json:"noZero,omitempty"` // Suppress the display of zero balance accounts + Call bool `json:"call,omitempty"` // Write-only call (a query) to a smart contract Send bool `json:"send,omitempty"` // Writes a transaction to an address (see docs for more information) Calldata string `json:"calldata,omitempty"` // For commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send) Articulate bool `json:"articulate,omitempty"` // For commands only, articulate the retrieved data if ABIs can be found @@ -56,6 +57,7 @@ func (opts *StateOptions) testLog() { logger.TestLog(len(opts.Parts) > 0, "Parts: ", opts.Parts) logger.TestLog(opts.Changes, "Changes: ", opts.Changes) logger.TestLog(opts.NoZero, "NoZero: ", opts.NoZero) + logger.TestLog(opts.Call, "Call: ", opts.Call) logger.TestLog(opts.Send, "Send: ", opts.Send) logger.TestLog(len(opts.Calldata) > 0, "Calldata: ", opts.Calldata) logger.TestLog(opts.Articulate, "Articulate: ", opts.Articulate) @@ -104,6 +106,8 @@ func StateFinishParseInternal(w io.Writer, values url.Values) *StateOptions { opts.Changes = true case "noZero": opts.NoZero = true + case "call": + opts.Call = true case "send": opts.Send = true case "calldata": diff --git a/src/apps/chifra/internal/state/output.go b/src/apps/chifra/internal/state/output.go index 10b12e26bb..1dbef5f2ef 100644 --- a/src/apps/chifra/internal/state/output.go +++ b/src/apps/chifra/internal/state/output.go @@ -56,7 +56,7 @@ func (opts *StateOptions) StateInternal(rCtx *output.RenderCtx) error { // EXISTING_CODE if opts.Globals.Decache { err = opts.HandleDecache(rCtx) - } else if len(opts.Calldata) > 0 { + } else if opts.Call { err = opts.HandleCall(rCtx) } else if opts.Send { err = opts.HandleSend(rCtx) diff --git a/src/dev_tools/goMaker/templates/cmd-line-options.csv b/src/dev_tools/goMaker/templates/cmd-line-options.csv index 9791330f7f..80b3ee9a54 100644 --- a/src/dev_tools/goMaker/templates/cmd-line-options.csv +++ b/src/dev_tools/goMaker/templates/cmd-line-options.csv @@ -206,8 +206,9 @@ num,folder,group,route,tool,longName,hotKey,def_val,attributes,handler,option_ty 32040,tools,Chain State,state,getState,parts,p,,visible|docs,,flag,list,,,,,control which state to export 32050,tools,Chain State,state,getState,changes,c,,visible|docs,,switch,,,,,,only report a balance when it changes from one block to the next 32060,tools,Chain State,state,getState,no_zero,z,,visible|docs,,switch,,,,,,suppress the display of zero balance accounts +32070,tools,Chain State,state,getState,call,l,,visible|docs,1,switch,,result,,,,write-only call (a query) to a smart contract 32073,tools,Chain State,state,getState,send,s,,,2,switch,,result,,,,writes a transaction to an address (see docs for more information) -32087,tools,Chain State,state,getState,calldata,d,,visible|docs,1,flag,,result,,,,for commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send) +32087,tools,Chain State,state,getState,calldata,d,,visible|docs,,flag,,,,,,for commands (--call or --send), provides the call data (in various forms) for the command (may be empty for --send) 32080,tools,Chain State,state,getState,articulate,a,,visible|docs,,switch,,,,,,for commands only, articulate the retrieved data if ABIs can be found 32090,tools,Chain State,state,getState,proxy_for,r,,visible|docs,,flag,
,,,,,for commands only, redirects calls to this implementation 32100,tools,Chain State,state,getState,n1,,,,,note,,,,,,An `address` must be either an ENS name or start with '0x' and be forty-two characters long. diff --git a/src/dev_tools/sdkFuzzer/state.go b/src/dev_tools/sdkFuzzer/state.go index a7187e8346..c769b566a6 100644 --- a/src/dev_tools/sdkFuzzer/state.go +++ b/src/dev_tools/sdkFuzzer/state.go @@ -33,6 +33,7 @@ func DoState() { noZero := []bool{false, true} articulate := []bool{false, true} proxyFor := fuzzProxyFors + // calldata is a --other // blocks is not fuzzed // Fuzz Loop // EXISTING_CODE @@ -135,21 +136,21 @@ func TestState(which, value, fn string, opts *sdk.StateOptions) { ReportOkay(fn) } } - case "send": - if send, _, err := opts.StateSend(); err != nil { + case "call": + if call, _, err := opts.StateCall(); err != nil { ReportError(fn, opts, err) } else { - if err := SaveToFile[types.Result](fn, send); err != nil { + if err := SaveToFile[types.Result](fn, call); err != nil { ReportError2(fn, err) } else { ReportOkay(fn) } } - case "calldata": - if calldata, _, err := opts.StateCalldata(value); err != nil { + case "send": + if send, _, err := opts.StateSend(); err != nil { ReportError(fn, opts, err) } else { - if err := SaveToFile[types.Result](fn, calldata); err != nil { + if err := SaveToFile[types.Result](fn, send); err != nil { ReportError2(fn, err) } else { ReportOkay(fn) diff --git a/src/dev_tools/testRunner/testCases/state.csv b/src/dev_tools/testRunner/testCases/state.csv index 9c12cc26d5..c1ae362c57 100644 --- a/src/dev_tools/testRunner/testCases/state.csv +++ b/src/dev_tools/testRunner/testCases/state.csv @@ -53,39 +53,45 @@ on ,both ,fast ,state ,tools ,getState ,fmt_junk ,y on ,both ,fast ,state ,tools ,getState ,get_range ,y ,addrs = 0xbb9bc244d798123fde783fcc1c72d3bb8c189413 & blocks = 1428000-1438000:200 on ,both ,fast ,state ,tools ,getState ,ens_test ,y ,addrs = trueblocks.eth & blocks = 8854700-8854900:20 -on ,both ,fast ,state ,tools ,getState ,contract_call_fail1 ,y ,calldata = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875 & blocks = 6523977-6540000:2000 -on ,both ,fast ,state ,tools ,getState ,contract_call_fail2 ,y ,calldata = '12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 -on ,both ,fast ,state ,tools ,getState ,contract_call_fail4 ,y ,calldata = '0x12065fe01()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 -on ,both ,fast ,state ,tools ,getState ,contract_call ,y ,calldata = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 -on ,api ,fast ,state ,tools ,getState ,contract_call2_api ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,cmd ,fast ,state ,tools ,getState ,contract_call2_cmd ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,api ,fast ,state ,tools ,getState ,contract_call2_api_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,cmd ,fast ,state ,tools ,getState ,contract_call2_cmd_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet"")' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,both ,fast ,state ,tools ,getState ,contract_call3_two ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet""):owner()' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,both ,fast ,state ,tools ,getState ,contract_call3_two_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet""):0x8da5cb5b' & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" -on ,both ,fast ,state ,tools ,getState ,uniswap_factory_getPair ,n ,calldata = 0xe6a439050000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 & addrs = 0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f & blocks = 10092000 & fmt = csv -on ,both ,fast ,state ,tools ,getState ,uniswap_token0 ,y ,calldata = '0x0dfe1681()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,uniswap_token0_name ,n ,calldata = '0x06fdde03()' & addrs = 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 & blocks = 10092000 & fmt = txt -on ,both ,fast ,state ,tools ,getState ,uniswap_token1 ,y ,calldata = '0xd21220a7()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -local ,both ,fast ,state ,tools ,getState ,uniswap_token1_name ,y ,calldata = '0x06fdde03()' & addrs = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,uniswap_name ,y ,calldata = '0x06fdde03()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,uniswap_reserve ,n ,calldata = '0x0902f1ac()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 & fmt = csv -on ,both ,fast ,state ,tools ,getState ,uniswap_fail ,y ,calldata = '0x0902f1ad()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,proxy_fail ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,proxy_call_direct ,y ,calldata = '0x0902f1ac()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 -on ,both ,fast ,state ,tools ,getState ,proxy_for ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & proxy_for = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,contract_call_fail1 ,y ,call & calldata = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,contract_call_fail2 ,y ,call & calldata = '12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,contract_call_fail4 ,y ,call & calldata = '0x12065fe01()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,contract_call ,y ,call & calldata = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,api ,fast ,state ,tools ,getState ,contract_call2_api ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet"")' & call & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,cmd ,fast ,state ,tools ,getState ,contract_call2_cmd ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet"")' & call & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,api ,fast ,state ,tools ,getState ,contract_call2_api_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet"")' & call & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,cmd ,fast ,state ,tools ,getState ,contract_call2_cmd_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet"")' & call & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,both ,fast ,state ,tools ,getState ,contract_call3_two ,y ,"calldata = 'manifestHashMap(0xf503017d7baf7fbc0fff7492b751025c6a78179b,""mainnet""):owner()' & call & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,both ,fast ,state ,tools ,getState ,contract_call3_two_ens ,y ,"calldata = 'manifestHashMap(trueblocks.eth,""mainnet""):0x8da5cb5b' & call & addrs = unchainedindex.eth & blocks = 14976122 & fmt = json" +on ,both ,fast ,state ,tools ,getState ,uniswap_factory_getPair ,n ,call & calldata = 0xe6a439050000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 & addrs = 0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f & blocks = 10092000 & fmt = csv +on ,both ,fast ,state ,tools ,getState ,uniswap_token0 ,y ,call & calldata = '0x0dfe1681()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,uniswap_token0_name ,n ,call & calldata = '0x06fdde03()' & addrs = 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 & blocks = 10092000 & fmt = txt +on ,both ,fast ,state ,tools ,getState ,uniswap_token1 ,y ,call & calldata = '0xd21220a7()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +local ,both ,fast ,state ,tools ,getState ,uniswap_token1_name ,y ,call & calldata = '0x06fdde03()' & addrs = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,uniswap_name ,y ,call & calldata = '0x06fdde03()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,uniswap_reserve ,n ,call & calldata = '0x0902f1ac()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 & fmt = csv +on ,both ,fast ,state ,tools ,getState ,uniswap_fail ,y ,call & calldata = '0x0902f1ad()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,proxy_fail ,y ,call & calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,proxy_call_direct ,y ,call & calldata = '0x0902f1ac()' & addrs = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 +on ,both ,fast ,state ,tools ,getState ,proxy_for ,y ,call & calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & proxy_for = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 & blocks = 10092000 on ,both ,fast ,state ,tools ,getState ,proxy_2 ,y ,parts = all & addrs = 0x7cfb89D6DF1b89A678Dcaf42B9c262593e881E22 & fmt = json & blocks = 14000000 on ,both ,fast ,state ,tools ,getState ,fail_art_not_call ,y ,addrs = 0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359 & parts = accttype & blocks = 2500000 & articulate +on ,both ,fast ,state ,tools ,getState ,eoa_send_fail1 ,y ,send & calldata = '0x12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,eoa_send_fail2 ,y ,send & calldata = '12065fe0()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,eoa_send_fail3 ,y ,send & calldata = '0x12065fe01()' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,eoa_send_fail4 ,y ,send & calldata = '0x12065fe01()' & parts = all +on ,both ,fast ,state ,tools ,getState ,eoa_send_fail5 ,y ,send & calldata = '0x12065fe01()' & changes +on ,both ,fast ,state ,tools ,getState ,eoa_send_fail6 ,y ,send & calldata = '0x12065fe01()' & no_zero # Not sure why this fails... -on ,both ,fast ,state ,tools ,getState ,contract_call_fail3 ,y ,calldata & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 +on ,both ,fast ,state ,tools ,getState ,contract_call_fail3 ,y ,calldata = '0x' & addrs = 0xa4f29fc548856180f6b1e319ee4d86715875cce4 & blocks = 6523977-6540000:2000 # This started failing when we went to sync.Map for the abiMap and at the same time started using IterateOverMap. Possibly ordering changes in the map? -on ,both ,fast ,state ,tools ,getState ,proxy_imp ,n ,calldata = '0xbb82aa5e()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & blocks = 10092000 & fmt = csv +on ,both ,fast ,state ,tools ,getState ,proxy_imp ,n ,call & calldata = '0xbb82aa5e()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & blocks = 10092000 & fmt = csv -on ,both ,fast ,state ,tools ,getState ,not_call_and_parts ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & parts = some -on ,both ,fast ,state ,tools ,getState ,not_call_and_changes ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & changes -on ,both ,fast ,state ,tools ,getState ,not_call_and_nozero ,y ,calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & no_zero +on ,both ,fast ,state ,tools ,getState ,not_call_and_parts ,y ,call & calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & parts = some +on ,both ,fast ,state ,tools ,getState ,not_call_and_changes ,y ,call & calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & changes +on ,both ,fast ,state ,tools ,getState ,not_call_and_nozero ,y ,call & calldata = '0x0902f1ac()' & addrs = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B & no_zero on ,both ,fast ,state ,tools ,getState ,with_no_block ,y ,addrs = 0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359 on ,both ,fast ,state ,tools ,getState ,not_not_call_and_proxy ,y ,addrs = 0xf6f1cd99578ea87b67ae2bf7e9ca3e7e99d0fb98 & proxy_for = 0xbb2b8038a1640196fbe3e38816f3e67cba72d940 diff --git a/tests b/tests index 93d96acc1f..9137f00d22 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 93d96acc1fc5f993f7dff87554eacc82fb032dfc +Subproject commit 9137f00d222de1e5769919a1bf526df67c11daa6 From 10a39805dd6bc014ef55017a0ae87224d96e1b5b Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Sat, 14 Dec 2024 01:10:48 -0500 Subject: [PATCH 5/6] Adds --call back in as switch --- src/apps/chifra/internal/state/handle_call.go | 9 +- .../chifra/internal/state/handle_decache.go | 4 +- src/apps/chifra/internal/state/handle_send.go | 11 ++- src/apps/chifra/internal/state/options.go | 2 +- src/apps/chifra/internal/state/validate.go | 95 +++++++++++++------ src/apps/chifra/pkg/call/call.go | 4 +- src/apps/chifra/pkg/manifest/download.go | 2 +- .../chifra/pkg/monitor/monitor_freshen.go | 6 +- src/apps/chifra/pkg/pricing/maker.go | 2 +- src/apps/chifra/pkg/pricing/uniswap.go | 4 +- tests | 2 +- 11 files changed, 92 insertions(+), 49 deletions(-) diff --git a/src/apps/chifra/internal/state/handle_call.go b/src/apps/chifra/internal/state/handle_call.go index 1f65b7b90c..a2a3c32616 100644 --- a/src/apps/chifra/internal/state/handle_call.go +++ b/src/apps/chifra/internal/state/handle_call.go @@ -28,7 +28,7 @@ func (opts *StateOptions) HandleCall(rCtx *output.RenderCtx) error { return articulate.ArticulateFunction(function, "", str[2:]) } - callAddress := opts.GetCallAddress() + callAddress := opts.GetAddressOrProxy() fetchData := func(modelChan chan types.Modeler, errorChan chan error) { apps, _, err := identifiers.IdsToApps(chain, opts.BlockIds) if err != nil { @@ -65,7 +65,7 @@ func (opts *StateOptions) HandleCall(rCtx *output.RenderCtx) error { for _, c := range opts.Calls { if contractCall, _, err := call.NewContractCall(opts.Conn, callAddress, c); err != nil { delete(thisMap, app) - return fmt.Errorf("the --call value provided (%s) was not found: %s", c, err) + return fmt.Errorf("the --calldata value provided (%s) was not found: %s", c, err) } else { contractCall.BlockNumber = bn @@ -117,9 +117,8 @@ func (opts *StateOptions) HandleCall(rCtx *output.RenderCtx) error { return output.StreamMany(rCtx, fetchData, opts.Globals.OutputOptsWithExtra(extraOpts)) } -func (opts *StateOptions) GetCallAddress() base.Address { - // Note that the validator precludes the possibility of having more than one address - // if the call option is present. +func (opts *StateOptions) GetAddressOrProxy() base.Address { + // Note that validtor makes sure there's exactly one address for --call or --send. callAddress := base.HexToAddress(opts.Addrs[0]) proxy := base.HexToAddress(opts.ProxyFor) if !proxy.IsZero() { diff --git a/src/apps/chifra/internal/state/handle_decache.go b/src/apps/chifra/internal/state/handle_decache.go index 80a6dabfc8..59645224e0 100644 --- a/src/apps/chifra/internal/state/handle_decache.go +++ b/src/apps/chifra/internal/state/handle_decache.go @@ -56,9 +56,9 @@ func (opts *StateOptions) getItemsToRemove() ([]cache.Locator, error) { for _, c := range opts.Calls { if len(c) > 0 { - callAddress := opts.GetCallAddress() + callAddress := opts.GetAddressOrProxy() if contractCall, _, err := call.NewContractCall(opts.Conn, callAddress, c); err != nil { - wrapped := fmt.Errorf("the --call value provided (%s) was not found: %s", c, err) + wrapped := fmt.Errorf("the --calldata value provided (%s) was not found: %s", c, err) return []cache.Locator{}, wrapped } else { diff --git a/src/apps/chifra/internal/state/handle_send.go b/src/apps/chifra/internal/state/handle_send.go index 0c5357556e..ea2974cbe3 100644 --- a/src/apps/chifra/internal/state/handle_send.go +++ b/src/apps/chifra/internal/state/handle_send.go @@ -5,11 +5,16 @@ package statePkg import ( - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) func (opts *StateOptions) HandleSend(rCtx *output.RenderCtx) error { - logger.Info("HandleSend was called.") - return nil + fetchData := func(modelChan chan types.Modeler, errorChan chan error) { + modelChan <- &types.Result{ + Name: "I am not right", + } + } + + return output.StreamMany(rCtx, fetchData, opts.Globals.OutputOpts()) } diff --git a/src/apps/chifra/internal/state/options.go b/src/apps/chifra/internal/state/options.go index 2bc888671d..7ce2bc1fab 100644 --- a/src/apps/chifra/internal/state/options.go +++ b/src/apps/chifra/internal/state/options.go @@ -222,7 +222,7 @@ func (opts *StateOptions) getCaches() (caches map[walk.CacheType]bool) { // EXISTING_CODE caches = map[walk.CacheType]bool{ walk.Cache_State: true, - walk.Cache_Results: len(opts.Calldata) > 0, + walk.Cache_Results: opts.Call || opts.Send, } // EXISTING_CODE return diff --git a/src/apps/chifra/internal/state/validate.go b/src/apps/chifra/internal/state/validate.go index 056f7da35b..50307de9b5 100644 --- a/src/apps/chifra/internal/state/validate.go +++ b/src/apps/chifra/internal/state/validate.go @@ -37,59 +37,72 @@ func (opts *StateOptions) validateState() error { // do nothing for now } else { - if len(opts.Calldata) > 0 { + if opts.Call && opts.Send { + return validate.Usage("The {0} and {1} options are mutually exclusive.", "--call", "--send") + } + + if opts.Call || opts.Send { + if len(opts.Calldata) == 0 { + return validate.Usage("The {0} option requires at least one {1} command.", "--call", "--calldata") + } + if len(opts.Parts) > 0 { - return validate.Usage("The {0} option is not available{1}.", "--parts", " with the --call option") + return validate.Usage("The {0} option is not available{1}.", "--parts", " with the --call or --send option") } if opts.Changes { - return validate.Usage("The {0} option is not available{1}.", "--changes", " with the --call option") + return validate.Usage("The {0} option is not available{1}.", "--changes", " with the --call or --send option") } if opts.NoZero { - return validate.Usage("The {0} option is not available{1}.", "--no_zero", " with the --call option") + return validate.Usage("The {0} option is not available{1}.", "--no_zero", " with the --call or --send option") } if len(opts.Addrs) != 1 { - return validate.Usage("Exactly one address is required for the {0} option.", "--call") + return validate.Usage("Exactly one address is required for the {0} option.", "--call or --send") } - callAddress := opts.GetCallAddress() - err := opts.Conn.IsContractAtLatest(base.HexToAddress(callAddress.Hex())) - if err != nil { - if errors.Is(err, rpc.ErrNotAContract) { - return validate.Usage("The address for the --call option must be a smart contract.") - } - return err + callAddress := opts.GetAddressOrProxy() + isContract := false + if err = opts.Conn.IsContractAtLatest(base.HexToAddress(callAddress.Hex())); err == nil { + isContract = true } - // Before we do anythinng, let's just make sure we have a valid four-byte - for _, c := range opts.Calls { - if _, suggestions, err := call.NewContractCall(opts.Conn, callAddress, c); err != nil { - message := fmt.Sprintf("the --call value provided (%s) was not found: %s", c, err) - if len(suggestions) > 0 { - if len(suggestions) > 0 { - message += " Suggestions: " - for index, suggestion := range suggestions { - if index > 0 { - message += " " - } - message += fmt.Sprintf("%d: %s.", index+1, suggestion) - } - } + if opts.Send { + // Sends with no call data are okay to either smart contracts or regular accounts. + if isContract { + if err := opts.checkCommands(callAddress, opts.Send); err != nil { + return err + } + } + + } else if opts.Call { + if isContract { + if err := opts.checkCommands(callAddress, opts.Send); err != nil { + return err + } + } else { + if errors.Is(err, rpc.ErrNotAContract) { + return validate.Usage("The address for the --call option must be a smart contract.") } - return errors.New(message) + return err } + } else { + // will never happen } } else { + if len(opts.Calldata) > 0 { + return validate.Usage("The {0} option is only available with the {1} option.", "--calldata", "--call or --send") + } + if opts.Articulate { - return validate.Usage("The {0} option is only available with the {1} option.", "--articulate", "--call") + return validate.Usage("The {0} option is only available with the {1} option.", "--articulate", "--call or --send") } proxy := base.HexToAddress(opts.ProxyFor) if !proxy.IsZero() { - return validate.Usage("The {0} option is only available with the {1} option.", "--proxy_for", "--call") + return validate.Usage("The {0} option is only available with the {1} option.", "--proxy_for", "--call or --send") } err := validate.ValidateAtLeastOneAddr(opts.Addrs) @@ -134,3 +147,27 @@ func (opts *StateOptions) validateState() error { return opts.Globals.Validate() } + +func (opts *StateOptions) checkCommands(callAddress base.Address, isSend bool) error { + if len(opts.Calldata) == 0 && !isSend { + return validate.Usage("The {0} option requires at least one command.", "--call") + } + + // an empty list of commands is okay... + for _, cmd := range opts.Calls { + if _, suggestions, err := call.NewContractCall(opts.Conn, callAddress, cmd); err != nil { + message := fmt.Sprintf("the --calldata value provided (%s) was not found: %s", cmd, err) + if len(suggestions) > 0 { + message += " Suggestions: " + for index, suggestion := range suggestions { + if index > 0 { + message += " " + } + message += fmt.Sprintf("%d: %s.", index+1, suggestion) + } + } + return errors.New(message) + } + } + return nil +} diff --git a/src/apps/chifra/pkg/call/call.go b/src/apps/chifra/pkg/call/call.go index 4ecda3f30d..b52d19121d 100644 --- a/src/apps/chifra/pkg/call/call.go +++ b/src/apps/chifra/pkg/call/call.go @@ -28,7 +28,7 @@ type ContractCall struct { func NewContractCallWithAbi(conn *rpc.Connection, callAddress base.Address, theCall string, abiMap *abi.SelectorSyncMap) (*ContractCall, []string, error) { parsed, err := parser.ParseCall(theCall) if err != nil { - err = fmt.Errorf("the value provided --call (%s) is invalid", theCall) + err = fmt.Errorf("the value provided (%s) is invalid", theCall) return nil, []string{}, err } @@ -100,7 +100,7 @@ func NewContractCall(conn *rpc.Connection, callAddress base.Address, theCall str parsed, err := parser.ParseCall(theCall) if err != nil { - err = fmt.Errorf("the value provided --call (%s) is invalid", theCall) + err = fmt.Errorf("the value provided (%s) is invalid", theCall) return nil, []string{}, err } diff --git a/src/apps/chifra/pkg/manifest/download.go b/src/apps/chifra/pkg/manifest/download.go index b3f4e24b6c..58e7ebaa2c 100644 --- a/src/apps/chifra/pkg/manifest/download.go +++ b/src/apps/chifra/pkg/manifest/download.go @@ -46,7 +46,7 @@ func ReadUnchainedIndex(chain string, publisher base.Address, database string) ( theCall := fmt.Sprintf("manifestHashMap(%s, \"%s\")", publisher, database) if contractCall, _, err := call.NewContractCallWithAbi(conn, callAddress, theCall, abiMap); err != nil { - wrapped := fmt.Errorf("the --call value provided (%s) was not found: %s", theCall, err) + wrapped := fmt.Errorf("the --calldata value provided (%s) was not found: %s", theCall, err) return "", wrapped } else { contractCall.BlockNumber = conn.GetLatestBlockNumber() diff --git a/src/apps/chifra/pkg/monitor/monitor_freshen.go b/src/apps/chifra/pkg/monitor/monitor_freshen.go index f25099d60a..b393db15eb 100644 --- a/src/apps/chifra/pkg/monitor/monitor_freshen.go +++ b/src/apps/chifra/pkg/monitor/monitor_freshen.go @@ -386,9 +386,11 @@ func getAppearances(addrStr string, lines []string, lastVisited uint32, found in if !strings.HasPrefix(lines[idx], addrStr) { break } + strippedBn := strings.TrimLeft(lines[idx][startOfBlockNum:endOfBlockNum], "0") + strippedTxId := strings.TrimLeft(lines[idx][startOfTxId:endOfTxId], "0") r := types.AppRecord{ - BlockNumber: uint32(base.MustParseUint64(lines[idx][startOfBlockNum:endOfBlockNum])), - TransactionIndex: uint32(base.MustParseUint64(lines[idx][startOfTxId:endOfTxId])), + BlockNumber: uint32(base.MustParseUint64(strippedBn)), + TransactionIndex: uint32(base.MustParseUint64(strippedTxId)), } if r.BlockNumber > lastVisited { results = append(results, r) diff --git a/src/apps/chifra/pkg/pricing/maker.go b/src/apps/chifra/pkg/pricing/maker.go index 3ec7f1b7d5..c15a2d680b 100644 --- a/src/apps/chifra/pkg/pricing/maker.go +++ b/src/apps/chifra/pkg/pricing/maker.go @@ -30,7 +30,7 @@ func priceUsdMaker(conn *rpc.Connection, statement *types.Statement) (price base contractCall, _, err := call.NewContractCall(conn, makerMedianizer, theCall) if err != nil { - wrapped := fmt.Errorf("the --call value provided (%s) was not found: %s", theCall, err) + wrapped := fmt.Errorf("the --calldata value provided (%s) was not found: %s", theCall, err) return 0.0, "not-priced", wrapped } diff --git a/src/apps/chifra/pkg/pricing/uniswap.go b/src/apps/chifra/pkg/pricing/uniswap.go index f05a562d2b..b6c9b32ee9 100644 --- a/src/apps/chifra/pkg/pricing/uniswap.go +++ b/src/apps/chifra/pkg/pricing/uniswap.go @@ -50,7 +50,7 @@ func priceUsdUniswap(conn *rpc.Connection, statement *types.Statement) (price ba theCall1 := fmt.Sprintf("getPair(%s, %s)", first.Hex(), second.Hex()) contractCall, _, err := call.NewContractCall(conn, uniswapFactoryV2, theCall1) if err != nil { - wrapped := fmt.Errorf("the --call value provided (%s) was not found: %s", theCall1, err) + wrapped := fmt.Errorf("the --calldata value provided (%s) was not found: %s", theCall1, err) return 0.0, "not-priced", wrapped } contractCall.BlockNumber = statement.BlockNumber @@ -70,7 +70,7 @@ func priceUsdUniswap(conn *rpc.Connection, statement *types.Statement) (price ba theCall2 := "getReserves()" contractCall, _, err = call.NewContractCall(conn, pairAddress, theCall2) if err != nil { - wrapped := fmt.Errorf("the --call value provided (%s) was not found: %s", theCall2, err) + wrapped := fmt.Errorf("the --calldata value provided (%s) was not found: %s", theCall2, err) return 0.0, "not-priced", wrapped } contractCall.BlockNumber = statement.BlockNumber diff --git a/tests b/tests index 9137f00d22..30d9d0188a 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 9137f00d222de1e5769919a1bf526df67c11daa6 +Subproject commit 30d9d0188a6c669954117c1c29b63323f6128e5c From 96f333a7e26d26d5291fcae525b79c003168d121 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Sat, 14 Dec 2024 01:12:50 -0500 Subject: [PATCH 6/6] --call to --calldata --- src/apps/chifra/internal/state/validate.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/apps/chifra/internal/state/validate.go b/src/apps/chifra/internal/state/validate.go index 50307de9b5..273609eb0f 100644 --- a/src/apps/chifra/internal/state/validate.go +++ b/src/apps/chifra/internal/state/validate.go @@ -87,8 +87,6 @@ func (opts *StateOptions) validateState() error { } return err } - } else { - // will never happen } } else {