-
Notifications
You must be signed in to change notification settings - Fork 0
/
converters.go
42 lines (37 loc) · 1.05 KB
/
converters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package grpc
import (
"github.com/dipdup-net/abi-indexer/internal/storage"
"github.com/dipdup-net/abi-indexer/pkg/modules/grpc/pb"
generalPB "github.com/dipdup-net/indexer-sdk/pkg/modules/grpc/pb"
)
// Metadata -
func Metadata(metadata *storage.Metadata) *pb.Metadata {
return &pb.Metadata{
Address: metadata.Contract,
Metadata: metadata.Metadata,
JsonSchema: metadata.JSONSchema,
}
}
// SubscriptionMetadata -
func SubscriptionMetadata(id uint64, metadata *storage.Metadata) *pb.SubscriptionMetadata {
return &pb.SubscriptionMetadata{
Subscription: &generalPB.SubscribeResponse{
Id: id,
},
Metadata: Metadata(metadata),
}
}
// HeadRequest -
func MetadataRequest() *generalPB.DefaultRequest {
return new(generalPB.DefaultRequest)
}
// ListMetadataResponse -
func ListMetadataResponse(metadata []*storage.Metadata) *pb.ListMetadataResponse {
response := &pb.ListMetadataResponse{
Metadata: make([]*pb.Metadata, 0),
}
for i := range metadata {
response.Metadata = append(response.Metadata, Metadata(metadata[i]))
}
return response
}