Skip to content

Commit

Permalink
adding first draft of converting metadata to protobuf types
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard-Voiculescu committed Jul 14, 2024
1 parent 18cf464 commit fdd0f1f
Show file tree
Hide file tree
Showing 15 changed files with 125,893 additions and 73 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ data/*
/firevara
devel/data/*
devel/firehose-data/*
.vscode/*
.env
14 changes: 13 additions & 1 deletion cmd/firevara/tools_convert_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func convertMetadataE(logger *zap.Logger, tracer logging.Tracer) firecore.Comman
blockHash := sflags.MustGetString(cmd, "block-hash")
endpoint := args[0]

if endpoint == "" {
return fmt.Errorf("missing endpoint")
}

if blockHash != "" && !strings.HasPrefix(blockHash, "0x") {
blockHash = "0x" + blockHash
}
Expand All @@ -44,7 +48,15 @@ func convertMetadataE(logger *zap.Logger, tracer logging.Tracer) firecore.Comman
return fmt.Errorf("converting metadata: %w", err)
}

fmt.Println(metadata)
for _, t := range metadata.Types {
msg := t.ToProtoMessage()
if msg == "" {
continue
}
fmt.Println(msg)
}

// fmt.Println(metadata)
return nil
}
}
11 changes: 2 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ replace github.com/jhump/protoreflect => github.com/streamingfast/protoreflect v

require (
github.com/centrifuge/go-substrate-rpc-client/v4 v4.2.1
github.com/gobeam/stringy v0.0.7
github.com/spf13/cobra v1.7.0
github.com/streamingfast/bstream v0.0.2-0.20240619142813-9d23840859bf
github.com/streamingfast/cli v0.0.4-0.20240412191021-5f81842cb71d
Expand Down Expand Up @@ -57,11 +58,8 @@ require (
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-json-experiment/json v0.0.0-20231013223334-54c864be5b8d // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -80,8 +78,6 @@ require (
github.com/ipfs/go-ipfs-api v0.6.0 // indirect
github.com/jhump/protoreflect v1.14.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josephburnett/jd v1.7.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.16.6 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
Expand All @@ -90,15 +86,13 @@ require (
github.com/lithammer/dedent v1.1.0 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mostynb/go-grpc-compression v1.1.17 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/mschoch/smat v0.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
Expand Down Expand Up @@ -138,7 +132,6 @@ require (
github.com/streamingfast/dmetrics v0.0.0-20230919161904-206fa8ebd545 // indirect
github.com/streamingfast/dstore v0.1.1-0.20240325191553-bcce8892a9bb // indirect
github.com/streamingfast/dtracing v0.0.0-20220305214756-b5c0e8699839 // indirect
github.com/streamingfast/jsonpb v0.0.0-20210811021341-3670f0aa02d0 // indirect
github.com/streamingfast/opaque v0.0.0-20210811180740-0c01d37ea308 // indirect
github.com/streamingfast/pbgo v0.0.6-0.20240430190514-722fe9d82e5d // indirect
github.com/streamingfast/sf-tracing v0.0.0-20240430173521-888827872b90 // indirect
Expand Down Expand Up @@ -199,7 +192,7 @@ require (
github.com/streamingfast/firehose-core v1.5.4-0.20240627152952-7accd60755e3
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/stretchr/testify v1.8.4
github.com/vedhavyas/go-subkey/v2 v2.0.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
Expand Down
39 changes: 2 additions & 37 deletions go.sum

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func main() {
blockHash, err := types.NewHashFromHexString("0x53cde3f3c1909cdc98c4e724c569f5517511928d451811916ebb181bc7d7f7f7")
blockHash, err := types.NewHashFromHexString("0xcd73e68bd2bb5f3110ab1e7e62f7381038d088eab970a57dacbad5e76690a3db")
if err != nil {
log.Fatalf("Failed to create block hash: %v", err)
}
Expand Down Expand Up @@ -71,7 +71,7 @@ func main() {
log.Fatalf("Failed to marshal extrinsic: %v", err)
}
_ = j
// fmt.Println(string(j))
fmt.Println(string(j))
}

eventRetriever, err := retriever.NewDefaultEventRetriever(state.NewEventProvider(api.RPC.State), api.RPC.State)
Expand Down Expand Up @@ -116,17 +116,18 @@ func main() {
if err != nil {
log.Fatalf("Failed to marshal extrinsic: %v", err)
}

_ = m

block0, err := types.NewHashFromHexString("0x1555a60f789e322c607f8b8df062cf0441484897b547028c378509d5e56eec48")
if err != nil {
log.Fatalf("Failed to create block hash: %v", err)
}
specVerion, err := api.RPC.State.GetRuntimeVersion(block0)
if err != nil {
log.Fatalf("Failed to get runtime version: %v", err)
}
// fmt.Println(string(m))

// block0, err := types.NewHashFromHexString("0x1555a60f789e322c607f8b8df062cf0441484897b547028c378509d5e56eec48")
// if err != nil {
// log.Fatalf("Failed to create block hash: %v", err)
// }
// specVerion, err := api.RPC.State.GetRuntimeVersion(block0)
// if err != nil {
// log.Fatalf("Failed to get runtime version: %v", err)
// }

fmt.Println("Spec Version: ", specVerion.SpecVersion)
// fmt.Println("Spec Version: ", specVerion.SpecVersion)
}
Loading

0 comments on commit fdd0f1f

Please sign in to comment.