From 55d4b352caa044859fad4b9cc8c5f9364cae7685 Mon Sep 17 00:00:00 2001 From: agodnic Date: Wed, 12 Jul 2023 16:47:33 -0300 Subject: [PATCH] Remove unused fields from the origin transaction model (#528) ### Description This pull request removes two unused fields from the `GlobalTransaction.OriginTx` JSON model: * `timestamp`: this field is always set to the VAA's timestamp, making it redundant. Moreover, for EVM chains we need one extra RPC node request to get it. So better get rid of it. * `chainId`: this field is always set to the VAA's emitter chain, making it redundant. --- api/docs/docs.go | 6 ------ api/docs/swagger.json | 6 ------ api/docs/swagger.yaml | 4 ---- api/handlers/transactions/model.go | 8 +++----- api/handlers/transactions/repository.go | 6 +----- 5 files changed, 4 insertions(+), 26 deletions(-) diff --git a/api/docs/docs.go b/api/docs/docs.go index 6999b136..fc140ac0 100644 --- a/api/docs/docs.go +++ b/api/docs/docs.go @@ -2591,18 +2591,12 @@ const docTemplate = `{ "transactions.OriginTx": { "type": "object", "properties": { - "chainId": { - "$ref": "#/definitions/vaa.ChainID" - }, "from": { "type": "string" }, "status": { "type": "string" }, - "timestamp": { - "type": "string" - }, "txHash": { "type": "string" } diff --git a/api/docs/swagger.json b/api/docs/swagger.json index e0417cd5..263b2cd5 100644 --- a/api/docs/swagger.json +++ b/api/docs/swagger.json @@ -2584,18 +2584,12 @@ "transactions.OriginTx": { "type": "object", "properties": { - "chainId": { - "$ref": "#/definitions/vaa.ChainID" - }, "from": { "type": "string" }, "status": { "type": "string" }, - "timestamp": { - "type": "string" - }, "txHash": { "type": "string" } diff --git a/api/docs/swagger.yaml b/api/docs/swagger.yaml index 4e72fc05..4b692258 100644 --- a/api/docs/swagger.yaml +++ b/api/docs/swagger.yaml @@ -541,14 +541,10 @@ definitions: type: object transactions.OriginTx: properties: - chainId: - $ref: '#/definitions/vaa.ChainID' from: type: string status: type: string - timestamp: - type: string txHash: type: string type: object diff --git a/api/handlers/transactions/model.go b/api/handlers/transactions/model.go index 7d1e9a47..c17555a9 100644 --- a/api/handlers/transactions/model.go +++ b/api/handlers/transactions/model.go @@ -76,11 +76,9 @@ type GlobalTransactionDoc struct { // OriginTx representa a origin transaction. type OriginTx struct { - ChainID sdk.ChainID `bson:"chainId" json:"chainId"` - TxHash string `bson:"nativeTxHash" json:"txHash"` - Timestamp *time.Time `bson:"timestamp" json:"timestamp"` - From string `bson:"from" json:"from"` - Status string `bson:"status" json:"status"` + TxHash string `bson:"nativeTxHash" json:"txHash"` + From string `bson:"from" json:"from"` + Status string `bson:"status" json:"status"` } // DestinationTx representa a destination transaction. diff --git a/api/handlers/transactions/repository.go b/api/handlers/transactions/repository.go index f9d970b7..d7cf32b3 100644 --- a/api/handlers/transactions/repository.go +++ b/api/handlers/transactions/repository.go @@ -656,8 +656,6 @@ func (r *Repository) FindGlobalTransactionByID(ctx context.Context, q *GlobalTra } default: result = globalTransaction - result.OriginTx.Timestamp = originTx.Timestamp - result.OriginTx.ChainID = originTx.ChainID } return result, nil @@ -692,9 +690,7 @@ func (r *Repository) findOriginTxFromVaa(ctx context.Context, q *GlobalTransacti // populate the result and return originTx := OriginTx{ - Timestamp: &record.Timestamp, - ChainID: record.EmitterChain, - Status: string(domain.SourceTxStatusConfirmed), + Status: string(domain.SourceTxStatusConfirmed), } if record.EmitterChain != sdk.ChainIDSolana && record.EmitterChain != sdk.ChainIDAptos { originTx.TxHash = record.TxHash