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": { "fee": {
"type": "string" "type": "string"
}, },
"feeUSD": {
"type": "string"
},
"from": { "from": {
"type": "string" "type": "string"
}, },
"gasTokenNotional": {
"type": "string"
},
"status": { "status": {
"type": "string" "type": "string"
}, },
@ -2937,9 +2943,18 @@ const docTemplate = `{
"chainId": { "chainId": {
"$ref": "#/definitions/vaa.ChainID" "$ref": "#/definitions/vaa.ChainID"
}, },
"fee": {
"type": "string"
},
"feeUSD": {
"type": "string"
},
"from": { "from": {
"type": "string" "type": "string"
}, },
"gasTokenNotional": {
"type": "string"
},
"status": { "status": {
"type": "string" "type": "string"
}, },

View File

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

View File

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

View File

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