Skip to content

Commit

Permalink
Fix: storage parsing in alphanet
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored and m-kus committed Mar 11, 2021
1 parent a2f9844 commit 9801f6b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions internal/parsers/storage/alpha.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ func (a *Alpha) ParseOrigination(content noderpc.Operation, operation operation.
}
bmd := make([]models.Model, 0)

var storageData struct {
Storage ast.UntypedAST `json:"storage"`
}

if err := json.Unmarshal(content.Script, &storageData); err != nil {
return RichStorage{Empty: true}, err
}

if err := storage.Settle(storageData.Storage); err != nil {
return RichStorage{Empty: true}, err
}

pair, ok := storage.Nodes[0].(*ast.Pair)
if ok {
bigMap, ok := pair.Args[0].(*ast.BigMap)
Expand All @@ -49,18 +61,6 @@ func (a *Alpha) ParseOrigination(content noderpc.Operation, operation operation.
return RichStorage{Empty: true}, nil
}

var storageData struct {
Storage ast.UntypedAST `json:"storage"`
}

if err := json.Unmarshal(content.Script, &storageData); err != nil {
return RichStorage{Empty: true}, err
}

if err := storage.Settle(storageData.Storage); err != nil {
return RichStorage{Empty: true}, err
}

if err := bigMap.Data.Range(func(key, value ast.Comparable) (bool, error) {
k := key.(ast.Node)
keyHash, err := ast.BigMapKeyHashFromNode(k)
Expand Down

0 comments on commit 9801f6b

Please sign in to comment.