-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use onion sequence in signature verification and onion sing
- Loading branch information
1 parent
af7c748
commit 9d31ece
Showing
14 changed files
with
1,226 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
syntax = "proto3"; | ||
package kujira.onion; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "kujira/onion/genesis.proto"; | ||
|
||
option go_package = "github.com/Team-Kujira/core/x/onion/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
rpc Sequence(QuerySequenceRequest) returns (QuerySequenceResponse) { | ||
option (google.api.http).get = "/kujira/onion/sequence/{address}"; | ||
} | ||
} | ||
|
||
message QuerySequenceRequest { string address = 1; } | ||
message QuerySequenceResponse { | ||
OnionSequence seq = 1 [ (gogoproto.nullable) = false ]; | ||
} |
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
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,20 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/Team-Kujira/core/x/onion/types" | ||
) | ||
|
||
var _ types.QueryServer = Keeper{} | ||
|
||
func (k Keeper) Sequence(c context.Context, req *types.QuerySequenceRequest) (*types.QuerySequenceResponse, error) { | ||
ctx := sdk.UnwrapSDKContext(c) | ||
seq, err := k.GetSequence(ctx, req.Address) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &types.QuerySequenceResponse{Seq: seq}, 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,59 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/store/prefix" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/gogoproto/proto" | ||
|
||
"github.com/Team-Kujira/core/x/onion/types" | ||
) | ||
|
||
// GetAuthorityMetadata returns the authority metadata for a specific denom | ||
func (k Keeper) GetSequence(ctx sdk.Context, address string) (types.OnionSequence, error) { | ||
store := ctx.KVStore(k.storeKey) | ||
prefixStore := prefix.NewStore(store, []byte(types.OnionSequencePrefix)) | ||
bz := prefixStore.Get([]byte(address)) | ||
if bz == nil { | ||
return types.OnionSequence{ | ||
Address: address, | ||
Sequence: 0, | ||
}, nil | ||
} | ||
sequence := types.OnionSequence{} | ||
err := proto.Unmarshal(bz, &sequence) | ||
if err != nil { | ||
return types.OnionSequence{}, err | ||
} | ||
return sequence, nil | ||
} | ||
|
||
// SetAuthorityMetadata stores authority metadata for a specific denom | ||
func (k Keeper) SetSequence(ctx sdk.Context, sequence types.OnionSequence) error { | ||
store := ctx.KVStore(k.storeKey) | ||
prefixStore := prefix.NewStore(store, []byte(types.OnionSequencePrefix)) | ||
|
||
bz, err := proto.Marshal(&sequence) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
prefixStore.Set([]byte(sequence.Address), bz) | ||
return nil | ||
} | ||
|
||
func (k Keeper) GetAllSequences(ctx sdk.Context) []types.OnionSequence { | ||
store := ctx.KVStore(k.storeKey) | ||
iterator := sdk.KVStorePrefixIterator(store, []byte{}) | ||
defer iterator.Close() | ||
|
||
sequences := []types.OnionSequence{} | ||
for ; iterator.Valid(); iterator.Next() { | ||
sequence := types.OnionSequence{} | ||
err := proto.Unmarshal(iterator.Value(), &sequence) | ||
if err != nil { | ||
panic(err) | ||
} | ||
sequences = append(sequences, sequence) | ||
} | ||
return sequences | ||
} |
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.