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

@ -53,6 +53,8 @@ type SourceChain struct {
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.
@ -70,6 +72,8 @@ type TargetChain struct {
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,9 +209,11 @@ 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{
@ -218,16 +224,20 @@ func getChainEvents(chainID sdk.ChainID, operation *operations.OperationDto) (*S
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{
@ -240,6 +250,8 @@ func getChainEvents(chainID sdk.ChainID, operation *operations.OperationDto) (*S
From: operation.DestinationTx.From,
To: operation.DestinationTx.To,
Fee: targetFee,
FeeUSD: targetFeeUSD,
GasTokenNotional: targetGasTokenNotional,
}
}