-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,082 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
syntax = "proto3"; | ||
package zetachain.zetacore.lightclient; | ||
|
||
option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; | ||
|
||
// VerificationFlags is a structure containing information which chain types are enabled for block header verification | ||
message VerificationFlags { | ||
bool ethTypeChainEnabled = 1; | ||
bool btcTypeChainEnabled = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./chain_state_pb"; | ||
export * from "./genesis_pb"; | ||
export * from "./query_pb"; | ||
export * from "./verification_flags_pb"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" | ||
// @generated from file lightclient/verification_flags.proto (package zetachain.zetacore.lightclient, syntax proto3) | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
|
||
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; | ||
import { Message, proto3 } from "@bufbuild/protobuf"; | ||
|
||
/** | ||
* VerificationFlags is a structure containing information which chain types are enabled for block header verification | ||
* | ||
* @generated from message zetachain.zetacore.lightclient.VerificationFlags | ||
*/ | ||
export declare class VerificationFlags extends Message<VerificationFlags> { | ||
/** | ||
* @generated from field: bool ethTypeChainEnabled = 1; | ||
*/ | ||
ethTypeChainEnabled: boolean; | ||
|
||
/** | ||
* @generated from field: bool btcTypeChainEnabled = 2; | ||
*/ | ||
btcTypeChainEnabled: boolean; | ||
|
||
constructor(data?: PartialMessage<VerificationFlags>); | ||
|
||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "zetachain.zetacore.lightclient.VerificationFlags"; | ||
static readonly fields: FieldList; | ||
|
||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): VerificationFlags; | ||
|
||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): VerificationFlags; | ||
|
||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): VerificationFlags; | ||
|
||
static equals(a: VerificationFlags | PlainMessage<VerificationFlags> | undefined, b: VerificationFlags | PlainMessage<VerificationFlags> | undefined): boolean; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/zeta-chain/zetacore/x/lightclient/types" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
// VerificationFlags implements the Query/VerificationFlags gRPC method | ||
func (k Keeper) VerificationFlags(c context.Context, req *types.QueryVerificationFlagsRequest) (*types.QueryVerificationFlagsResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "invalid request") | ||
} | ||
ctx := sdk.UnwrapSDKContext(c) | ||
|
||
val, found := k.GetVerificationFlags(ctx) | ||
if !found { | ||
return nil, status.Error(codes.NotFound, "not found") | ||
} | ||
|
||
return &types.QueryVerificationFlagsResponse{VerificationFlags: val}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/store/prefix" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/zeta-chain/zetacore/x/lightclient/types" | ||
) | ||
|
||
// SetVerificationFlags set the verification flags in the store | ||
func (k Keeper) SetVerificationFlags(ctx sdk.Context, crosschainFlags types.VerificationFlags) { | ||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) | ||
b := k.cdc.MustMarshal(&crosschainFlags) | ||
store.Set([]byte{0}, b) | ||
} | ||
|
||
// GetVerificationFlags returns the verification flags | ||
func (k Keeper) GetVerificationFlags(ctx sdk.Context) (val types.VerificationFlags, found bool) { | ||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) | ||
|
||
b := store.Get([]byte{0}) | ||
if b == nil { | ||
return val, false | ||
} | ||
|
||
k.cdc.MustUnmarshal(b, &val) | ||
return val, true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.