@@ -60,7 +60,9 @@ type Options struct {
6060 // variadic args usages. If some type is specified via config file, then the config's
6161 // one is preferable. Currently, event's parameter type is defined from the first
6262 // occurrence of event call.
63- GuessEventTypes bool
63+ GuessEventTypes bool
64+ GuessedNamedTypes map [string ]manifest.ExtendedType
65+ CollectedNamedTypes map [string ]manifest.ExtendedType
6466
6567 // Name is a contract's name to be written to manifest.
6668 Name string
@@ -69,11 +71,7 @@ type Options struct {
6971 SourceURL string
7072
7173 // Runtime notifications declared in the contract configuration file.
72- ContractEvents []HybridEvent
73-
74- // DeclaredNamedTypes is the set of named types that were declared in the
75- // contract configuration type and are the part of manifest events.
76- DeclaredNamedTypes map [string ]binding.ExtendedType
74+ ContractEvents []manifest.Event
7775
7876 // The list of standards supported by the contract.
7977 ContractSupportedStandards []string
@@ -92,23 +90,6 @@ type Options struct {
9290 BindingsFile string
9391}
9492
95- // HybridEvent represents the description of event emitted by the contract squashed
96- // with extended event's parameters description. We have it as a separate type for
97- // the user's convenience. It is applied for the smart contract configuration file
98- // only.
99- type HybridEvent struct {
100- Name string `json:"name"`
101- Parameters []HybridParameter `json:"parameters"`
102- }
103-
104- // HybridParameter contains the manifest's event parameter description united with
105- // the extended type description for this parameter. It is applied for the smart
106- // contract configuration file only.
107- type HybridParameter struct {
108- manifest.Parameter `yaml:",inline"`
109- ExtendedType * binding.ExtendedType `yaml:"extendedtype,omitempty"`
110- }
111-
11293type buildInfo struct {
11394 config * packages.Config
11495 program []* packages.Package
@@ -337,15 +318,6 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
337318 cfg .Types [m .Name .Name ] = * m .ReturnTypeExtended
338319 }
339320 }
340- if len (di .NamedTypes ) > 0 {
341- cfg .NamedTypes = di .NamedTypes
342- }
343- for name , et := range o .DeclaredNamedTypes {
344- if _ , ok := cfg .NamedTypes [name ]; ok {
345- return nil , fmt .Errorf ("configured declared named type intersects with the contract's one: `%s`" , name )
346- }
347- cfg .NamedTypes [name ] = et
348- }
349321 for _ , e := range o .ContractEvents {
350322 eStructName := rpcbinding .ToEventBindingName (e .Name )
351323 for _ , p := range e .Parameters {
@@ -357,6 +329,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
357329 }
358330 }
359331 if o .GuessEventTypes {
332+ o .GuessedNamedTypes = make (map [string ]manifest.ExtendedType )
360333 if len (di .EmittedEvents ) > 0 {
361334 var keys = make ([]string , 0 , len (di .EmittedEvents ))
362335 for k := range di .EmittedEvents {
@@ -366,7 +339,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
366339 for _ , eventName := range keys {
367340 var (
368341 eventUsages = di .EmittedEvents [eventName ]
369- manifestEvent HybridEvent
342+ manifestEvent manifest. Event
370343 )
371344 for _ , e := range o .ContractEvents {
372345 if e .Name == eventName {
@@ -408,12 +381,12 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
408381 if p .ExtendedType != nil {
409382 typeName := p .ExtendedType .Name
410383 if extType , ok := exampleUsage .ExtTypes [typeName ]; ok {
411- for _ , ok := cfg . NamedTypes [typeName ]; ok ; _ , ok = cfg . NamedTypes [typeName ] {
384+ for _ , ok := o . GuessedNamedTypes [typeName ]; ok ; _ , ok = o . GuessedNamedTypes [typeName ] {
412385 typeName = typeName + "X"
413386 }
414387 extType .Name = typeName
415388 p .ExtendedType .Name = typeName
416- cfg . NamedTypes [typeName ] = extType
389+ o . GuessedNamedTypes [typeName ] = extType
417390 }
418391 if _ , ok := cfg .Types [pname ]; ! ok {
419392 cfg .Types [pname ] = * p .ExtendedType
0 commit comments