Skip to content

Commit

Permalink
feat(taiko-client): switching from blobstorage server to blobscan-api (
Browse files Browse the repository at this point in the history
…#17244)

Co-authored-by: jeff <[email protected]>
  • Loading branch information
k-kaddal and cyberhorsey authored May 21, 2024
1 parent cc718b8 commit fbdb7c0
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions packages/taiko-client/pkg/rpc/blob_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ type BlobDataSeq struct {
Data []*BlobData `json:"data"`
}

type BlobServerResponse struct {
Commitment string `json:"commitment"`
Data string `json:"data"`
VersionedHash string `json:"versionedHash"`
}

func NewBlobDataSource(
ctx context.Context,
client *Client,
Expand Down Expand Up @@ -83,17 +89,13 @@ func (ds *BlobDataSource) GetBlobs(

// getBlobFromServer get blob data from server path `/getBlob`.
func (ds *BlobDataSource) getBlobFromServer(ctx context.Context, blobHash common.Hash) (*BlobDataSeq, error) {
var (
route = "/getBlob"
param = map[string]string{"blobHash": blobHash.String()}
)
route := "/blobs/" + blobHash.String()
requestURL, err := url.JoinPath(ds.blobServerEndpoint.String(), route)
if err != nil {
return nil, err
}
resp, err := resty.New().R().
SetResult(BlobDataSeq{}).
SetQueryParams(param).
SetResult(BlobServerResponse{}).
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
Expand All @@ -103,9 +105,18 @@ func (ds *BlobDataSource) getBlobFromServer(ctx context.Context, blobHash common
}
if !resp.IsSuccess() {
return nil, fmt.Errorf(
"unable to connect blob server endpoint, status code: %v",
"unable to connect blobscan endpoint, status code: %v",
resp.StatusCode(),
)
}
return resp.Result().(*BlobDataSeq), nil
response := resp.Result().(*BlobServerResponse)

return &BlobDataSeq{
Data: []*BlobData{
{
BlobHash: response.VersionedHash,
KzgCommitment: response.Commitment,
Blob: response.Data,
},
}}, nil
}

0 comments on commit fbdb7c0

Please sign in to comment.