Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BlockHeight to TransactionResult #308

Merged

Conversation

emilic
Copy link
Contributor

@emilic emilic commented Jun 29, 2022

Closes: #307

Description

Add missing BlockHeight to the TransactionResult. Note that this update is only for the GRPC API call and does not update the HTTP endpoint. Comments in issue refer requiring openapi schema needing updates so new models can be generated, out of scope for this PR.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@sukantoraymond
Copy link
Contributor

LGTM

@codecov-commenter
Copy link

Codecov Report

Merging #308 (e9f2dcd) into master (900f9f9) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #308      +/-   ##
==========================================
+ Coverage   65.98%   66.01%   +0.03%     
==========================================
  Files          21       21              
  Lines        1952     1954       +2     
==========================================
+ Hits         1288     1290       +2     
  Misses        543      543              
  Partials      121      121              
Flag Coverage Δ
unittests 66.01% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
transaction.go 85.84% <ø> (ø)
access/grpc/convert.go 84.83% <100.00%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 900f9f9...e9f2dcd. Read the comment docs.

Copy link
Contributor

@rrrkren rrrkren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want to add to access/http as well?

Copy link
Contributor

@psiemens psiemens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @rrrkren.

@emilic You'll also want to update this function to include BlockHeight:

func toTransactionResult(txr *models.TransactionResult, options []cadenceJSON.Option) (*flow.TransactionResult, error) {
events, err := toEvents(txr.Events, options)
if err != nil {
return nil, err
}
var txErr error
if txr.ErrorMessage != "" {
txErr = fmt.Errorf(txr.ErrorMessage)
}
return &flow.TransactionResult{
Status: toTransactionStatus(txr.Status),
Error: txErr,
Events: events,
BlockID: flow.HexToID(txr.BlockId),
}, nil
}

I believe that will require a change to the TransactionResult JSON model here:

type TransactionResult struct {

@emilic
Copy link
Contributor Author

emilic commented Jun 30, 2022

probably want to add to access/http as well?

I mentioned that this is generated from an openapi schema in another project. I made this PR: onflow/flow#1025 to add the block_height to the schema so we can generate it with the Makefile

@sukantoraymond @psiemens

@emilic
Copy link
Contributor Author

emilic commented Jun 30, 2022

Good catch @rrrkren.

@emilic You'll also want to update this function to include BlockHeight:

func toTransactionResult(txr *models.TransactionResult, options []cadenceJSON.Option) (*flow.TransactionResult, error) {
events, err := toEvents(txr.Events, options)
if err != nil {
return nil, err
}
var txErr error
if txr.ErrorMessage != "" {
txErr = fmt.Errorf(txr.ErrorMessage)
}
return &flow.TransactionResult{
Status: toTransactionStatus(txr.Status),
Error: txErr,
Events: events,
BlockID: flow.HexToID(txr.BlockId),
}, nil
}

I believe that will require a change to the TransactionResult JSON model here:

type TransactionResult struct {

I'll need to make a PR to the flow-go repo as well to update the openapi schema

Copy link
Contributor

@psiemens psiemens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

Thanks for clarifying @emilic. I think it's OK to merge this as-is given that the HTTP doesn't yet support the block height field.

@psiemens psiemens merged commit a2cf588 into onflow:master Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add block height to TransactionResult struct
5 participants