Skip to content

Commit

Permalink
Handle populated, empty Operation.Status
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Dec 1, 2020
1 parent 3507943 commit a954dc4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions asserter/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ func (a *Asserter) OperationStatus(status *string, construction bool) error {
return ErrAsserterNotInitialized
}

if status == nil {
// As of rosetta-specifications@v1.4.7, populating
// the Operation.Status field is deprecated for construction,
// however, many implementations may still do this. Therefore,
// we need to handle a populated but empty Operation.Status
// field gracefully.
if status == nil || len(*status) == 0 {
if construction {
return nil
}
Expand All @@ -155,10 +160,6 @@ func (a *Asserter) OperationStatus(status *string, construction bool) error {
return ErrOperationStatusNotEmptyForConstruction
}

if len(*status) == 0 {
return ErrOperationStatusMissing
}

if _, ok := a.operationStatusMap[*status]; !ok {
return fmt.Errorf("%w: %s", ErrOperationStatusInvalid, *status)
}
Expand Down

0 comments on commit a954dc4

Please sign in to comment.