From 4f2d6e5e8bbaf8a808246625e724f18bdee9ec59 Mon Sep 17 00:00:00 2001
From: Garet Halliday <ghalliday@gfxlabs.io>
Date: Wed, 21 Sep 2022 13:11:52 -0500
Subject: [PATCH] fix types.gotmpl

---
 openrpc/out/types.go           | 26 ++++++++++++++++++++++++++
 openrpc/templates/types.gotmpl | 32 ++++++++++++++------------------
 2 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/openrpc/out/types.go b/openrpc/out/types.go
index f73420d..5beaa29 100644
--- a/openrpc/out/types.go
+++ b/openrpc/out/types.go
@@ -321,6 +321,12 @@ type SyncingStatus struct {
 	Option1 bool
 }
 type Transaction1559Signed struct {
+	Field0 Transaction1559Unsigned
+	Field1 struct {
+		R       Uint `json:"r"`
+		S       Uint `json:"s"`
+		YParity Uint `json:"yParity"`
+	}
 }
 type Transaction1559Unsigned struct {
 	AccessList           AccessList `json:"accessList"`
@@ -335,6 +341,12 @@ type Transaction1559Unsigned struct {
 	Value                Uint       `json:"value"`
 }
 type Transaction2930Signed struct {
+	Field0 Transaction2930Unsigned
+	Field1 struct {
+		R       Uint `json:"r"`
+		S       Uint `json:"s"`
+		YParity Uint `json:"yParity"`
+	}
 }
 type Transaction2930Unsigned struct {
 	AccessList AccessList `json:"accessList"`
@@ -348,8 +360,22 @@ type Transaction2930Unsigned struct {
 	Value      Uint       `json:"value"`
 }
 type TransactionInfo struct {
+	Field0 struct {
+		BlockHash        Hash32  `json:"blockHash"`
+		BlockNumber      Uint    `json:"blockNumber"`
+		From             Address `json:"from"`
+		Hash             Hash32  `json:"hash"`
+		TransactionIndex Uint    `json:"transactionIndex"`
+	}
+	Field1 TransactionSigned
 }
 type TransactionLegacySigned struct {
+	Field0 TransactionLegacyUnsigned
+	Field1 struct {
+		R Uint `json:"r"`
+		S Uint `json:"s"`
+		V Uint `json:"v"`
+	}
 }
 type TransactionLegacyUnsigned struct {
 	ChainId  Uint    `json:"chainId"`
diff --git a/openrpc/templates/types.gotmpl b/openrpc/templates/types.gotmpl
index 26deb3a..949bfaa 100644
--- a/openrpc/templates/types.gotmpl
+++ b/openrpc/templates/types.gotmpl
@@ -5,32 +5,28 @@ package main
 {{define "schemaType" -}}
     {{if not (eq .Ref "") -}}
         {{camelCase (refName .Ref)}}
-    {{- else if eq .Type "object" -}}
+    {{- else if or
+        (not (eq (len .Properties) 0))
+        (not (eq (len .OneOf) 0))
+        (not (eq (len .AnyOf) 0))
+        (not (eq (len .AllOf) 0))
+    -}}
         struct {
             {{range $name, $property := .Properties -}}
                 {{camelCase $name}} {{template "schemaType" $property}} `json:"{{$name}}"`
             {{end -}}
-        }
-    {{- else if eq .Type "array" -}}
-        []{{template "schemaType" (index .Items 0)}}
-    {{- else if not (eq (len .OneOf) 0) -}}
-        struct{
-            {{range $idx, $v := .OneOf -}}
-                Option{{$idx}} {{template "schemaType" $v}}
+            {{range $idx, $property := .OneOf -}}
+                Option{{$idx}} {{template "schemaType" $property}}
             {{end -}}
-        }
-    {{- else if not (eq (len .AnyOf) 0) -}}
-        struct{
-            {{range $idx, $v := .AnyOf -}}
-                Option{{$idx}} {{template "schemaType" $v}}
+            {{range $idx, $property := .AnyOf -}}
+                Option{{$idx}} {{template "schemaType" $property}}
             {{end -}}
-        }
-    {{- else if not (eq (len .AllOf) 0) -}}
-        struct{
-            {{range $idx, $v := .AllOf -}}
-                Field{{$idx}} {{template "schemaType" $v}}
+            {{range $idx, $property := .AllOf -}}
+                Field{{$idx}} {{template "schemaType" $property}}
             {{end -}}
         }
+    {{- else if eq .Type "array" -}}
+        []{{template "schemaType" (index .Items 0)}}
     {{- else if not (eq (len .Enum) 0) -}}
         string
     {{- else -}}
-- 
GitLab