github.com/celestiaorg/celestia-node@v0.15.0-beta.1/nodebuilder/blob/cmd/util.go (about)

     1  package cmd
     2  
     3  import (
     4  	"encoding/json"
     5  	"os"
     6  )
     7  
     8  // Define the raw content from the file input.
     9  type blobs struct {
    10  	Blobs []blobJSON
    11  }
    12  
    13  type blobJSON struct {
    14  	Namespace string
    15  	BlobData  string
    16  }
    17  
    18  func parseSubmitBlobs(path string) ([]blobJSON, error) {
    19  	var rawBlobs blobs
    20  
    21  	content, err := os.ReadFile(path)
    22  	if err != nil {
    23  		return []blobJSON{}, err
    24  	}
    25  
    26  	err = json.Unmarshal(content, &rawBlobs)
    27  	if err != nil {
    28  		return []blobJSON{}, err
    29  	}
    30  
    31  	return rawBlobs.Blobs, err
    32  }