Skip to content

Commit

Permalink
op-celestia: fix helper tool (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxcanfly authored Nov 7, 2023
1 parent 006f891 commit 6839400
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions op-celestia/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package main

import (
"bytes"
"context"
"encoding/binary"
"encoding/hex"
"fmt"
"os"

"github.com/ethereum-optimism/optimism/op-celestia/celestia"
openrpc "github.com/rollkit/celestia-openrpc"
"github.com/rollkit/celestia-openrpc/types/share"
)
Expand All @@ -16,19 +15,13 @@ func main() {
if len(os.Args) < 4 {
panic("usage: op-celestia <namespace> <eth calldata> <auth token>")
}

data, _ := hex.DecodeString(os.Args[2])
buf := bytes.NewBuffer(data)
var height int64
err := binary.Read(buf, binary.BigEndian, &height)
if err != nil {
panic(err)
}
var index uint32
err = binary.Read(buf, binary.BigEndian, &index)
if err != nil {
panic(err)
}
fmt.Printf("celestia block height: %v; tx index: %v\n", height, index)

frameRef := celestia.FrameRef{}
frameRef.UnmarshalBinary(data)

fmt.Printf("celestia block height: %v; tx index: %v\n", frameRef.BlockHeight, frameRef.TxCommitment)
fmt.Println("-----------------------------------------")
client, err := openrpc.NewClient(context.Background(), "http://localhost:26658", os.Args[3])
if err != nil {
Expand All @@ -43,7 +36,7 @@ func main() {
panic(err)
}

namespacedData, err := client.Blob.GetAll(context.Background(), uint64(height), []share.Namespace{namespace})
namespacedData, err := client.Blob.GetAll(context.Background(), uint64(frameRef.BlockHeight), []share.Namespace{namespace})
if err != nil {
panic(err)
}
Expand Down
Binary file removed op-celestia/op-celestia
Binary file not shown.

0 comments on commit 6839400

Please sign in to comment.