Add fees fields to /operations endpoint (#1545)

* add fees to operations endpoint

* update swagger docs
This commit is contained in:
Mariano 2024-07-16 12:00:13 -03:00 committed by GitHub
parent 6ab6824d82
commit 40dafd9b78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 79 additions and 27 deletions

View File

@ -2876,9 +2876,15 @@ const docTemplate = `{
"fee": {
"type": "string"
},
"feeUSD": {
"type": "string"
},
"from": {
"type": "string"
},
"gasTokenNotional": {
"type": "string"
},
"status": {
"type": "string"
},
@ -2937,9 +2943,18 @@ const docTemplate = `{
"chainId": {
"$ref": "#/definitions/vaa.ChainID"
},
"fee": {
"type": "string"
},
"feeUSD": {
"type": "string"
},
"from": {
"type": "string"
},
"gasTokenNotional": {
"type": "string"
},
"status": {
"type": "string"
},

View File

@ -2869,9 +2869,15 @@
"fee": {
"type": "string"
},
"feeUSD": {
"type": "string"
},
"from": {
"type": "string"
},
"gasTokenNotional": {
"type": "string"
},
"status": {
"type": "string"
},
@ -2930,9 +2936,18 @@
"chainId": {
"$ref": "#/definitions/vaa.ChainID"
},
"fee": {
"type": "string"
},
"feeUSD": {
"type": "string"
},
"from": {
"type": "string"
},
"gasTokenNotional": {
"type": "string"
},
"status": {
"type": "string"
},

View File

@ -435,8 +435,12 @@ definitions:
$ref: '#/definitions/vaa.ChainID'
fee:
type: string
feeUSD:
type: string
from:
type: string
gasTokenNotional:
type: string
status:
type: string
timestamp:
@ -475,8 +479,14 @@ definitions:
properties:
chainId:
$ref: '#/definitions/vaa.ChainID'
fee:
type: string
feeUSD:
type: string
from:
type: string
gasTokenNotional:
type: string
status:
type: string
timestamp:

View File

@ -46,13 +46,15 @@ type Content struct {
// SourceChain definition.
type SourceChain struct {
ChainId sdk.ChainID `json:"chainId"`
Timestamp *time.Time `json:"timestamp"`
Transaction Transaction `json:"transaction"`
From string `json:"from"`
Status string `json:"status"`
Data *Data `json:"attribute,omitempty"`
Fee *string `json:"fee,omitempty"`
ChainId sdk.ChainID `json:"chainId"`
Timestamp *time.Time `json:"timestamp"`
Transaction Transaction `json:"transaction"`
From string `json:"from"`
Status string `json:"status"`
Data *Data `json:"attribute,omitempty"`
Fee *string `json:"fee,omitempty"`
GasTokenNotional *string `json:"gasTokenNotional,omitempty"`
FeeUSD *string `json:"feeUSD,omitempty"`
}
// TxHash definition.
@ -63,13 +65,15 @@ type Transaction struct {
// TargetChain definition.
type TargetChain struct {
ChainId sdk.ChainID `json:"chainId"`
Timestamp *time.Time `json:"timestamp"`
Transaction Transaction `json:"transaction"`
Status string `json:"status"`
From string `json:"from"`
To string `json:"to"`
Fee *string `json:"fee,omitempty"`
ChainId sdk.ChainID `json:"chainId"`
Timestamp *time.Time `json:"timestamp"`
Transaction Transaction `json:"transaction"`
Status string `json:"status"`
From string `json:"from"`
To string `json:"to"`
Fee *string `json:"fee,omitempty"`
GasTokenNotional *string `json:"gasTokenNotional,omitempty"`
FeeUSD *string `json:"feeUSD,omitempty"`
}
// Data represents a custom attribute for a origin transaction.
@ -205,29 +209,35 @@ func getChainEvents(chainID sdk.ChainID, operation *operations.OperationDto) (*S
SecondTxHash: secondTxHash,
}
var sourceFee *string
var sourceFee, sourceFeeUSD, sourceGasTokenNotional *string
if operation.SourceTx.Fee != nil {
sourceFee = &operation.SourceTx.Fee.Fee
sourceFeeUSD = &operation.SourceTx.Fee.FeeUSD
sourceGasTokenNotional = &operation.SourceTx.Fee.GasTokenNotional
}
sourceChain = &SourceChain{
ChainId: chainID,
Timestamp: operation.SourceTx.Timestamp,
Transaction: transaction,
From: operation.SourceTx.From,
Status: operation.SourceTx.Status,
Data: data,
Fee: sourceFee,
ChainId: chainID,
Timestamp: operation.SourceTx.Timestamp,
Transaction: transaction,
From: operation.SourceTx.From,
Status: operation.SourceTx.Status,
Data: data,
Fee: sourceFee,
FeeUSD: sourceFeeUSD,
GasTokenNotional: sourceGasTokenNotional,
}
}
// build targetChain
var targetChain *TargetChain
if operation.DestinationTx != nil {
var targetFee, targetFeeUSD, targetGasTokenNotional *string
var targetFee *string
if operation.DestinationTx.Fee != nil {
targetFee = &operation.DestinationTx.Fee.Fee
targetFeeUSD = &operation.DestinationTx.Fee.FeeUSD
targetGasTokenNotional = &operation.DestinationTx.Fee.GasTokenNotional
}
targetChain = &TargetChain{
@ -236,10 +246,12 @@ func getChainEvents(chainID sdk.ChainID, operation *operations.OperationDto) (*S
Transaction: Transaction{
TxHash: operation.DestinationTx.TxHash,
},
Status: operation.DestinationTx.Status,
From: operation.DestinationTx.From,
To: operation.DestinationTx.To,
Fee: targetFee,
Status: operation.DestinationTx.Status,
From: operation.DestinationTx.From,
To: operation.DestinationTx.To,
Fee: targetFee,
FeeUSD: targetFeeUSD,
GasTokenNotional: targetGasTokenNotional,
}
}