@@ -3,21 +3,39 @@ package abisPkg
3
3
import (
4
4
"errors"
5
5
"fmt"
6
+ "path/filepath"
7
+ "strings"
6
8
9
+ "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base"
7
10
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output"
8
11
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc"
9
12
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
10
13
)
11
14
12
15
func (opts * AbisOptions ) HandleListFuncs (rCtx * output.RenderCtx ) (err error ) {
13
- return opts .HandleListItems (rCtx , "function" )
16
+ return opts .HandleListItems (rCtx )
14
17
}
15
18
16
19
func (opts * AbisOptions ) HandleListEvents (rCtx * output.RenderCtx ) (err error ) {
17
- return opts .HandleListItems (rCtx , "event" )
20
+ return opts .HandleListItems (rCtx )
18
21
}
19
22
20
- func (opts * AbisOptions ) HandleListItems (rCtx * output.RenderCtx , filter string ) (err error ) {
23
+ func (opts * AbisOptions ) HandleListItems (rCtx * output.RenderCtx ) (err error ) {
24
+ if len (opts .Addrs ) == 0 {
25
+ vFunc := func (fn string , vP any ) (bool , error ) {
26
+ _ = vP
27
+ _ , name := filepath .Split (fn )
28
+ if strings .HasSuffix (name , ".json" ) {
29
+ if base .IsValidAddress (strings .TrimSuffix (name , ".json" )) {
30
+ // silent ignore
31
+ opts .Addrs = append (opts .Addrs , strings .TrimSuffix (name , ".json" ))
32
+ }
33
+ }
34
+ return true , nil
35
+ }
36
+ opts .ForEveryAbi (true , vFunc , nil )
37
+ }
38
+
21
39
fetchData := func (modelChan chan types.Modeler , errorChan chan error ) {
22
40
for _ , addr := range opts .Addrs {
23
41
functions , which , err := opts .LoadAbis ([]string {addr }, false /* known */ )
@@ -36,7 +54,7 @@ func (opts *AbisOptions) HandleListItems(rCtx *output.RenderCtx, filter string)
36
54
}
37
55
38
56
for _ , f := range functions {
39
- if filter == "" || filter == f .FunctionType {
57
+ if opts . ListFilter == "" || opts . ListFilter == f .FunctionType {
40
58
modelChan <- f
41
59
}
42
60
}
0 commit comments