refactor(proto): remove macaroon proto

This commit is contained in:
Prad Nukala 2024-11-01 14:42:08 -04:00
parent 5b85868993
commit 388ca462a4
43 changed files with 53 additions and 7147 deletions

View File

@ -148,9 +148,6 @@ import (
did "github.com/onsonr/sonr/x/did" did "github.com/onsonr/sonr/x/did"
didkeeper "github.com/onsonr/sonr/x/did/keeper" didkeeper "github.com/onsonr/sonr/x/did/keeper"
didtypes "github.com/onsonr/sonr/x/did/types" didtypes "github.com/onsonr/sonr/x/did/types"
macaroon "github.com/onsonr/sonr/x/macaroon"
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
macaroontypes "github.com/onsonr/sonr/x/macaroon/types"
service "github.com/onsonr/sonr/x/service" service "github.com/onsonr/sonr/x/service"
servicekeeper "github.com/onsonr/sonr/x/service/keeper" servicekeeper "github.com/onsonr/sonr/x/service/keeper"
servicetypes "github.com/onsonr/sonr/x/service/types" servicetypes "github.com/onsonr/sonr/x/service/types"
@ -236,7 +233,6 @@ type SonrApp struct {
UpgradeKeeper *upgradekeeper.Keeper UpgradeKeeper *upgradekeeper.Keeper
legacyAmino *codec.LegacyAmino legacyAmino *codec.LegacyAmino
VaultKeeper vaultkeeper.Keeper VaultKeeper vaultkeeper.Keeper
MacaroonKeeper macaroonkeeper.Keeper
ServiceKeeper servicekeeper.Keeper ServiceKeeper servicekeeper.Keeper
sm *module.SimulationManager sm *module.SimulationManager
BasicModuleManager module.BasicManager BasicModuleManager module.BasicManager
@ -371,7 +367,6 @@ func NewChainApp(
packetforwardtypes.StoreKey, packetforwardtypes.StoreKey,
didtypes.StoreKey, didtypes.StoreKey,
vaulttypes.StoreKey, vaulttypes.StoreKey,
macaroontypes.StoreKey,
servicetypes.StoreKey, servicetypes.StoreKey,
) )
@ -632,16 +627,6 @@ func NewChainApp(
app.StakingKeeper, app.StakingKeeper,
) )
// Create the macaroon Keeper
app.MacaroonKeeper = macaroonkeeper.NewKeeper(
appCodec,
sdkruntime.NewKVStoreService(keys[macaroontypes.StoreKey]),
logger,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
app.AccountKeeper,
app.DidKeeper,
)
// Create the vault Keeper // Create the vault Keeper
app.VaultKeeper = vaultkeeper.NewKeeper( app.VaultKeeper = vaultkeeper.NewKeeper(
appCodec, appCodec,
@ -650,7 +635,6 @@ func NewChainApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(), authtypes.NewModuleAddress(govtypes.ModuleName).String(),
app.AccountKeeper, app.AccountKeeper,
app.DidKeeper, app.DidKeeper,
app.MacaroonKeeper,
) )
// Create the service Keeper // Create the service Keeper
@ -661,7 +645,6 @@ func NewChainApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(), authtypes.NewModuleAddress(govtypes.ModuleName).String(),
app.DidKeeper, app.DidKeeper,
app.GroupKeeper, app.GroupKeeper,
app.MacaroonKeeper,
app.NFTKeeper, app.NFTKeeper,
app.VaultKeeper, app.VaultKeeper,
) )
@ -924,10 +907,9 @@ func NewChainApp(
did.NewAppModule(appCodec, app.DidKeeper, app.NFTKeeper), did.NewAppModule(appCodec, app.DidKeeper, app.NFTKeeper),
macaroon.NewAppModule(appCodec, app.MacaroonKeeper, app.DidKeeper),
vault.NewAppModule(appCodec, app.VaultKeeper, app.DidKeeper), vault.NewAppModule(appCodec, app.VaultKeeper, app.DidKeeper),
service.NewAppModule(appCodec, app.ServiceKeeper, app.DidKeeper, app.MacaroonKeeper), service.NewAppModule(appCodec, app.ServiceKeeper, app.DidKeeper),
) )
// BasicModuleManager defines the module BasicManager is in charge of setting up basic, // BasicModuleManager defines the module BasicManager is in charge of setting up basic,
@ -977,7 +959,6 @@ func NewChainApp(
packetforwardtypes.ModuleName, packetforwardtypes.ModuleName,
didtypes.ModuleName, didtypes.ModuleName,
vaulttypes.ModuleName, vaulttypes.ModuleName,
macaroontypes.ModuleName,
servicetypes.ModuleName, servicetypes.ModuleName,
) )
@ -999,7 +980,6 @@ func NewChainApp(
packetforwardtypes.ModuleName, packetforwardtypes.ModuleName,
didtypes.ModuleName, didtypes.ModuleName,
vaulttypes.ModuleName, vaulttypes.ModuleName,
macaroontypes.ModuleName,
servicetypes.ModuleName, servicetypes.ModuleName,
) )
@ -1030,7 +1010,6 @@ func NewChainApp(
packetforwardtypes.ModuleName, packetforwardtypes.ModuleName,
didtypes.ModuleName, didtypes.ModuleName,
vaulttypes.ModuleName, vaulttypes.ModuleName,
macaroontypes.ModuleName,
servicetypes.ModuleName, servicetypes.ModuleName,
} }
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...) app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
@ -1491,7 +1470,6 @@ func initParamsKeeper(
WithKeyTable(packetforwardtypes.ParamKeyTable()) WithKeyTable(packetforwardtypes.ParamKeyTable())
paramsKeeper.Subspace(didtypes.ModuleName) paramsKeeper.Subspace(didtypes.ModuleName)
paramsKeeper.Subspace(vaulttypes.ModuleName) paramsKeeper.Subspace(vaulttypes.ModuleName)
paramsKeeper.Subspace(macaroontypes.ModuleName)
paramsKeeper.Subspace(servicetypes.ModuleName) paramsKeeper.Subspace(servicetypes.ModuleName)
return paramsKeeper return paramsKeeper

View File

@ -104,6 +104,37 @@ message Controller {
int64 creation_block = 9; int64 creation_block = 9;
} }
// Grant is a Grant message type.
message Grant {
option (cosmos.orm.v1.table) = {
id : 1
primary_key : {fields : "id" auto_increment : true}
index : {id : 1 fields : "subject,origin" unique : true}
};
uint64 id = 1;
string controller = 2;
string subject = 3;
string origin = 4;
int64 expiry_height = 5;
}
// Macaroon is a Macaroon message type.
message Macaroon {
option (cosmos.orm.v1.table) = {
id : 2
primary_key : {fields : "id" auto_increment : true}
index : {id : 1 fields : "subject,origin" unique : true}
};
uint64 id = 1;
string controller = 2;
string subject = 3;
string origin = 4;
int64 expiry_height = 5;
string macaroon = 6;
}
// Verification represents a verification method // Verification represents a verification method
message Verification { message Verification {
option (cosmos.orm.v1.table) = { option (cosmos.orm.v1.table) = {

View File

@ -1,11 +0,0 @@
syntax = "proto3";
package onsonr.sonr.macaroon.module.v1;
import "cosmos/app/v1alpha1/module.proto";
// Module is the app config object of the module.
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
message Module {
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/onsonr/sonr/x/macaroon"};
}

View File

@ -1,62 +0,0 @@
syntax = "proto3";
package macaroon.v1;
import "amino/amino.proto";
import "did/v1/tx.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/sonr/x/macaroon/types";
// GenesisState defines the module genesis state
message GenesisState {
// Params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
}
// Params defines the set of module parameters.
message Params {
option (amino.name) = "macaroon/params";
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;
// The list of methods
Methods methods = 1;
// The list of scopes
Scopes scopes = 2;
// The list of caveats
Caveats caveats = 3;
}
// Methods defines the available DID methods
message Methods {
option (amino.name) = "macaroon/methods";
option (gogoproto.equal) = true;
string default = 1;
repeated string supported = 2;
}
// Scopes defines the set of scopes
message Scopes {
option (amino.name) = "macaroon/scopes";
option (gogoproto.equal) = true;
string base = 1;
repeated string supported = 2;
}
// Caveats defines the available caveats
message Caveats {
option (amino.name) = "macaroon/caveats";
option (gogoproto.equal) = true;
repeated Caveat supported_first_party = 1;
repeated Caveat supported_third_party = 2;
}
// Caveat defines the caveat
message Caveat {
repeated string scopes = 1;
string caveat = 2;
string description = 3;
}

View File

@ -1,64 +0,0 @@
syntax = "proto3";
package macaroon.v1;
import "google/api/annotations.proto";
import "macaroon/v1/genesis.proto";
option go_package = "github.com/onsonr/sonr/x/macaroon/types";
// Query provides defines the gRPC querier service.
service Query {
// Params queries all parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/macaroon/v1/params";
}
// RefreshToken refreshes a macaroon token as post authentication.
rpc RefreshToken(QueryRefreshTokenRequest)
returns (QueryRefreshTokenResponse) {
option (google.api.http).post = "/macaroon/v1/refresh";
}
// ValidateToken validates a macaroon token as pre authentication.
rpc ValidateToken(QueryValidateTokenRequest)
returns (QueryValidateTokenResponse) {
option (google.api.http).post = "/macaroon/v1/validate";
}
}
// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1;
}
// QueryRefreshTokenRequest is the request type for the Query/RefreshToken RPC
// method.
message QueryRefreshTokenRequest {
// The macaroon token to refresh
string token = 1;
}
// QueryRefreshTokenResponse is the response type for the Query/RefreshToken
// RPC method.
message QueryRefreshTokenResponse {
// The macaroon token
string token = 1;
}
// QueryValidateTokenRequest is the request type for the Query/ValidateToken
// RPC method.
message QueryValidateTokenRequest {
// The macaroon token to validate
string token = 1;
}
// QueryValidateTokenResponse is the response type for the Query/ValidateToken
// RPC method.
message QueryValidateTokenResponse {
// The macaroon token
bool valid = 1;
}

View File

@ -1,39 +0,0 @@
syntax = "proto3";
package macaroon.v1;
import "cosmos/orm/v1/orm.proto";
option go_package = "github.com/onsonr/sonr/x/macaroon/types";
// https://github.com/cosmos/cosmos-sdk/blob/main/orm/README.md
// Grant is a Grant message type.
message Grant {
option (cosmos.orm.v1.table) = {
id : 1
primary_key : {fields : "id" auto_increment : true}
index : {id : 1 fields : "subject,origin" unique : true}
};
uint64 id = 1;
string controller = 2;
string subject = 3;
string origin = 4;
int64 expiry_height = 5;
}
// Macaroon is a Macaroon message type.
message Macaroon {
option (cosmos.orm.v1.table) = {
id : 2
primary_key : {fields : "id" auto_increment : true}
index : {id : 1 fields : "subject,origin" unique : true}
};
uint64 id = 1;
string controller = 2;
string subject = 3;
string origin = 4;
int64 expiry_height = 5;
string macaroon = 6;
}

View File

@ -1,66 +0,0 @@
syntax = "proto3";
package macaroon.v1;
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "macaroon/v1/genesis.proto";
option go_package = "github.com/onsonr/sonr/x/macaroon/types";
// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;
// UpdateParams defines a governance operation for updating the parameters.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
// IssueMacaroon asserts the given controller is the owner of the given
// address.
rpc IssueMacaroon(MsgIssueMacaroon) returns (MsgIssueMacaroonResponse);
}
// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// params defines the parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [ (gogoproto.nullable) = false ];
}
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParamsResponse {}
// MsgIssueMacaroon is the message type for the IssueMacaroon RPC.
message MsgIssueMacaroon {
option (cosmos.msg.v1.signer) = "controller";
// Controller is the address of the controller to authenticate.
string controller = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// Origin is the origin of the request in wildcard form.
string origin = 2;
// Permissions is the scope of the service.
map<string, string> permissions = 3;
// token is the macron token to authenticate the operation.
string token = 4;
}
// MsgIssueMacaroonResponse is the response type for the IssueMacaroon
// RPC.
message MsgIssueMacaroonResponse {
bool success = 1;
string token = 2;
}

View File

@ -1,104 +0,0 @@
# `x/macaroon`
The Macaroon module is responsible for providing decentralized access control and service authorization for the Sonr ecosystem. It implements macaroon-based authentication and authorization mechanisms.
## Concepts
Macaroons are a type of bearer credential that allow for decentralized delegation, attenuation, and third-party caveats. This module implements the core functionality for creating, validating, and managing macaroons within the Sonr ecosystem.
## State
The module maintains the following state:
### Grant
Represents a permission grant with the following fields:
- `id`: Unique identifier (auto-incremented)
- `controller`: Address of the controller
- `subject`: Subject of the grant
- `origin`: Origin of the grant
- `expiry_height`: Block height at which the grant expires
### Macaroon
Represents a macaroon token with the following fields:
- `id`: Unique identifier (auto-incremented)
- `controller`: Address of the controller
- `subject`: Subject of the macaroon
- `origin`: Origin of the macaroon
- `expiry_height`: Block height at which the macaroon expires
- `macaroon`: The actual macaroon token
## State Transitions
State transitions occur through the following messages:
- `MsgUpdateParams`: Updates the module parameters
- `MsgIssueMacaroon`: Issues a new macaroon
## Messages
### MsgUpdateParams
Updates the module parameters. Can only be executed by the governance account.
Fields:
- `authority`: Address of the governance account
- `params`: New parameter values
### MsgIssueMacaroon
Issues a new macaroon for a given controller and origin.
Fields:
- `controller`: Address of the controller
- `origin`: Origin of the request in wildcard form
- `permissions`: Map of permissions
- `token`: Macaroon token to authenticate the operation
## Queries
The module provides the following queries:
- `Params`: Retrieves the current module parameters
- `RefreshToken`: Refreshes a macaroon token (post-authentication)
- `ValidateToken`: Validates a macaroon token (pre-authentication)
## Parameters
The module has the following parameters:
- `methods`: Defines the available DID methods
- `default`: Default method
- `supported`: List of supported methods
- `scopes`: Defines the set of scopes
- `base`: Base scope
- `supported`: List of supported scopes
- `caveats`: Defines the available caveats
- `supported_first_party`: List of supported first-party caveats
- `supported_third_party`: List of supported third-party caveats
- `transactions`: Defines the allowlist and denylist for transactions
- `allowlist`: List of allowed transactions
- `denylist`: List of denied transactions
## Events
The module may emit events related to macaroon issuance, validation, and refreshing. (Specific event details to be implemented)
## Client
The module provides gRPC endpoints for all queries and message types defined in the protobuf files.
## Future Improvements
- Implement more advanced caveat types
- Add support for third-party caveats
- Enhance macaroon revocation mechanisms
- Implement additional security features and checks
## Tests
(To be implemented: Acceptance tests for the module's functionality)
## Appendix
For more information on macaroons and their implementation, refer to the original macaroon paper: "Macaroons: Cookies with Contextual Caveats for Decentralized Authorization in the Cloud" by Arnar Birgisson, et al.

View File

@ -1,31 +0,0 @@
package module
import (
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
modulev1 "github.com/onsonr/sonr/api/macaroon/v1"
)
// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Query: &autocliv1.ServiceCommandDescriptor{
Service: modulev1.Query_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Params",
Use: "params",
Short: "Query the current consensus parameters",
},
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: modulev1.Msg_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "UpdateParams",
Skip: false, // set to true if authority gated
},
},
},
}
}

View File

@ -1,50 +0,0 @@
package cli
import (
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/onsonr/sonr/x/macaroon/types"
)
// !NOTE: Must enable in module.go (disabled in favor of autocli.go)
func GetQueryCmd() *cobra.Command {
queryCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Querying commands for " + types.ModuleName,
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
queryCmd.AddCommand(
GetCmdParams(),
)
return queryCmd
}
func GetCmdParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Show all module params",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}

View File

@ -1,69 +0,0 @@
package cli
import (
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/onsonr/sonr/x/macaroon/types"
)
// !NOTE: Must enable in module.go (disabled in favor of autocli.go)
// NewTxCmd returns a root CLI command handler for certain modules
// transaction commands.
func NewTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: types.ModuleName,
Short: types.ModuleName + " subcommands.",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
txCmd.AddCommand(
MsgUpdateParams(),
)
return txCmd
}
// Returns a CLI command handler for registering a
// contract for the module.
func MsgUpdateParams() *cobra.Command {
cmd := &cobra.Command{
Use: "update-params [some-value]",
Short: "Update the params (must be submitted from the authority)",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
senderAddress := cliCtx.GetFromAddress()
//
// someValue, err := strconv.ParseBool(args[0])
// if err != nil {
// return err
// }
msg := &types.MsgUpdateParams{
Authority: senderAddress.String(),
Params: types.Params{
// SomeValue: someValue,
},
}
if err := msg.Validate(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}

View File

@ -1,65 +0,0 @@
package module
import (
"os"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
modulev1 "github.com/onsonr/sonr/api/macaroon/module/v1"
didkeeper "github.com/onsonr/sonr/x/did/keeper"
"github.com/onsonr/sonr/x/macaroon/keeper"
)
var _ appmodule.AppModule = AppModule{}
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (am AppModule) IsOnePerModuleType() {}
// IsAppModule implements the appmodule.AppModule interface.
func (am AppModule) IsAppModule() {}
func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(ProvideModule),
)
}
type ModuleInputs struct {
depinject.In
Cdc codec.Codec
StoreService store.KVStoreService
AddressCodec address.Codec
AccountKeeper authkeeper.AccountKeeper
DidKeeper didkeeper.Keeper
StakingKeeper stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
}
type ModuleOutputs struct {
depinject.Out
Module appmodule.AppModule
Keeper keeper.Keeper
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr, in.AccountKeeper, in.DidKeeper)
m := NewAppModule(in.Cdc, k, in.DidKeeper)
return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}}
}

View File

@ -1,37 +0,0 @@
package keeper
import (
"context"
"cosmossdk.io/log"
"github.com/onsonr/sonr/x/macaroon/types"
)
func (k Keeper) Logger() log.Logger {
return k.logger
}
// InitGenesis initializes the module's state from a genesis state.
func (k *Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error {
// this line is used by starport scaffolding # genesis/module/init
if err := data.Params.Validate(); err != nil {
return err
}
return k.Params.Set(ctx, data.Params)
}
// ExportGenesis exports the module's state to a genesis state.
func (k *Keeper) ExportGenesis(ctx context.Context) *types.GenesisState {
params, err := k.Params.Get(ctx)
if err != nil {
panic(err)
}
// this line is used by starport scaffolding # genesis/module/export
return &types.GenesisState{
Params: params,
}
}

View File

@ -1,25 +0,0 @@
package keeper_test
import (
"testing"
"github.com/onsonr/sonr/x/macaroon/types"
"github.com/stretchr/testify/require"
)
func TestGenesis(t *testing.T) {
f := SetupTest(t)
genesisState := &types.GenesisState{
Params: types.DefaultParams(),
// this line is used by starport scaffolding # genesis/test/state
}
f.k.InitGenesis(f.ctx, genesisState)
got := f.k.ExportGenesis(f.ctx)
require.NotNil(t, got)
// this line is used by starport scaffolding # genesis/test/assert
}

View File

@ -1,82 +0,0 @@
package keeper
import (
"cosmossdk.io/collections"
storetypes "cosmossdk.io/core/store"
"cosmossdk.io/log"
"cosmossdk.io/orm/model/ormdb"
"github.com/cosmos/cosmos-sdk/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
apiv1 "github.com/onsonr/sonr/api/macaroon/v1"
didkeeper "github.com/onsonr/sonr/x/did/keeper"
"github.com/onsonr/sonr/x/macaroon/types"
)
type Keeper struct {
cdc codec.BinaryCodec
logger log.Logger
// state management
Schema collections.Schema
Params collections.Item[types.Params]
OrmDB apiv1.StateStore
AccountKeeper authkeeper.AccountKeeper
DIDKeeper didkeeper.Keeper
authority string
}
// NewKeeper creates a new Keeper instance
func NewKeeper(
cdc codec.BinaryCodec,
storeService storetypes.KVStoreService,
logger log.Logger,
authority string,
accKeeper authkeeper.AccountKeeper,
didKeeper didkeeper.Keeper,
) Keeper {
logger = logger.With(log.ModuleKey, "x/"+types.ModuleName)
sb := collections.NewSchemaBuilder(storeService)
if authority == "" {
authority = authtypes.NewModuleAddress(govtypes.ModuleName).String()
}
db, err := ormdb.NewModuleDB(&types.ORMModuleSchema, ormdb.ModuleDBOptions{KVStoreService: storeService})
if err != nil {
panic(err)
}
store, err := apiv1.NewStateStore(db)
if err != nil {
panic(err)
}
k := Keeper{
cdc: cdc,
logger: logger,
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
OrmDB: store,
AccountKeeper: accKeeper,
DIDKeeper: didKeeper,
authority: authority,
}
schema, err := sb.Build()
if err != nil {
panic(err)
}
k.Schema = schema
return k
}

View File

@ -1,141 +0,0 @@
package keeper_test
import (
"testing"
"cosmossdk.io/core/store"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
didkeeper "github.com/onsonr/sonr/x/did/keeper"
module "github.com/onsonr/sonr/x/macaroon"
"github.com/onsonr/sonr/x/macaroon/keeper"
"github.com/onsonr/sonr/x/macaroon/types"
)
var maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
minttypes.ModuleName: {authtypes.Minter},
govtypes.ModuleName: {authtypes.Burner},
}
type testFixture struct {
suite.Suite
ctx sdk.Context
k keeper.Keeper
msgServer types.MsgServer
queryServer types.QueryServer
appModule *module.AppModule
accountkeeper authkeeper.AccountKeeper
didk didkeeper.Keeper
bankkeeper bankkeeper.BaseKeeper
stakingKeeper *stakingkeeper.Keeper
mintkeeper mintkeeper.Keeper
addrs []sdk.AccAddress
govModAddr string
}
func SetupTest(t *testing.T) *testFixture {
t.Helper()
f := new(testFixture)
require := require.New(t)
// Base setup
logger := log.NewTestLogger(t)
encCfg := moduletestutil.MakeTestEncodingConfig()
f.govModAddr = authtypes.NewModuleAddress(govtypes.ModuleName).String()
f.addrs = simtestutil.CreateIncrementalAccounts(3)
key := storetypes.NewKVStoreKey(types.ModuleName)
storeService := runtime.NewKVStoreService(key)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
f.ctx = testCtx.Ctx
// Register SDK modules.
registerBaseSDKModules(f, encCfg, storeService, logger, require)
// Setup Keeper.
f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr, f.accountkeeper, f.didk)
f.msgServer = keeper.NewMsgServerImpl(f.k)
f.queryServer = keeper.NewQuerier(f.k)
f.appModule = module.NewAppModule(encCfg.Codec, f.k, f.didk)
return f
}
func registerModuleInterfaces(encCfg moduletestutil.TestEncodingConfig) {
authtypes.RegisterInterfaces(encCfg.InterfaceRegistry)
stakingtypes.RegisterInterfaces(encCfg.InterfaceRegistry)
types.RegisterInterfaces(encCfg.InterfaceRegistry)
}
func registerBaseSDKModules(
f *testFixture,
encCfg moduletestutil.TestEncodingConfig,
storeService store.KVStoreService,
logger log.Logger,
require *require.Assertions,
) {
registerModuleInterfaces(encCfg)
// Auth Keeper.
f.accountkeeper = authkeeper.NewAccountKeeper(
encCfg.Codec, storeService,
authtypes.ProtoBaseAccount,
maccPerms,
authcodec.NewBech32Codec(sdk.Bech32MainPrefix), sdk.Bech32MainPrefix,
f.govModAddr,
)
// Bank Keeper.
f.bankkeeper = bankkeeper.NewBaseKeeper(
encCfg.Codec, storeService,
f.accountkeeper,
nil,
f.govModAddr, logger,
)
// Staking Keeper.
f.stakingKeeper = stakingkeeper.NewKeeper(
encCfg.Codec, storeService,
f.accountkeeper, f.bankkeeper, f.govModAddr,
authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr),
authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
)
require.NoError(f.stakingKeeper.SetParams(f.ctx, stakingtypes.DefaultParams()))
f.accountkeeper.SetModuleAccount(f.ctx, f.stakingKeeper.GetNotBondedPool(f.ctx))
f.accountkeeper.SetModuleAccount(f.ctx, f.stakingKeeper.GetBondedPool(f.ctx))
// Mint Keeper.
f.mintkeeper = mintkeeper.NewKeeper(
encCfg.Codec, storeService,
f.stakingKeeper, f.accountkeeper, f.bankkeeper,
authtypes.FeeCollectorName, f.govModAddr,
)
f.accountkeeper.SetModuleAccount(f.ctx, f.accountkeeper.GetModuleAccount(f.ctx, minttypes.ModuleName))
f.mintkeeper.InitGenesis(f.ctx, f.accountkeeper, minttypes.DefaultGenesisState())
}

View File

@ -1,30 +0,0 @@
package keeper_test
import (
"testing"
)
func TestORM(t *testing.T) {
f := SetupTest(t)
if f == nil {
t.FailNow()
}
// dt := f.k.OrmDB.ExampleDataTable()
// acc := []byte("test_acc")
// amt := uint64(7)
//
// err := dt.Insert(f.ctx, &apiv1.ExampleData{
// Account: acc,
// Amount: amt,
// })
// require.NoError(t, err)
//
// d, err := dt.Has(f.ctx, []byte("test_acc"))
// require.NoError(t, err)
// require.True(t, d)
//
// res, err := dt.Get(f.ctx, []byte("test_acc"))
// require.NoError(t, err)
// require.NotNil(t, res)
// require.EqualValues(t, amt, res.Amount)
}

View File

@ -1,42 +0,0 @@
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/onsonr/sonr/x/macaroon/types"
)
var _ types.QueryServer = Querier{}
type Querier struct {
Keeper
}
func NewQuerier(keeper Keeper) Querier {
return Querier{Keeper: keeper}
}
func (k Querier) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
p, err := k.Keeper.Params.Get(ctx)
if err != nil {
return nil, err
}
return &types.QueryParamsResponse{Params: &p}, nil
}
// RefreshToken implements types.QueryServer.
func (k Querier) RefreshToken(goCtx context.Context, req *types.QueryRefreshTokenRequest) (*types.QueryRefreshTokenResponse, error) {
// ctx := sdk.UnwrapSDKContext(goCtx)
return &types.QueryRefreshTokenResponse{}, nil
}
// ValidateToken implements types.QueryServer.
func (k Querier) ValidateToken(goCtx context.Context, req *types.QueryValidateTokenRequest) (*types.QueryValidateTokenResponse, error) {
// ctx := sdk.UnwrapSDKContext(goCtx)
return &types.QueryValidateTokenResponse{}, nil
}

View File

@ -1,41 +0,0 @@
package keeper
import (
"context"
"cosmossdk.io/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/onsonr/sonr/x/macaroon/types"
)
type msgServer struct {
k Keeper
}
var _ types.MsgServer = msgServer{}
// NewMsgServerImpl returns an implementation of the module MsgServer interface.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{k: keeper}
}
func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if ms.k.authority != msg.Authority {
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority)
}
return nil, ms.k.Params.Set(ctx, msg.Params)
}
// AuthorizeService implements types.MsgServer.
func (ms msgServer) AuthorizeService(ctx context.Context, msg *types.MsgIssueMacaroon) (*types.MsgIssueMacaroonResponse, error) {
// ctx := sdk.UnwrapSDKContext(goCtx)
return &types.MsgIssueMacaroonResponse{}, nil
}
// IssueMacaroon implements types.MsgServer.
func (ms msgServer) IssueMacaroon(ctx context.Context, msg *types.MsgIssueMacaroon) (*types.MsgIssueMacaroonResponse, error) {
// ctx := sdk.UnwrapSDKContext(goCtx)
return &types.MsgIssueMacaroonResponse{}, nil
}

View File

@ -1,56 +0,0 @@
package keeper_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/x/macaroon/types"
)
func TestParams(t *testing.T) {
f := SetupTest(t)
require := require.New(t)
testCases := []struct {
name string
request *types.MsgUpdateParams
err bool
}{
{
name: "fail; invalid authority",
request: &types.MsgUpdateParams{
Authority: f.addrs[0].String(),
Params: types.DefaultParams(),
},
err: true,
},
{
name: "success",
request: &types.MsgUpdateParams{
Authority: f.govModAddr,
Params: types.DefaultParams(),
},
err: false,
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
_, err := f.msgServer.UpdateParams(f.ctx, tc.request)
if tc.err {
require.Error(err)
} else {
require.NoError(err)
r, err := f.queryServer.Params(f.ctx, &types.QueryParamsRequest{})
require.NoError(err)
require.EqualValues(&tc.request.Params, r.Params)
}
})
}
}

View File

@ -1,149 +0,0 @@
package module
import (
"context"
"encoding/json"
"cosmossdk.io/client/v2/autocli"
errorsmod "cosmossdk.io/errors"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
didkeeper "github.com/onsonr/sonr/x/did/keeper"
"github.com/onsonr/sonr/x/macaroon/keeper"
"github.com/onsonr/sonr/x/macaroon/types"
)
const (
// ConsensusVersion defines the current x/macaroon module consensus version.
ConsensusVersion = 1
// this line is used by starport scaffolding # simapp/module/const
)
var (
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleGenesis = AppModule{}
_ module.AppModule = AppModule{}
_ autocli.HasAutoCLIConfig = AppModule{}
)
// AppModuleBasic defines the basic application module used by the wasm module.
type AppModuleBasic struct {
cdc codec.Codec
}
type AppModule struct {
AppModuleBasic
keeper keeper.Keeper
didk didkeeper.Keeper
}
// NewAppModule constructor
func NewAppModule(
cdc codec.Codec,
keeper keeper.Keeper,
didkeeper didkeeper.Keeper,
) *AppModule {
return &AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper,
didk: didkeeper,
}
}
func (a AppModuleBasic) Name() string {
return types.ModuleName
}
func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(&types.GenesisState{
Params: types.DefaultParams(),
})
}
func (a AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, _ client.TxEncodingConfig, message json.RawMessage) error {
var data types.GenesisState
err := marshaler.UnmarshalJSON(message, &data)
if err != nil {
return err
}
if err := data.Params.Validate(); err != nil {
return errorsmod.Wrap(err, "params")
}
return nil
}
func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {
}
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
if err != nil {
// same behavior as in cosmos-sdk
panic(err)
}
}
// Disable in favor of autocli.go. If you wish to use these, it will override AutoCLI methods.
/*
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.NewTxCmd()
}
func (a AppModuleBasic) GetQueryCmd() *cobra.Command {
return cli.GetQueryCmd()
}
*/
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
}
func (a AppModuleBasic) RegisterInterfaces(r codectypes.InterfaceRegistry) {
types.RegisterInterfaces(r)
}
func (a AppModule) InitGenesis(ctx sdk.Context, marshaler codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
marshaler.MustUnmarshalJSON(message, &genesisState)
if err := a.keeper.Params.Set(ctx, genesisState.Params); err != nil {
panic(err)
}
return nil
}
func (a AppModule) ExportGenesis(ctx sdk.Context, marshaler codec.JSONCodec) json.RawMessage {
genState := a.keeper.ExportGenesis(ctx)
return marshaler.MustMarshalJSON(genState)
}
func (a AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {
}
func (a AppModule) QuerierRoute() string {
return types.QuerierRoute
}
func (a AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(a.keeper))
types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(a.keeper))
}
// ConsensusVersion is a sequence number for state-breaking change of the
// module. It should be incremented on each consensus-breaking change
// introduced by the module. To avoid wrong/empty versions, the initial version
// should be set to 1.
func (a AppModule) ConsensusVersion() uint64 {
return ConsensusVersion
}

View File

@ -1,51 +0,0 @@
package types
import (
fmt "fmt"
"time"
)
const (
OriginMacroonCaveat MacroonCaveat = "origin"
ScopesMacroonCaveat MacroonCaveat = "scopes"
SubjectMacroonCaveat MacroonCaveat = "subject"
ExpMacroonCaveat MacroonCaveat = "exp"
TokenMacroonCaveat MacroonCaveat = "token"
)
var MacroonCaveats = []MacroonCaveat{OriginMacroonCaveat, ScopesMacroonCaveat, SubjectMacroonCaveat, ExpMacroonCaveat, TokenMacroonCaveat}
type MacroonCaveat string
func (c MacroonCaveat) Equal(other string) bool {
return string(c) == other
}
func (c MacroonCaveat) String() string {
return string(c)
}
func (c MacroonCaveat) Verify(value string) error {
switch c {
case OriginMacroonCaveat:
return nil
case ScopesMacroonCaveat:
return nil
case SubjectMacroonCaveat:
return nil
case ExpMacroonCaveat:
// Check if the expiration time is still valid
exp, err := time.Parse(time.RFC3339, value)
if err != nil {
return err
}
if time.Now().After(exp) {
return fmt.Errorf("expired")
}
return nil
case TokenMacroonCaveat:
return nil
default:
return fmt.Errorf("unknown caveat: %s", c)
}
}

View File

@ -1,37 +0,0 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
// this line is used by starport scaffolding # 1
)
var (
amino = codec.NewLegacyAmino()
AminoCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
}
// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgUpdateParams{}, ModuleName+"/MsgUpdateParams", nil)
}
func RegisterInterfaces(registry types.InterfaceRegistry) {
// this line is used by starport scaffolding # 3
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgUpdateParams{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

View File

@ -1,11 +0,0 @@
package types
import sdkerrors "cosmossdk.io/errors"
var (
ErrInvalidGenesisState = sdkerrors.Register(ModuleName, 100, "invalid genesis state")
ErrUnauthorizedMacaroonToken = sdkerrors.Register(ModuleName, 200, "unauthorized macaroon token")
ErrInvalidMacaroonScopes = sdkerrors.Register(ModuleName, 201, "invalid macaroon scopes")
ErrInvalidMacaroonController = sdkerrors.Register(ModuleName, 202, "invalid macaroon controller")
ErrInvalidTransactionSignature = sdkerrors.Register(ModuleName, 203, "invalid supplied transaction signature")
)

View File

@ -1 +0,0 @@
package types

View File

@ -1,22 +0,0 @@
package types
// this line is used by starport scaffolding # genesis/types/import
// DefaultIndex is the default global index
const DefaultIndex uint64 = 1
// DefaultGenesis returns the default genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{
// this line is used by starport scaffolding # genesis/types/default
Params: DefaultParams(),
}
}
// Validate performs basic genesis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {
// this line is used by starport scaffolding # genesis/types/validate
return gs.Params.Validate()
}

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +0,0 @@
package types_test
import (
"testing"
"github.com/onsonr/sonr/x/macaroon/types"
"github.com/stretchr/testify/require"
)
func TestGenesisState_Validate(t *testing.T) {
tests := []struct {
desc string
genState *types.GenesisState
valid bool
}{
{
desc: "default is valid",
genState: types.DefaultGenesis(),
valid: true,
},
{
desc: "valid genesis state",
genState: &types.GenesisState{
// this line is used by starport scaffolding # types/genesis/validField
},
valid: true,
},
// this line is used by starport scaffolding # types/genesis/testcase
}
for _, tc := range tests {
t.Run(tc.desc, func(t *testing.T) {
err := tc.genState.Validate()
if tc.valid {
require.NoError(t, err)
} else {
require.Error(t, err)
}
})
}
}

View File

@ -1,27 +0,0 @@
package types
import (
"cosmossdk.io/collections"
ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1"
)
var (
// ParamsKey saves the current module params.
ParamsKey = collections.NewPrefix(0)
)
const (
ModuleName = "macaroon"
StoreKey = ModuleName
QuerierRoute = ModuleName
)
var ORMModuleSchema = ormv1alpha1.ModuleSchemaDescriptor{
SchemaFile: []*ormv1alpha1.ModuleSchemaDescriptor_FileEntry{
{Id: 1, ProtoFileName: "macaroon/v1/state.proto"},
},
Prefix: []byte{0},
}

View File

@ -1,49 +0,0 @@
package types
import (
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ sdk.Msg = &MsgUpdateParams{}
// ╭───────────────────────────────────────────────────────────╮
// │ MsgUpdateParams type definition │
// ╰───────────────────────────────────────────────────────────╯
// NewMsgUpdateParams creates new instance of MsgUpdateParams
func NewMsgUpdateParams(
sender sdk.Address,
someValue bool,
) *MsgUpdateParams {
return &MsgUpdateParams{
Authority: sender.String(),
Params: Params{},
}
}
// Route returns the name of the module
func (msg MsgUpdateParams) Route() string { return ModuleName }
// Type returns the the action
func (msg MsgUpdateParams) Type() string { return "update_params" }
// GetSignBytes implements the LegacyMsg interface.
func (msg MsgUpdateParams) GetSignBytes() []byte {
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
}
// GetSigners returns the expected signers for a MsgUpdateParams message.
func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
return []sdk.AccAddress{addr}
}
// ValidateBasic does a sanity check on the provided data.
func (msg *MsgUpdateParams) Validate() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return errors.Wrap(err, "invalid authority address")
}
return msg.Params.Validate()
}

View File

@ -1,111 +0,0 @@
package types
import (
"encoding/json"
)
// DefaultParams returns default module parameters.
func DefaultParams() Params {
return Params{
Methods: DefaultMethods(),
Scopes: DefaultScopes(),
Caveats: DefaultCaveats(),
}
}
// Stringer method for Params.
func (p Params) String() string {
bz, err := json.Marshal(p)
if err != nil {
panic(err)
}
return string(bz)
}
// Validate does the sanity check on the params.
func (p Params) Validate() error {
return nil
}
func DefaultMethods() *Methods {
return &Methods{
Default: "did:sonr",
Supported: []string{"did:key", "did:web", "did:sonr", "did:ipfs", "did:btcr", "did:ethr"},
}
}
func DefaultScopes() *Scopes {
return &Scopes{
Base: "openid profile sonr.address",
Supported: []string{"create", "read", "update", "delete", "sign", "verify", "simulate", "execute", "broadcast", "admin"},
}
}
func DefaultCaveats() *Caveats {
return &Caveats{
// First party - JWT Format
SupportedFirstParty: DefaultFirstPartyCaveats(),
// Third party - UCAN Format
SupportedThirdParty: DefaultThirdPartyCaveats(),
}
}
func DefaultFirstPartyCaveats() []*Caveat {
return []*Caveat{
{
Scopes: []string{"openid", "profile", "sonr.address"},
Caveat: "aud",
Description: "Audience must be a valid DID",
},
{
Scopes: []string{"openid", "profile", "sonr.address"},
Caveat: "exp",
Description: "Expiration time must be a valid timestamp",
},
{
Scopes: []string{"openid", "profile", "sonr.address"},
Caveat: "iat",
Description: "Issued at time must be a valid timestamp",
},
{
Scopes: []string{"openid", "profile", "sonr.address"},
Caveat: "iss",
Description: "Issuer must be a valid DID",
},
{
Scopes: []string{"openid", "profile", "sonr.address"},
Caveat: "nbf",
Description: "Not before time must be a valid timestamp",
},
{
Scopes: []string{"openid", "profile", "sonr.address"},
Caveat: "nonce",
Description: "Nonce must be a valid string",
},
{
Scopes: []string{"openid", "profile", "sonr.address"},
Caveat: "sub",
Description: "Subject must be a valid DID",
},
}
}
func DefaultThirdPartyCaveats() []*Caveat {
return []*Caveat{
{
Scopes: []string{"create", "read", "update", "delete", "sign", "verify", "simulate", "execute", "broadcast", "admin"},
Caveat: "cap",
Description: "Capability must be a valid capability",
},
{
Scopes: []string{"create", "read", "update", "delete", "sign", "verify", "simulate", "execute", "broadcast", "admin"},
Caveat: "exp",
Description: "Expiration time must be a valid timestamp",
},
}
}
func (c *Caveat) Equal(other *Caveat) bool {
return c.Caveat == other.Caveat
}

File diff suppressed because it is too large Load Diff

View File

@ -1,319 +0,0 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: macaroon/v1/query.proto
/*
Package types is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package types
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var _ = metadata.Join
func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryParamsRequest
var metadata runtime.ServerMetadata
msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryParamsRequest
var metadata runtime.ServerMetadata
msg, err := server.Params(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Query_RefreshToken_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Query_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryRefreshTokenRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RefreshToken_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.RefreshToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryRefreshTokenRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RefreshToken_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.RefreshToken(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Query_ValidateToken_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Query_ValidateToken_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryValidateTokenRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ValidateToken_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ValidateToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_ValidateToken_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryValidateTokenRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ValidateToken_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ValidateToken(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Query_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_RefreshToken_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_RefreshToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Query_ValidateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_ValidateToken_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_ValidateToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterQueryHandler(ctx, mux, conn)
}
// RegisterQueryHandler registers the http handlers for service Query to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
}
// RegisterQueryHandlerClient registers the http handlers for service Query
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "QueryClient" to call the correct interceptors.
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Query_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_RefreshToken_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_RefreshToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Query_ValidateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_ValidateToken_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_ValidateToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"macaroon", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"macaroon", "v1", "refresh"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_ValidateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"macaroon", "v1", "validate"}, "", runtime.AssumeColonVerbOpt(false)))
)
var (
forward_Query_Params_0 = runtime.ForwardResponseMessage
forward_Query_RefreshToken_0 = runtime.ForwardResponseMessage
forward_Query_ValidateToken_0 = runtime.ForwardResponseMessage
)

View File

@ -1,890 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: macaroon/v1/state.proto
package types
import (
_ "cosmossdk.io/orm"
fmt "fmt"
proto "github.com/cosmos/gogoproto/proto"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type Grant struct {
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Controller string `protobuf:"bytes,2,opt,name=controller,proto3" json:"controller,omitempty"`
Subject string `protobuf:"bytes,3,opt,name=subject,proto3" json:"subject,omitempty"`
Origin string `protobuf:"bytes,4,opt,name=origin,proto3" json:"origin,omitempty"`
ExpiryHeight int64 `protobuf:"varint,5,opt,name=expiry_height,json=expiryHeight,proto3" json:"expiry_height,omitempty"`
}
func (m *Grant) Reset() { *m = Grant{} }
func (m *Grant) String() string { return proto.CompactTextString(m) }
func (*Grant) ProtoMessage() {}
func (*Grant) Descriptor() ([]byte, []int) {
return fileDescriptor_2ade56339acadfd8, []int{0}
}
func (m *Grant) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Grant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Grant.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Grant) XXX_Merge(src proto.Message) {
xxx_messageInfo_Grant.Merge(m, src)
}
func (m *Grant) XXX_Size() int {
return m.Size()
}
func (m *Grant) XXX_DiscardUnknown() {
xxx_messageInfo_Grant.DiscardUnknown(m)
}
var xxx_messageInfo_Grant proto.InternalMessageInfo
func (m *Grant) GetId() uint64 {
if m != nil {
return m.Id
}
return 0
}
func (m *Grant) GetController() string {
if m != nil {
return m.Controller
}
return ""
}
func (m *Grant) GetSubject() string {
if m != nil {
return m.Subject
}
return ""
}
func (m *Grant) GetOrigin() string {
if m != nil {
return m.Origin
}
return ""
}
func (m *Grant) GetExpiryHeight() int64 {
if m != nil {
return m.ExpiryHeight
}
return 0
}
type Macaroon struct {
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Controller string `protobuf:"bytes,2,opt,name=controller,proto3" json:"controller,omitempty"`
Subject string `protobuf:"bytes,3,opt,name=subject,proto3" json:"subject,omitempty"`
Origin string `protobuf:"bytes,4,opt,name=origin,proto3" json:"origin,omitempty"`
ExpiryHeight int64 `protobuf:"varint,5,opt,name=expiry_height,json=expiryHeight,proto3" json:"expiry_height,omitempty"`
Macaroon string `protobuf:"bytes,6,opt,name=macaroon,proto3" json:"macaroon,omitempty"`
}
func (m *Macaroon) Reset() { *m = Macaroon{} }
func (m *Macaroon) String() string { return proto.CompactTextString(m) }
func (*Macaroon) ProtoMessage() {}
func (*Macaroon) Descriptor() ([]byte, []int) {
return fileDescriptor_2ade56339acadfd8, []int{1}
}
func (m *Macaroon) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Macaroon) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Macaroon.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Macaroon) XXX_Merge(src proto.Message) {
xxx_messageInfo_Macaroon.Merge(m, src)
}
func (m *Macaroon) XXX_Size() int {
return m.Size()
}
func (m *Macaroon) XXX_DiscardUnknown() {
xxx_messageInfo_Macaroon.DiscardUnknown(m)
}
var xxx_messageInfo_Macaroon proto.InternalMessageInfo
func (m *Macaroon) GetId() uint64 {
if m != nil {
return m.Id
}
return 0
}
func (m *Macaroon) GetController() string {
if m != nil {
return m.Controller
}
return ""
}
func (m *Macaroon) GetSubject() string {
if m != nil {
return m.Subject
}
return ""
}
func (m *Macaroon) GetOrigin() string {
if m != nil {
return m.Origin
}
return ""
}
func (m *Macaroon) GetExpiryHeight() int64 {
if m != nil {
return m.ExpiryHeight
}
return 0
}
func (m *Macaroon) GetMacaroon() string {
if m != nil {
return m.Macaroon
}
return ""
}
func init() {
proto.RegisterType((*Grant)(nil), "macaroon.v1.Grant")
proto.RegisterType((*Macaroon)(nil), "macaroon.v1.Macaroon")
}
func init() { proto.RegisterFile("macaroon/v1/state.proto", fileDescriptor_2ade56339acadfd8) }
var fileDescriptor_2ade56339acadfd8 = []byte{
// 307 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0x4d, 0x4c, 0x4e,
0x2c, 0xca, 0xcf, 0xcf, 0xd3, 0x2f, 0x33, 0xd4, 0x2f, 0x2e, 0x49, 0x2c, 0x49, 0xd5, 0x2b, 0x28,
0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0x49, 0xe8, 0x95, 0x19, 0x4a, 0x89, 0x27, 0xe7, 0x17, 0xe7,
0xe6, 0x17, 0xeb, 0xe7, 0x17, 0xe5, 0x82, 0xd4, 0xe5, 0x17, 0xe5, 0x42, 0x54, 0x29, 0x6d, 0x63,
0xe4, 0x62, 0x75, 0x2f, 0x4a, 0xcc, 0x2b, 0x11, 0xe2, 0xe3, 0x62, 0xca, 0x4c, 0x91, 0x60, 0x54,
0x60, 0xd4, 0x60, 0x09, 0x62, 0xca, 0x4c, 0x11, 0x92, 0xe3, 0xe2, 0x4a, 0xce, 0xcf, 0x2b, 0x29,
0xca, 0xcf, 0xc9, 0x49, 0x2d, 0x92, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x0c, 0x42, 0x12, 0x11, 0x92,
0xe0, 0x62, 0x2f, 0x2e, 0x4d, 0xca, 0x4a, 0x4d, 0x2e, 0x91, 0x60, 0x06, 0x4b, 0xc2, 0xb8, 0x42,
0x62, 0x5c, 0x6c, 0xf9, 0x45, 0x99, 0xe9, 0x99, 0x79, 0x12, 0x2c, 0x60, 0x09, 0x28, 0x4f, 0x48,
0x99, 0x8b, 0x37, 0xb5, 0xa2, 0x20, 0xb3, 0xa8, 0x32, 0x3e, 0x23, 0x35, 0x33, 0x3d, 0xa3, 0x44,
0x82, 0x55, 0x81, 0x51, 0x83, 0x39, 0x88, 0x07, 0x22, 0xe8, 0x01, 0x16, 0xb3, 0x52, 0xfb, 0x34,
0xef, 0x72, 0x1f, 0xb3, 0x02, 0x17, 0x1b, 0xc8, 0x39, 0x02, 0x8c, 0x42, 0x22, 0x5c, 0x7c, 0x50,
0x73, 0x75, 0x20, 0xc6, 0x08, 0x30, 0x4a, 0x30, 0x4a, 0x30, 0x2a, 0x5d, 0x65, 0xe4, 0xe2, 0xf0,
0x85, 0xfa, 0x70, 0x90, 0xb8, 0x5d, 0x48, 0x8a, 0x8b, 0x03, 0x16, 0xe8, 0x12, 0x6c, 0x60, 0xed,
0x70, 0x3e, 0x91, 0xfe, 0x62, 0x72, 0x72, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6,
0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39,
0x86, 0x28, 0xf5, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xfc, 0xbc,
0xe2, 0xfc, 0xbc, 0x22, 0x7d, 0x30, 0x51, 0xa1, 0x0f, 0x4f, 0x02, 0x25, 0x95, 0x05, 0xa9, 0xc5,
0x49, 0x6c, 0xe0, 0xa8, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x46, 0x4a, 0xd1, 0x1b,
0x02, 0x00, 0x00,
}
func (m *Grant) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Grant) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Grant) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.ExpiryHeight != 0 {
i = encodeVarintState(dAtA, i, uint64(m.ExpiryHeight))
i--
dAtA[i] = 0x28
}
if len(m.Origin) > 0 {
i -= len(m.Origin)
copy(dAtA[i:], m.Origin)
i = encodeVarintState(dAtA, i, uint64(len(m.Origin)))
i--
dAtA[i] = 0x22
}
if len(m.Subject) > 0 {
i -= len(m.Subject)
copy(dAtA[i:], m.Subject)
i = encodeVarintState(dAtA, i, uint64(len(m.Subject)))
i--
dAtA[i] = 0x1a
}
if len(m.Controller) > 0 {
i -= len(m.Controller)
copy(dAtA[i:], m.Controller)
i = encodeVarintState(dAtA, i, uint64(len(m.Controller)))
i--
dAtA[i] = 0x12
}
if m.Id != 0 {
i = encodeVarintState(dAtA, i, uint64(m.Id))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func (m *Macaroon) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Macaroon) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Macaroon) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Macaroon) > 0 {
i -= len(m.Macaroon)
copy(dAtA[i:], m.Macaroon)
i = encodeVarintState(dAtA, i, uint64(len(m.Macaroon)))
i--
dAtA[i] = 0x32
}
if m.ExpiryHeight != 0 {
i = encodeVarintState(dAtA, i, uint64(m.ExpiryHeight))
i--
dAtA[i] = 0x28
}
if len(m.Origin) > 0 {
i -= len(m.Origin)
copy(dAtA[i:], m.Origin)
i = encodeVarintState(dAtA, i, uint64(len(m.Origin)))
i--
dAtA[i] = 0x22
}
if len(m.Subject) > 0 {
i -= len(m.Subject)
copy(dAtA[i:], m.Subject)
i = encodeVarintState(dAtA, i, uint64(len(m.Subject)))
i--
dAtA[i] = 0x1a
}
if len(m.Controller) > 0 {
i -= len(m.Controller)
copy(dAtA[i:], m.Controller)
i = encodeVarintState(dAtA, i, uint64(len(m.Controller)))
i--
dAtA[i] = 0x12
}
if m.Id != 0 {
i = encodeVarintState(dAtA, i, uint64(m.Id))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func encodeVarintState(dAtA []byte, offset int, v uint64) int {
offset -= sovState(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *Grant) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Id != 0 {
n += 1 + sovState(uint64(m.Id))
}
l = len(m.Controller)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.Subject)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.Origin)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
if m.ExpiryHeight != 0 {
n += 1 + sovState(uint64(m.ExpiryHeight))
}
return n
}
func (m *Macaroon) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Id != 0 {
n += 1 + sovState(uint64(m.Id))
}
l = len(m.Controller)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.Subject)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.Origin)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
if m.ExpiryHeight != 0 {
n += 1 + sovState(uint64(m.ExpiryHeight))
}
l = len(m.Macaroon)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
return n
}
func sovState(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozState(x uint64) (n int) {
return sovState(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *Grant) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Grant: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Grant: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
}
m.Id = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Id |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Controller = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Subject", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Subject = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Origin", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Origin = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 5:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ExpiryHeight", wireType)
}
m.ExpiryHeight = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ExpiryHeight |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipState(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthState
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Macaroon) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Macaroon: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Macaroon: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
}
m.Id = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Id |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Controller = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Subject", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Subject = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Origin", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Origin = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 5:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ExpiryHeight", wireType)
}
m.ExpiryHeight = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ExpiryHeight |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Macaroon", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Macaroon = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipState(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthState
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipState(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowState
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowState
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowState
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthState
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupState
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthState
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthState = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowState = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupState = fmt.Errorf("proto: unexpected end of group")
)

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,6 @@ import (
modulev1 "github.com/onsonr/sonr/api/service/module/v1" modulev1 "github.com/onsonr/sonr/api/service/module/v1"
didkeeper "github.com/onsonr/sonr/x/did/keeper" didkeeper "github.com/onsonr/sonr/x/did/keeper"
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
"github.com/onsonr/sonr/x/service/keeper" "github.com/onsonr/sonr/x/service/keeper"
vaultkeeper "github.com/onsonr/sonr/x/vault/keeper" vaultkeeper "github.com/onsonr/sonr/x/vault/keeper"
) )
@ -47,7 +46,6 @@ type ModuleInputs struct {
DidKeeper didkeeper.Keeper DidKeeper didkeeper.Keeper
GroupKeeper groupkeeper.Keeper GroupKeeper groupkeeper.Keeper
MacaroonKeeper macaroonkeeper.Keeper
NFTKeeper nftkeeper.Keeper NFTKeeper nftkeeper.Keeper
StakingKeeper stakingkeeper.Keeper StakingKeeper stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper
@ -64,8 +62,8 @@ type ModuleOutputs struct {
func ProvideModule(in ModuleInputs) ModuleOutputs { func ProvideModule(in ModuleInputs) ModuleOutputs {
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr, in.DidKeeper, in.GroupKeeper, in.MacaroonKeeper, in.NFTKeeper, in.VaultKeeper) k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr, in.DidKeeper, in.GroupKeeper, in.NFTKeeper, in.VaultKeeper)
m := NewAppModule(in.Cdc, k, in.DidKeeper, in.MacaroonKeeper) m := NewAppModule(in.Cdc, k, in.DidKeeper)
return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}} return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}}
} }

View File

@ -13,7 +13,6 @@ import (
apiv1 "github.com/onsonr/sonr/api/service/v1" apiv1 "github.com/onsonr/sonr/api/service/v1"
didkeeper "github.com/onsonr/sonr/x/did/keeper" didkeeper "github.com/onsonr/sonr/x/did/keeper"
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
"github.com/onsonr/sonr/x/service/types" "github.com/onsonr/sonr/x/service/types"
vaultkeeper "github.com/onsonr/sonr/x/vault/keeper" vaultkeeper "github.com/onsonr/sonr/x/vault/keeper"
) )
@ -32,7 +31,6 @@ type Keeper struct {
DidKeeper didkeeper.Keeper DidKeeper didkeeper.Keeper
GroupKeeper groupkeeper.Keeper GroupKeeper groupkeeper.Keeper
MacaroonKeeper macaroonkeeper.Keeper
NFTKeeper nftkeeper.Keeper NFTKeeper nftkeeper.Keeper
VaultKeeper vaultkeeper.Keeper VaultKeeper vaultkeeper.Keeper
} }
@ -45,7 +43,6 @@ func NewKeeper(
authority string, authority string,
didKeeper didkeeper.Keeper, didKeeper didkeeper.Keeper,
groupKeeper groupkeeper.Keeper, groupKeeper groupkeeper.Keeper,
macaroonKeeper macaroonkeeper.Keeper,
nftKeeper nftkeeper.Keeper, nftKeeper nftkeeper.Keeper,
vaultKeeper vaultkeeper.Keeper, vaultKeeper vaultkeeper.Keeper,
) Keeper { ) Keeper {
@ -78,7 +75,6 @@ func NewKeeper(
DidKeeper: didKeeper, DidKeeper: didKeeper,
GroupKeeper: groupKeeper, GroupKeeper: groupKeeper,
MacaroonKeeper: macaroonKeeper,
NFTKeeper: nftKeeper, NFTKeeper: nftKeeper,
} }

View File

@ -26,7 +26,6 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
didkeeper "github.com/onsonr/sonr/x/did/keeper" didkeeper "github.com/onsonr/sonr/x/did/keeper"
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
module "github.com/onsonr/sonr/x/service" module "github.com/onsonr/sonr/x/service"
"github.com/onsonr/sonr/x/service/keeper" "github.com/onsonr/sonr/x/service/keeper"
"github.com/onsonr/sonr/x/service/types" "github.com/onsonr/sonr/x/service/types"
@ -54,7 +53,6 @@ type testFixture struct {
bankkeeper bankkeeper.BaseKeeper bankkeeper bankkeeper.BaseKeeper
didkeeper didkeeper.Keeper didkeeper didkeeper.Keeper
groupkeeper groupkeeper.Keeper groupkeeper groupkeeper.Keeper
mack macaroonkeeper.Keeper
stakingKeeper *stakingkeeper.Keeper stakingKeeper *stakingkeeper.Keeper
mintkeeper mintkeeper.Keeper mintkeeper mintkeeper.Keeper
nftkeeper nftkeeper.Keeper nftkeeper nftkeeper.Keeper
@ -86,10 +84,10 @@ func SetupTest(t *testing.T) *testFixture {
registerBaseSDKModules(f, encCfg, storeService, logger, require) registerBaseSDKModules(f, encCfg, storeService, logger, require)
// Setup Keeper. // Setup Keeper.
f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr, f.didkeeper, f.groupkeeper, f.mack, f.nftkeeper, f.vaultkeeper) f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr, f.didkeeper, f.groupkeeper, f.nftkeeper, f.vaultkeeper)
f.msgServer = keeper.NewMsgServerImpl(f.k) f.msgServer = keeper.NewMsgServerImpl(f.k)
f.queryServer = keeper.NewQuerier(f.k) f.queryServer = keeper.NewQuerier(f.k)
f.appModule = module.NewAppModule(encCfg.Codec, f.k, f.didkeeper, f.mack) f.appModule = module.NewAppModule(encCfg.Codec, f.k, f.didkeeper)
return f return f
} }

View File

@ -16,7 +16,6 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
didkeeper "github.com/onsonr/sonr/x/did/keeper" didkeeper "github.com/onsonr/sonr/x/did/keeper"
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
"github.com/onsonr/sonr/x/service/keeper" "github.com/onsonr/sonr/x/service/keeper"
"github.com/onsonr/sonr/x/service/types" "github.com/onsonr/sonr/x/service/types"
) )
@ -46,7 +45,6 @@ type AppModule struct {
keeper keeper.Keeper keeper keeper.Keeper
didk didkeeper.Keeper didk didkeeper.Keeper
mack macaroonkeeper.Keeper
} }
// NewAppModule constructor // NewAppModule constructor
@ -54,13 +52,11 @@ func NewAppModule(
cdc codec.Codec, cdc codec.Codec,
keeper keeper.Keeper, keeper keeper.Keeper,
didkeeper didkeeper.Keeper, didkeeper didkeeper.Keeper,
macaroonkeeper macaroonkeeper.Keeper,
) *AppModule { ) *AppModule {
return &AppModule{ return &AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc}, AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper, keeper: keeper,
didk: didkeeper, didk: didkeeper,
mack: macaroonkeeper,
} }
} }

View File

@ -14,7 +14,6 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
modulev1 "github.com/onsonr/sonr/api/vault/module/v1" modulev1 "github.com/onsonr/sonr/api/vault/module/v1"
didkeeper "github.com/onsonr/sonr/x/did/keeper" didkeeper "github.com/onsonr/sonr/x/did/keeper"
@ -45,7 +44,6 @@ type ModuleInputs struct {
AccountKeeper authkeeper.AccountKeeper AccountKeeper authkeeper.AccountKeeper
DidKeeper didkeeper.Keeper DidKeeper didkeeper.Keeper
MacaroonKeeper macaroonkeeper.Keeper
StakingKeeper stakingkeeper.Keeper StakingKeeper stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper
} }
@ -60,7 +58,7 @@ type ModuleOutputs struct {
func ProvideModule(in ModuleInputs) ModuleOutputs { func ProvideModule(in ModuleInputs) ModuleOutputs {
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr, in.AccountKeeper, in.DidKeeper, in.MacaroonKeeper) k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr, in.AccountKeeper, in.DidKeeper)
m := NewAppModule(in.Cdc, k, in.DidKeeper) m := NewAppModule(in.Cdc, k, in.DidKeeper)
return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}} return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}}

View File

@ -17,7 +17,6 @@ import (
apiv1 "github.com/onsonr/sonr/api/vault/v1" apiv1 "github.com/onsonr/sonr/api/vault/v1"
dwngen "github.com/onsonr/sonr/internal/dwn/gen" dwngen "github.com/onsonr/sonr/internal/dwn/gen"
didkeeper "github.com/onsonr/sonr/x/did/keeper" didkeeper "github.com/onsonr/sonr/x/did/keeper"
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
"github.com/onsonr/sonr/x/vault/types" "github.com/onsonr/sonr/x/vault/types"
) )
@ -38,7 +37,6 @@ type Keeper struct {
AccountKeeper authkeeper.AccountKeeper AccountKeeper authkeeper.AccountKeeper
DIDKeeper didkeeper.Keeper DIDKeeper didkeeper.Keeper
MacaroonKeeper macaroonkeeper.Keeper
} }
// NewKeeper creates a new Keeper instance // NewKeeper creates a new Keeper instance
@ -49,7 +47,6 @@ func NewKeeper(
authority string, authority string,
authKeeper authkeeper.AccountKeeper, authKeeper authkeeper.AccountKeeper,
didKeeper didkeeper.Keeper, didKeeper didkeeper.Keeper,
macaroonKeeper macaroonkeeper.Keeper,
) Keeper { ) Keeper {
var hasIpfs bool var hasIpfs bool
logger = logger.With(log.ModuleKey, "x/"+types.ModuleName) logger = logger.With(log.ModuleKey, "x/"+types.ModuleName)
@ -83,7 +80,6 @@ func NewKeeper(
cdc: cdc, cdc: cdc,
logger: logger, logger: logger,
DIDKeeper: didKeeper, DIDKeeper: didKeeper,
MacaroonKeeper: macaroonKeeper,
AccountKeeper: authKeeper, AccountKeeper: authKeeper,
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
OrmDB: store, OrmDB: store,

View File

@ -24,7 +24,6 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
didkeeper "github.com/onsonr/sonr/x/did/keeper" didkeeper "github.com/onsonr/sonr/x/did/keeper"
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
module "github.com/onsonr/sonr/x/vault" module "github.com/onsonr/sonr/x/vault"
"github.com/onsonr/sonr/x/vault/keeper" "github.com/onsonr/sonr/x/vault/keeper"
"github.com/onsonr/sonr/x/vault/types" "github.com/onsonr/sonr/x/vault/types"
@ -52,7 +51,6 @@ type testFixture struct {
stakingKeeper *stakingkeeper.Keeper stakingKeeper *stakingkeeper.Keeper
mintkeeper mintkeeper.Keeper mintkeeper mintkeeper.Keeper
didk didkeeper.Keeper didk didkeeper.Keeper
mack macaroonkeeper.Keeper
addrs []sdk.AccAddress addrs []sdk.AccAddress
govModAddr string govModAddr string
@ -80,7 +78,7 @@ func SetupTest(t *testing.T) *testFixture {
registerBaseSDKModules(f, encCfg, storeService, logger, require) registerBaseSDKModules(f, encCfg, storeService, logger, require)
// Setup Keeper. // Setup Keeper.
f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr, f.accountkeeper, f.didk, f.mack) f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr, f.accountkeeper, f.didk)
f.msgServer = keeper.NewMsgServerImpl(f.k) f.msgServer = keeper.NewMsgServerImpl(f.k)
f.queryServer = keeper.NewQuerier(f.k) f.queryServer = keeper.NewQuerier(f.k)
f.appModule = module.NewAppModule(encCfg.Codec, f.k, f.didk) f.appModule = module.NewAppModule(encCfg.Codec, f.k, f.didk)