From 228139ebe0bc4b5f8f16a17a972181858420462e Mon Sep 17 00:00:00 2001
From: a <a@a.a>
Date: Thu, 22 Sep 2022 23:32:18 -0500
Subject: [PATCH] beter

---
 openrpc/out/generated_api.go   | 96 +++++++++++++++++-----------------
 openrpc/templates/types.gotmpl | 12 +++--
 2 files changed, 57 insertions(+), 51 deletions(-)

diff --git a/openrpc/out/generated_api.go b/openrpc/out/generated_api.go
index 3154e4d..ebe1098 100755
--- a/openrpc/out/generated_api.go
+++ b/openrpc/out/generated_api.go
@@ -1,4 +1,4 @@
-// Code generated by go-openrpc. DO NOT EDIT.
+// Code generated by jrpc. DO NOT EDIT.
 
 package out
 
@@ -240,7 +240,7 @@ func (h *RpcHandler) DebugGetRawHeader(ctx context.Context,
 ) (HeaderRLP Bytes, err error) {
 	handler := h.FnDebugGetRawHeader
 	if handler == nil {
-		err = errors.New("Method debug_getRawHeader not implemented")
+		err = errors.New("method debug_getRawHeader not implemented")
 		return
 	}
 	return handler(ctx,
@@ -254,7 +254,7 @@ func (h *RpcHandler) DebugGetRawBlock(ctx context.Context,
 ) (BlockRLP Bytes, err error) {
 	handler := h.FnDebugGetRawBlock
 	if handler == nil {
-		err = errors.New("Method debug_getRawBlock not implemented")
+		err = errors.New("method debug_getRawBlock not implemented")
 		return
 	}
 	return handler(ctx,
@@ -268,7 +268,7 @@ func (h *RpcHandler) DebugGetRawTransaction(ctx context.Context,
 ) (EIP2718BinaryEncodedTransaction Bytes, err error) {
 	handler := h.FnDebugGetRawTransaction
 	if handler == nil {
-		err = errors.New("Method debug_getRawTransaction not implemented")
+		err = errors.New("method debug_getRawTransaction not implemented")
 		return
 	}
 	return handler(ctx,
@@ -282,7 +282,7 @@ func (h *RpcHandler) DebugGetRawReceipts(ctx context.Context,
 ) (Receipts []Bytes, err error) {
 	handler := h.FnDebugGetRawReceipts
 	if handler == nil {
-		err = errors.New("Method debug_getRawReceipts not implemented")
+		err = errors.New("method debug_getRawReceipts not implemented")
 		return
 	}
 	return handler(ctx,
@@ -295,7 +295,7 @@ func (h *RpcHandler) DebugGetBadBlocks(ctx context.Context,
 ) (Blocks []BadBlock, err error) {
 	handler := h.FnDebugGetBadBlocks
 	if handler == nil {
-		err = errors.New("Method debug_getBadBlocks not implemented")
+		err = errors.New("method debug_getBadBlocks not implemented")
 		return
 	}
 	return handler(ctx)
@@ -308,7 +308,7 @@ func (h *RpcHandler) EthGetBlockByHash(ctx context.Context,
 ) (BlockInformation Block, err error) {
 	handler := h.FnEthGetBlockByHash
 	if handler == nil {
-		err = errors.New("Method eth_getBlockByHash not implemented")
+		err = errors.New("method eth_getBlockByHash not implemented")
 		return
 	}
 	return handler(ctx,
@@ -324,7 +324,7 @@ func (h *RpcHandler) EthGetBlockByNumber(ctx context.Context,
 ) (BlockInformation Block, err error) {
 	handler := h.FnEthGetBlockByNumber
 	if handler == nil {
-		err = errors.New("Method eth_getBlockByNumber not implemented")
+		err = errors.New("method eth_getBlockByNumber not implemented")
 		return
 	}
 	return handler(ctx,
@@ -339,7 +339,7 @@ func (h *RpcHandler) EthGetBlockTransactionCountByHash(ctx context.Context,
 ) (TransactionCount Uint, err error) {
 	handler := h.FnEthGetBlockTransactionCountByHash
 	if handler == nil {
-		err = errors.New("Method eth_getBlockTransactionCountByHash not implemented")
+		err = errors.New("method eth_getBlockTransactionCountByHash not implemented")
 		return
 	}
 	return handler(ctx,
@@ -353,7 +353,7 @@ func (h *RpcHandler) EthGetBlockTransactionCountByNumber(ctx context.Context,
 ) (TransactionCount Uint, err error) {
 	handler := h.FnEthGetBlockTransactionCountByNumber
 	if handler == nil {
-		err = errors.New("Method eth_getBlockTransactionCountByNumber not implemented")
+		err = errors.New("method eth_getBlockTransactionCountByNumber not implemented")
 		return
 	}
 	return handler(ctx,
@@ -367,7 +367,7 @@ func (h *RpcHandler) EthGetUncleCountByBlockHash(ctx context.Context,
 ) (UncleCount Uint, err error) {
 	handler := h.FnEthGetUncleCountByBlockHash
 	if handler == nil {
-		err = errors.New("Method eth_getUncleCountByBlockHash not implemented")
+		err = errors.New("method eth_getUncleCountByBlockHash not implemented")
 		return
 	}
 	return handler(ctx,
@@ -381,7 +381,7 @@ func (h *RpcHandler) EthGetUncleCountByBlockNumber(ctx context.Context,
 ) (UncleCount Uint, err error) {
 	handler := h.FnEthGetUncleCountByBlockNumber
 	if handler == nil {
-		err = errors.New("Method eth_getUncleCountByBlockNumber not implemented")
+		err = errors.New("method eth_getUncleCountByBlockNumber not implemented")
 		return
 	}
 	return handler(ctx,
@@ -394,7 +394,7 @@ func (h *RpcHandler) EthChainId(ctx context.Context,
 ) (ChainID Uint, err error) {
 	handler := h.FnEthChainId
 	if handler == nil {
-		err = errors.New("Method eth_chainId not implemented")
+		err = errors.New("method eth_chainId not implemented")
 		return
 	}
 	return handler(ctx)
@@ -405,7 +405,7 @@ func (h *RpcHandler) EthSyncing(ctx context.Context,
 ) (SyncingStatus SyncingStatus, err error) {
 	handler := h.FnEthSyncing
 	if handler == nil {
-		err = errors.New("Method eth_syncing not implemented")
+		err = errors.New("method eth_syncing not implemented")
 		return
 	}
 	return handler(ctx)
@@ -416,7 +416,7 @@ func (h *RpcHandler) EthCoinbase(ctx context.Context,
 ) (CoinbaseAddress Address, err error) {
 	handler := h.FnEthCoinbase
 	if handler == nil {
-		err = errors.New("Method eth_coinbase not implemented")
+		err = errors.New("method eth_coinbase not implemented")
 		return
 	}
 	return handler(ctx)
@@ -427,7 +427,7 @@ func (h *RpcHandler) EthAccounts(ctx context.Context,
 ) (Accounts []Address, err error) {
 	handler := h.FnEthAccounts
 	if handler == nil {
-		err = errors.New("Method eth_accounts not implemented")
+		err = errors.New("method eth_accounts not implemented")
 		return
 	}
 	return handler(ctx)
@@ -438,7 +438,7 @@ func (h *RpcHandler) EthBlockNumber(ctx context.Context,
 ) (BlockNumber Uint, err error) {
 	handler := h.FnEthBlockNumber
 	if handler == nil {
-		err = errors.New("Method eth_blockNumber not implemented")
+		err = errors.New("method eth_blockNumber not implemented")
 		return
 	}
 	return handler(ctx)
@@ -451,7 +451,7 @@ func (h *RpcHandler) EthCall(ctx context.Context,
 ) (ReturnData Bytes, err error) {
 	handler := h.FnEthCall
 	if handler == nil {
-		err = errors.New("Method eth_call not implemented")
+		err = errors.New("method eth_call not implemented")
 		return
 	}
 	return handler(ctx,
@@ -467,7 +467,7 @@ func (h *RpcHandler) EthEstimateGas(ctx context.Context,
 ) (GasUsed Uint, err error) {
 	handler := h.FnEthEstimateGas
 	if handler == nil {
-		err = errors.New("Method eth_estimateGas not implemented")
+		err = errors.New("method eth_estimateGas not implemented")
 		return
 	}
 	return handler(ctx,
@@ -487,7 +487,7 @@ func (h *RpcHandler) EthCreateAccessList(ctx context.Context,
 }, err error) {
 	handler := h.FnEthCreateAccessList
 	if handler == nil {
-		err = errors.New("Method eth_createAccessList not implemented")
+		err = errors.New("method eth_createAccessList not implemented")
 		return
 	}
 	return handler(ctx,
@@ -501,7 +501,7 @@ func (h *RpcHandler) EthGasPrice(ctx context.Context,
 ) (GasPrice Uint, err error) {
 	handler := h.FnEthGasPrice
 	if handler == nil {
-		err = errors.New("Method eth_gasPrice not implemented")
+		err = errors.New("method eth_gasPrice not implemented")
 		return
 	}
 	return handler(ctx)
@@ -512,7 +512,7 @@ func (h *RpcHandler) EthMaxPriorityFeePerGas(ctx context.Context,
 ) (MaxPriorityFeePerGas Uint, err error) {
 	handler := h.FnEthMaxPriorityFeePerGas
 	if handler == nil {
-		err = errors.New("Method eth_maxPriorityFeePerGas not implemented")
+		err = errors.New("method eth_maxPriorityFeePerGas not implemented")
 		return
 	}
 	return handler(ctx)
@@ -530,7 +530,7 @@ func (h *RpcHandler) EthFeeHistory(ctx context.Context,
 }, err error) {
 	handler := h.FnEthFeeHistory
 	if handler == nil {
-		err = errors.New("Method eth_feeHistory not implemented")
+		err = errors.New("method eth_feeHistory not implemented")
 		return
 	}
 	return handler(ctx,
@@ -546,7 +546,7 @@ func (h *RpcHandler) EthNewFilter(ctx context.Context,
 ) (FilterIdentifier Uint, err error) {
 	handler := h.FnEthNewFilter
 	if handler == nil {
-		err = errors.New("Method eth_newFilter not implemented")
+		err = errors.New("method eth_newFilter not implemented")
 		return
 	}
 	return handler(ctx,
@@ -559,7 +559,7 @@ func (h *RpcHandler) EthNewBlockFilter(ctx context.Context,
 ) (FilterIdentifier Uint, err error) {
 	handler := h.FnEthNewBlockFilter
 	if handler == nil {
-		err = errors.New("Method eth_newBlockFilter not implemented")
+		err = errors.New("method eth_newBlockFilter not implemented")
 		return
 	}
 	return handler(ctx)
@@ -570,7 +570,7 @@ func (h *RpcHandler) EthNewPendingTransactionFilter(ctx context.Context,
 ) (FilterIdentifier Uint, err error) {
 	handler := h.FnEthNewPendingTransactionFilter
 	if handler == nil {
-		err = errors.New("Method eth_newPendingTransactionFilter not implemented")
+		err = errors.New("method eth_newPendingTransactionFilter not implemented")
 		return
 	}
 	return handler(ctx)
@@ -582,7 +582,7 @@ func (h *RpcHandler) EthUninstallFilter(ctx context.Context,
 ) (Success bool, err error) {
 	handler := h.FnEthUninstallFilter
 	if handler == nil {
-		err = errors.New("Method eth_uninstallFilter not implemented")
+		err = errors.New("method eth_uninstallFilter not implemented")
 		return
 	}
 	return handler(ctx,
@@ -596,7 +596,7 @@ func (h *RpcHandler) EthGetFilterChanges(ctx context.Context,
 ) (LogObjects FilterResults, err error) {
 	handler := h.FnEthGetFilterChanges
 	if handler == nil {
-		err = errors.New("Method eth_getFilterChanges not implemented")
+		err = errors.New("method eth_getFilterChanges not implemented")
 		return
 	}
 	return handler(ctx,
@@ -610,7 +610,7 @@ func (h *RpcHandler) EthGetFilterLogs(ctx context.Context,
 ) (LogObjects FilterResults, err error) {
 	handler := h.FnEthGetFilterLogs
 	if handler == nil {
-		err = errors.New("Method eth_getFilterLogs not implemented")
+		err = errors.New("method eth_getFilterLogs not implemented")
 		return
 	}
 	return handler(ctx,
@@ -624,7 +624,7 @@ func (h *RpcHandler) EthGetLogs(ctx context.Context,
 ) (LogObjects FilterResults, err error) {
 	handler := h.FnEthGetLogs
 	if handler == nil {
-		err = errors.New("Method eth_getLogs not implemented")
+		err = errors.New("method eth_getLogs not implemented")
 		return
 	}
 	return handler(ctx,
@@ -637,7 +637,7 @@ func (h *RpcHandler) EthMining(ctx context.Context,
 ) (MiningStatus bool, err error) {
 	handler := h.FnEthMining
 	if handler == nil {
-		err = errors.New("Method eth_mining not implemented")
+		err = errors.New("method eth_mining not implemented")
 		return
 	}
 	return handler(ctx)
@@ -648,7 +648,7 @@ func (h *RpcHandler) EthHashrate(ctx context.Context,
 ) (MiningStatus Uint, err error) {
 	handler := h.FnEthHashrate
 	if handler == nil {
-		err = errors.New("Method eth_hashrate not implemented")
+		err = errors.New("method eth_hashrate not implemented")
 		return
 	}
 	return handler(ctx)
@@ -659,7 +659,7 @@ func (h *RpcHandler) EthGetWork(ctx context.Context,
 ) (CurrentWork []Bytes32, err error) {
 	handler := h.FnEthGetWork
 	if handler == nil {
-		err = errors.New("Method eth_getWork not implemented")
+		err = errors.New("method eth_getWork not implemented")
 		return
 	}
 	return handler(ctx)
@@ -673,7 +673,7 @@ func (h *RpcHandler) EthSubmitWork(ctx context.Context,
 ) (Success bool, err error) {
 	handler := h.FnEthSubmitWork
 	if handler == nil {
-		err = errors.New("Method eth_submitWork not implemented")
+		err = errors.New("method eth_submitWork not implemented")
 		return
 	}
 	return handler(ctx,
@@ -690,7 +690,7 @@ func (h *RpcHandler) EthSubmitHashrate(ctx context.Context,
 ) (Success bool, err error) {
 	handler := h.FnEthSubmitHashrate
 	if handler == nil {
-		err = errors.New("Method eth_submitHashrate not implemented")
+		err = errors.New("method eth_submitHashrate not implemented")
 		return
 	}
 	return handler(ctx,
@@ -706,7 +706,7 @@ func (h *RpcHandler) EthSign(ctx context.Context,
 ) (Signature Bytes65, err error) {
 	handler := h.FnEthSign
 	if handler == nil {
-		err = errors.New("Method eth_sign not implemented")
+		err = errors.New("method eth_sign not implemented")
 		return
 	}
 	return handler(ctx,
@@ -721,7 +721,7 @@ func (h *RpcHandler) EthSignTransaction(ctx context.Context,
 ) (EncodedTransaction Bytes, err error) {
 	handler := h.FnEthSignTransaction
 	if handler == nil {
-		err = errors.New("Method eth_signTransaction not implemented")
+		err = errors.New("method eth_signTransaction not implemented")
 		return
 	}
 	return handler(ctx,
@@ -736,7 +736,7 @@ func (h *RpcHandler) EthGetBalance(ctx context.Context,
 ) (Balance Uint, err error) {
 	handler := h.FnEthGetBalance
 	if handler == nil {
-		err = errors.New("Method eth_getBalance not implemented")
+		err = errors.New("method eth_getBalance not implemented")
 		return
 	}
 	return handler(ctx,
@@ -753,7 +753,7 @@ func (h *RpcHandler) EthGetStorageAt(ctx context.Context,
 ) (Value Bytes, err error) {
 	handler := h.FnEthGetStorageAt
 	if handler == nil {
-		err = errors.New("Method eth_getStorageAt not implemented")
+		err = errors.New("method eth_getStorageAt not implemented")
 		return
 	}
 	return handler(ctx,
@@ -770,7 +770,7 @@ func (h *RpcHandler) EthGetTransactionCount(ctx context.Context,
 ) (TransactionCount Uint, err error) {
 	handler := h.FnEthGetTransactionCount
 	if handler == nil {
-		err = errors.New("Method eth_getTransactionCount not implemented")
+		err = errors.New("method eth_getTransactionCount not implemented")
 		return
 	}
 	return handler(ctx,
@@ -786,7 +786,7 @@ func (h *RpcHandler) EthGetCode(ctx context.Context,
 ) (Bytecode Bytes, err error) {
 	handler := h.FnEthGetCode
 	if handler == nil {
-		err = errors.New("Method eth_getCode not implemented")
+		err = errors.New("method eth_getCode not implemented")
 		return
 	}
 	return handler(ctx,
@@ -803,7 +803,7 @@ func (h *RpcHandler) EthGetProof(ctx context.Context,
 ) (Account AccountProof, err error) {
 	handler := h.FnEthGetProof
 	if handler == nil {
-		err = errors.New("Method eth_getProof not implemented")
+		err = errors.New("method eth_getProof not implemented")
 		return
 	}
 	return handler(ctx,
@@ -819,7 +819,7 @@ func (h *RpcHandler) EthSendTransaction(ctx context.Context,
 ) (TransactionHash Hash32, err error) {
 	handler := h.FnEthSendTransaction
 	if handler == nil {
-		err = errors.New("Method eth_sendTransaction not implemented")
+		err = errors.New("method eth_sendTransaction not implemented")
 		return
 	}
 	return handler(ctx,
@@ -833,7 +833,7 @@ func (h *RpcHandler) EthSendRawTransaction(ctx context.Context,
 ) (TransactionHash Hash32, err error) {
 	handler := h.FnEthSendRawTransaction
 	if handler == nil {
-		err = errors.New("Method eth_sendRawTransaction not implemented")
+		err = errors.New("method eth_sendRawTransaction not implemented")
 		return
 	}
 	return handler(ctx,
@@ -847,7 +847,7 @@ func (h *RpcHandler) EthGetTransactionByHash(ctx context.Context,
 ) (TransactionInformation TransactionInfo, err error) {
 	handler := h.FnEthGetTransactionByHash
 	if handler == nil {
-		err = errors.New("Method eth_getTransactionByHash not implemented")
+		err = errors.New("method eth_getTransactionByHash not implemented")
 		return
 	}
 	return handler(ctx,
@@ -862,7 +862,7 @@ func (h *RpcHandler) EthGetTransactionByBlockHashAndIndex(ctx context.Context,
 ) (TransactionInformation TransactionInfo, err error) {
 	handler := h.FnEthGetTransactionByBlockHashAndIndex
 	if handler == nil {
-		err = errors.New("Method eth_getTransactionByBlockHashAndIndex not implemented")
+		err = errors.New("method eth_getTransactionByBlockHashAndIndex not implemented")
 		return
 	}
 	return handler(ctx,
@@ -878,7 +878,7 @@ func (h *RpcHandler) EthGetTransactionByBlockNumberAndIndex(ctx context.Context,
 ) (TransactionInformation TransactionInfo, err error) {
 	handler := h.FnEthGetTransactionByBlockNumberAndIndex
 	if handler == nil {
-		err = errors.New("Method eth_getTransactionByBlockNumberAndIndex not implemented")
+		err = errors.New("method eth_getTransactionByBlockNumberAndIndex not implemented")
 		return
 	}
 	return handler(ctx,
@@ -893,7 +893,7 @@ func (h *RpcHandler) EthGetTransactionReceipt(ctx context.Context,
 ) (ReceiptInformation ReceiptInfo, err error) {
 	handler := h.FnEthGetTransactionReceipt
 	if handler == nil {
-		err = errors.New("Method eth_getTransactionReceipt not implemented")
+		err = errors.New("method eth_getTransactionReceipt not implemented")
 		return
 	}
 	return handler(ctx,
diff --git a/openrpc/templates/types.gotmpl b/openrpc/templates/types.gotmpl
index 624d1b3..53b835d 100644
--- a/openrpc/templates/types.gotmpl
+++ b/openrpc/templates/types.gotmpl
@@ -87,9 +87,15 @@ type GoOpenRPCService interface {
 func (h *GoOpenRPCHandler) RouteRPC(r jrpc.Router) {
     {{range .Methods -}}
         // {{.Summary}}
-        if err := r.RegisterFunc("{{.MethodName}}", h.Srv.{{camelCase .Name}}); err != nil {
-            panic(err)
-        }
+        {{if .Namespace}}
+            if err := r.RegisterFunc("{{.Namespace}}_{{.MethodName}}", h.Srv.{{camelCase .Name}}); err != nil {
+                panic(err)
+            }
+        {{else}}
+            if err := r.RegisterFunc("{{.MethodName}}", h.Srv.{{camelCase .Name}}); err != nil {
+                panic(err)
+            }
+        {{end}}
     {{end -}}
 }
 
-- 
GitLab