Skip to content

Commit

Permalink
Merge pull request #774 from The-K-R-O-K/illia-malachyn/769-transacti…
Browse files Browse the repository at this point in the history
…on-result-response-object

Add computation_usage to transaction result response object
  • Loading branch information
peterargue authored Sep 26, 2024
2 parents 2689460 + 403832d commit 62f6b8b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
32 changes: 17 additions & 15 deletions access/grpc/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,15 @@ func TransactionResultToMessage(result flow.TransactionResult, encodingVersion f
}

return &access.TransactionResultResponse{
Status: entities.TransactionStatus(result.Status),
StatusCode: uint32(statusCode),
ErrorMessage: errorMsg,
Events: eventMessages,
BlockId: IdentifierToMessage(result.BlockID),
BlockHeight: result.BlockHeight,
TransactionId: IdentifierToMessage(result.TransactionID),
CollectionId: IdentifierToMessage(result.CollectionID),
Status: entities.TransactionStatus(result.Status),
StatusCode: uint32(statusCode),
ErrorMessage: errorMsg,
Events: eventMessages,
BlockId: IdentifierToMessage(result.BlockID),
BlockHeight: result.BlockHeight,
TransactionId: IdentifierToMessage(result.TransactionID),
CollectionId: IdentifierToMessage(result.CollectionID),
ComputationUsage: result.ComputationUsage,
}, nil
}

Expand Down Expand Up @@ -610,13 +611,14 @@ func MessageToTransactionResult(m *access.TransactionResultResponse, options []j
}

return flow.TransactionResult{
Status: flow.TransactionStatus(m.GetStatus()),
Error: err,
Events: events,
BlockID: flow.BytesToID(m.GetBlockId()),
BlockHeight: m.GetBlockHeight(),
TransactionID: flow.BytesToID(m.GetTransactionId()),
CollectionID: flow.BytesToID(m.GetCollectionId()),
Status: flow.TransactionStatus(m.GetStatus()),
Error: err,
Events: events,
BlockID: flow.BytesToID(m.GetBlockId()),
BlockHeight: m.GetBlockHeight(),
TransactionID: flow.BytesToID(m.GetTransactionId()),
CollectionID: flow.BytesToID(m.GetCollectionId()),
ComputationUsage: m.GetComputationUsage(),
}, nil
}

Expand Down
9 changes: 5 additions & 4 deletions test/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,11 @@ func (g *TransactionResults) New() flow.TransactionResult {
g.events.New(),
g.events.New(),
},
BlockID: g.ids.New(),
BlockHeight: uint64(42),
TransactionID: g.ids.New(),
CollectionID: g.ids.New(),
BlockID: g.ids.New(),
BlockHeight: uint64(42),
TransactionID: g.ids.New(),
CollectionID: g.ids.New(),
ComputationUsage: uint64(42),
}
}

Expand Down
15 changes: 8 additions & 7 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,14 @@ func (s signaturesList) canonicalForm() []transactionSignatureCanonicalForm {
}

type TransactionResult struct {
Status TransactionStatus
Error error
Events []Event
BlockID Identifier
BlockHeight uint64
TransactionID Identifier
CollectionID Identifier
Status TransactionStatus
Error error
Events []Event
BlockID Identifier
BlockHeight uint64
TransactionID Identifier
CollectionID Identifier
ComputationUsage uint64
}

// TransactionStatus represents the status of a transaction.
Expand Down

0 comments on commit 62f6b8b

Please sign in to comment.