@@ -2,6 +2,7 @@ package abi
22
33import (
44 abi_pb "github.com/unpackdev/protos/dist/go/abi"
5+ ast_pb "github.com/unpackdev/protos/dist/go/ast"
56 "github.com/unpackdev/solgo/ast"
67 "github.com/unpackdev/solgo/ir"
78)
@@ -44,7 +45,7 @@ func (c *Contract) ToProto() *abi_pb.Contract {
4445
4546// processContract processes an IR contract and returns a Contract representation of it.
4647// It extracts state variables, events, errors, constructor, functions, fallback, and receive methods.
47- func (b * Builder ) processContract (contract * ir.Contract ) * Contract {
48+ func (b * Builder ) processContract (contract * ir.Contract ) ( * Contract , error ) {
4849 toReturn := Contract {}
4950
5051 // Process state variables.
@@ -55,28 +56,44 @@ func (b *Builder) processContract(contract *ir.Contract) *Contract {
5556
5657 // Process events.
5758 for _ , event := range contract .GetEvents () {
58- method := b .processEvent (event )
59+ method , err := b .processEvent (event )
60+ if err != nil {
61+ return nil , err
62+ }
63+
5964 toReturn = append (toReturn , method )
6065 }
6166
6267 // Process errors.
6368 for _ , errorNode := range contract .GetErrors () {
64- method := b .processError (errorNode )
69+ method , err := b .processError (errorNode )
70+ if err != nil {
71+ return nil , err
72+ }
73+
6574 toReturn = append (toReturn , method )
6675 }
6776
6877 // Process constructor.
6978 if contract .GetConstructor () != nil {
70- toReturn = append (
71- toReturn ,
72- b .processConstructor (contract .GetConstructor ()),
73- )
79+ method , err := b .processConstructor (contract .GetConstructor ())
80+ if err != nil {
81+ return nil , err
82+ }
83+
84+ toReturn = append (toReturn , method )
7485 }
7586
7687 // Process functions.
7788 for _ , function := range contract .GetFunctions () {
78- method := b .processFunction (function )
79- toReturn = append (toReturn , method )
89+ if function .GetVisibility () == ast_pb .Visibility_PUBLIC && function .GetVisibility () == ast_pb .Visibility_EXTERNAL {
90+ method , err := b .processFunction (function )
91+ if err != nil {
92+ return nil , err
93+ }
94+
95+ toReturn = append (toReturn , method )
96+ }
8097 }
8198
8299 // Process fallback.
@@ -89,13 +106,15 @@ func (b *Builder) processContract(contract *ir.Contract) *Contract {
89106
90107 // Process receive.
91108 if contract .GetReceive () != nil {
92- toReturn = append (
93- toReturn ,
94- b .processReceive (contract .GetReceive ()),
95- )
109+ method , err := b .processReceive (contract .GetReceive ())
110+ if err != nil {
111+ return nil , err
112+ }
113+
114+ toReturn = append (toReturn , method )
96115 }
97116
98- return & toReturn
117+ return & toReturn , nil
99118}
100119
101120// buildMethodIO constructs a MethodIO object based on the provided method and type description.
0 commit comments