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.
This commit is contained in:
agodnic 2023-07-12 16:47:33 -03:00 committed by GitHub
parent fe196e35f0
commit 55d4b352ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 26 deletions

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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

View File

@ -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.

View File

@ -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