Skip to content

Commit 5b8e1cf

Browse files
authored
remove camelcase from api responses (#167)
### TL;DR Updated JSON field names to follow consistent snake_case convention and added backward compatibility for deprecated fields. ### What changed? - Renamed `decodedData` to `decoded` in transaction and log responses - Changed `indexedParams` to `indexed_params` and `nonIndexedParams` to `non_indexed_params` - Added deprecated versions of the params fields to maintain backward compatibility - Added swagger documentation tags to mark deprecated fields ### How to test? 1. Make API requests that fetch decoded logs and transactions 2. Verify new snake_case fields contain the expected data 3. Confirm deprecated camelCase fields still work and contain the same data 4. Check swagger documentation reflects the deprecated status of old fields ### Why make this change? To establish consistent snake_case naming conventions across the API while ensuring existing integrations continue to work through a deprecation period.
2 parents 73eeb25 + 6b1f39f commit 5b8e1cf

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

internal/common/log.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ type LogModel struct {
5858
}
5959

6060
type DecodedLogDataModel struct {
61-
Name string `json:"name"`
62-
Signature string `json:"signature"`
63-
IndexedParams map[string]interface{} `json:"indexedParams" swaggertype:"object"`
64-
NonIndexedParams map[string]interface{} `json:"nonIndexedParams" swaggertype:"object"`
61+
Name string `json:"name"`
62+
Signature string `json:"signature"`
63+
IndexedParamsDeprecated map[string]interface{} `json:"indexedParams" swaggertype:"object" deprecated:"true"`
64+
IndexedParams map[string]interface{} `json:"indexed_params" swaggertype:"object"`
65+
NonIndexedParamsDeprecated map[string]interface{} `json:"nonIndexedParams" swaggertype:"object" deprecated:"true"`
66+
NonIndexedParams map[string]interface{} `json:"non_indexed_params" swaggertype:"object"`
6567
}
6668

6769
type DecodedLogModel struct {
@@ -77,13 +79,13 @@ type RawReceipt = map[string]interface{}
7779
type DecodedLogData struct {
7880
Name string `json:"name"`
7981
Signature string `json:"signature"`
80-
IndexedParams map[string]interface{} `json:"indexedParams"`
81-
NonIndexedParams map[string]interface{} `json:"nonIndexedParams"`
82+
IndexedParams map[string]interface{} `json:"indexed_params"`
83+
NonIndexedParams map[string]interface{} `json:"non_indexed_params"`
8284
}
8385

8486
type DecodedLog struct {
8587
Log
86-
Decoded DecodedLogData `json:"decodedData"`
88+
Decoded DecodedLogData `json:"decoded"`
8789
}
8890

8991
func DecodeLogs(chainId string, logs []Log) []*DecodedLog {
@@ -251,10 +253,12 @@ func (l *Log) Serialize() LogModel {
251253

252254
func (l *DecodedLog) Serialize() DecodedLogModel {
253255
decodedData := DecodedLogDataModel{
254-
Name: l.Decoded.Name,
255-
Signature: l.Decoded.Signature,
256-
IndexedParams: l.Decoded.IndexedParams,
257-
NonIndexedParams: l.Decoded.NonIndexedParams,
256+
Name: l.Decoded.Name,
257+
Signature: l.Decoded.Signature,
258+
IndexedParams: l.Decoded.IndexedParams,
259+
IndexedParamsDeprecated: l.Decoded.IndexedParams,
260+
NonIndexedParams: l.Decoded.NonIndexedParams,
261+
NonIndexedParamsDeprecated: l.Decoded.NonIndexedParams,
258262
}
259263
return DecodedLogModel{
260264
LogModel: l.Log.Serialize(),

internal/common/transaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type DecodedTransactionData struct {
5353

5454
type DecodedTransaction struct {
5555
Transaction
56-
Decoded DecodedTransactionData `json:"decodedData"`
56+
Decoded DecodedTransactionData `json:"decoded"`
5757
}
5858

5959
// TransactionModel represents a simplified Transaction structure for Swagger documentation

0 commit comments

Comments
 (0)