Skip to content

Commit

Permalink
defaulting if no db
Browse files Browse the repository at this point in the history
  • Loading branch information
DanFlannel committed Jan 26, 2024
1 parent ff39e59 commit b360da7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion explorer/graphql/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Run(ctx context.Context, conf ExplorerGralQLConfig) error {
}

provider := data.Provider{
EntClient: *client,
EntClient: client,
}

mux := http.NewServeMux()
Expand Down
27 changes: 20 additions & 7 deletions explorer/graphql/data/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package data
import (
"context"
"math/big"
"time"

"github.com/omni-network/omni/explorer/db/ent"
"github.com/omni-network/omni/explorer/db/ent/block"
Expand All @@ -15,16 +16,28 @@ import (
)

type Provider struct {
EntClient ent.Client
EntClient *ent.Client
}

func (p Provider) Block(sourceChainID uint64, height uint64) (*resolvers.Block, bool, error) {
// h := common.Hash{}
// h.SetBytes([]byte{1, 3, 23, 111, 27, 45, 98, 103, 94, 55, 1, 3, 23, 111, 27, 45, 98, 103, 94, 55})
// var chainID big.Int
// chainID.SetUint64(sourceChainID)
// var blockHeight big.Int
// blockHeight.SetUint64(height)
if p.EntClient == nil {
h := common.Hash{}
h.SetBytes([]byte{1, 3, 23, 111, 27, 45, 98, 103, 94, 55, 1, 3, 23, 111, 27, 45, 98, 103, 94, 55})
var chainID big.Int
chainID.SetUint64(sourceChainID)
var blockHeight big.Int
blockHeight.SetUint64(height)

res := resolvers.Block{
SourceChainIDRaw: resolvers.BigInt{Int: chainID},
BlockHeightRaw: resolvers.BigInt{Int: blockHeight},
BlockHashRaw: h,
Timestamp: graphql.Time{Time: time.Now()},
Messages: dummyMessages(),
}

return &res, true, nil
}

ctx := context.Background()
query, err := p.EntClient.Block.Query().
Expand Down

0 comments on commit b360da7

Please sign in to comment.