mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
feature/dwn sw js (#1103)
- **feat(macaroon): add and to macaroon genesis** - **refactor: move schema definitions to dedicated file** - **feat: remove Session model** - **refactor: move session middleware to internal package**
This commit is contained in:
+1
-2
@@ -13,7 +13,6 @@ import (
|
||||
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"
|
||||
|
||||
@@ -59,7 +58,7 @@ type ModuleOutputs struct {
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
|
||||
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper, in.NFTKeeper, &in.StakingKeeper, log.NewLogger(os.Stderr), govAddr)
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr, in.AccountKeeper, in.NFTKeeper, &in.StakingKeeper)
|
||||
m := NewAppModule(in.Cdc, k, in.NFTKeeper)
|
||||
|
||||
return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}}
|
||||
|
||||
@@ -13,12 +13,11 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"gopkg.in/macaroon.v2"
|
||||
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
stakkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
|
||||
"github.com/onsonr/crypto/mpc"
|
||||
"gopkg.in/macaroon.v2"
|
||||
|
||||
apiv1 "github.com/onsonr/sonr/api/did/v1"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
@@ -45,11 +44,11 @@ type Keeper struct {
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
storeService storetypes.KVStoreService,
|
||||
logger log.Logger,
|
||||
authority string,
|
||||
accKeeper authkeeper.AccountKeeper,
|
||||
nftKeeper nftkeeper.Keeper,
|
||||
stkKeeper *stakkeeper.Keeper,
|
||||
logger log.Logger,
|
||||
authority string,
|
||||
) Keeper {
|
||||
logger = logger.With(log.ModuleKey, "x/"+types.ModuleName)
|
||||
sb := collections.NewSchemaBuilder(storeService)
|
||||
|
||||
@@ -79,7 +79,7 @@ func SetupTest(t *testing.T) *testFixture {
|
||||
registerBaseSDKModules(f, encCfg, storeService, logger, require)
|
||||
|
||||
// Setup POA Keeper.
|
||||
f.k = keeper.NewKeeper(encCfg.Codec, storeService, f.accountkeeper, f.nftKeeper, f.stakingKeeper, logger, f.govModAddr)
|
||||
f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr, f.accountkeeper, f.nftKeeper, f.stakingKeeper)
|
||||
f.msgServer = keeper.NewMsgServerImpl(f.k)
|
||||
f.queryServer = keeper.NewQuerier(f.k)
|
||||
f.appModule = module.NewAppModule(encCfg.Codec, f.k, f.nftKeeper)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
|
||||
@@ -20,7 +21,7 @@ func NewQuerier(keeper Keeper) Querier {
|
||||
// Params returns the total set of did parameters.
|
||||
func (k Querier) Params(goCtx context.Context, req *types.QueryRequest) (*types.QueryParamsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
p, err := k.Keeper.CurrentParams(ctx)
|
||||
p, err := k.CurrentParams(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -35,13 +36,11 @@ func (k Querier) Resolve(goCtx context.Context, req *types.QueryRequest) (*types
|
||||
// Sign implements types.QueryServer.
|
||||
func (k Querier) Sign(goCtx context.Context, req *types.QuerySignRequest) (*types.QuerySignResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("Sign is unimplemented")
|
||||
return &types.QuerySignResponse{}, nil
|
||||
}
|
||||
|
||||
// Verify implements types.QueryServer.
|
||||
func (k Querier) Verify(goCtx context.Context, req *types.QueryVerifyRequest) (*types.QueryVerifyResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("Verify is unimplemented")
|
||||
return &types.QueryVerifyResponse{}, nil
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"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"
|
||||
@@ -37,10 +38,11 @@ func init() {
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
Cdc codec.Codec
|
||||
StoreService store.KVStoreService
|
||||
AddressCodec address.Codec
|
||||
DidKeeper didkeeper.Keeper
|
||||
Cdc codec.Codec
|
||||
StoreService store.KVStoreService
|
||||
AddressCodec address.Codec
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
DidKeeper didkeeper.Keeper
|
||||
|
||||
StakingKeeper stakingkeeper.Keeper
|
||||
SlashingKeeper slashingkeeper.Keeper
|
||||
@@ -56,7 +58,7 @@ type ModuleOutputs struct {
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
|
||||
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr)
|
||||
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{}}
|
||||
|
||||
@@ -6,10 +6,12 @@ import (
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -23,6 +25,9 @@ type Keeper struct {
|
||||
Params collections.Item[types.Params]
|
||||
OrmDB apiv1.StateStore
|
||||
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
DIDKeeper didkeeper.Keeper
|
||||
|
||||
authority string
|
||||
}
|
||||
|
||||
@@ -32,6 +37,8 @@ func NewKeeper(
|
||||
storeService storetypes.KVStoreService,
|
||||
logger log.Logger,
|
||||
authority string,
|
||||
accKeeper authkeeper.AccountKeeper,
|
||||
didKeeper didkeeper.Keeper,
|
||||
) Keeper {
|
||||
logger = logger.With(log.ModuleKey, "x/"+types.ModuleName)
|
||||
|
||||
@@ -58,6 +65,9 @@ func NewKeeper(
|
||||
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
|
||||
OrmDB: store,
|
||||
|
||||
AccountKeeper: accKeeper,
|
||||
DIDKeeper: didKeeper,
|
||||
|
||||
authority: authority,
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ func SetupTest(t *testing.T) *testFixture {
|
||||
registerBaseSDKModules(f, encCfg, storeService, logger, require)
|
||||
|
||||
// Setup Keeper.
|
||||
f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr)
|
||||
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)
|
||||
|
||||
@@ -32,13 +32,11 @@ func (k Querier) Params(c context.Context, req *types.QueryParamsRequest) (*type
|
||||
// RefreshToken implements types.QueryServer.
|
||||
func (k Querier) RefreshToken(goCtx context.Context, req *types.QueryRefreshTokenRequest) (*types.QueryRefreshTokenResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("RefreshToken is unimplemented")
|
||||
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)
|
||||
panic("ValidateToken is unimplemented")
|
||||
return &types.QueryValidateTokenResponse{}, nil
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package keeper
|
||||
import (
|
||||
"context"
|
||||
|
||||
"cosmossdk.io/errors"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
"cosmossdk.io/errors"
|
||||
"github.com/onsonr/sonr/x/macaroon/types"
|
||||
)
|
||||
|
||||
@@ -31,13 +31,11 @@ func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams
|
||||
// AuthorizeService implements types.MsgServer.
|
||||
func (ms msgServer) AuthorizeService(ctx context.Context, msg *types.MsgIssueMacaroon) (*types.MsgIssueMacaroonResponse, error) {
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
panic("AuthorizeService is unimplemented")
|
||||
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)
|
||||
panic("IssueMacaroon is unimplemented")
|
||||
return &types.MsgIssueMacaroonResponse{}, nil
|
||||
}
|
||||
|
||||
+245
-70
@@ -135,7 +135,8 @@ func (m *Params) GetCaveats() *Caveats {
|
||||
|
||||
// Methods defines the available DID methods
|
||||
type Methods struct {
|
||||
Methods []string `protobuf:"bytes,1,rep,name=methods,proto3" json:"methods,omitempty"`
|
||||
Default string `protobuf:"bytes,1,opt,name=default,proto3" json:"default,omitempty"`
|
||||
Supported []string `protobuf:"bytes,2,rep,name=supported,proto3" json:"supported,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Methods) Reset() { *m = Methods{} }
|
||||
@@ -171,16 +172,24 @@ func (m *Methods) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Methods proto.InternalMessageInfo
|
||||
|
||||
func (m *Methods) GetMethods() []string {
|
||||
func (m *Methods) GetDefault() string {
|
||||
if m != nil {
|
||||
return m.Methods
|
||||
return m.Default
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Methods) GetSupported() []string {
|
||||
if m != nil {
|
||||
return m.Supported
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Scopes defines the set of scopes
|
||||
type Scopes struct {
|
||||
Scopes []string `protobuf:"bytes,1,rep,name=scopes,proto3" json:"scopes,omitempty"`
|
||||
Base string `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"`
|
||||
Supported []string `protobuf:"bytes,2,rep,name=supported,proto3" json:"supported,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Scopes) Reset() { *m = Scopes{} }
|
||||
@@ -216,16 +225,24 @@ func (m *Scopes) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Scopes proto.InternalMessageInfo
|
||||
|
||||
func (m *Scopes) GetScopes() []string {
|
||||
func (m *Scopes) GetBase() string {
|
||||
if m != nil {
|
||||
return m.Scopes
|
||||
return m.Base
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Scopes) GetSupported() []string {
|
||||
if m != nil {
|
||||
return m.Supported
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Caveats defines the available caveats
|
||||
type Caveats struct {
|
||||
Caveats []string `protobuf:"bytes,1,rep,name=caveats,proto3" json:"caveats,omitempty"`
|
||||
SupportedFirstParty []string `protobuf:"bytes,1,rep,name=supported_first_party,json=supportedFirstParty,proto3" json:"supported_first_party,omitempty"`
|
||||
SupportedThirdParty []string `protobuf:"bytes,2,rep,name=supported_third_party,json=supportedThirdParty,proto3" json:"supported_third_party,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Caveats) Reset() { *m = Caveats{} }
|
||||
@@ -261,9 +278,16 @@ func (m *Caveats) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Caveats proto.InternalMessageInfo
|
||||
|
||||
func (m *Caveats) GetCaveats() []string {
|
||||
func (m *Caveats) GetSupportedFirstParty() []string {
|
||||
if m != nil {
|
||||
return m.Caveats
|
||||
return m.SupportedFirstParty
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Caveats) GetSupportedThirdParty() []string {
|
||||
if m != nil {
|
||||
return m.SupportedThirdParty
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -279,29 +303,33 @@ func init() {
|
||||
func init() { proto.RegisterFile("macaroon/v1/genesis.proto", fileDescriptor_06e0b5dfdf5e52ba) }
|
||||
|
||||
var fileDescriptor_06e0b5dfdf5e52ba = []byte{
|
||||
// 343 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x4d, 0x4c, 0x4e,
|
||||
0x2c, 0xca, 0xcf, 0xcf, 0xd3, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6,
|
||||
0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0x49, 0xe9, 0x95, 0x19, 0x4a, 0x09, 0x26, 0xe6,
|
||||
0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0xbc, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x98, 0xa9,
|
||||
0x0f, 0x62, 0x41, 0x44, 0x95, 0x1c, 0xb9, 0x78, 0xdc, 0x21, 0xc6, 0x04, 0x97, 0x24, 0x96, 0xa4,
|
||||
0x0a, 0x19, 0x72, 0xb1, 0x15, 0x24, 0x16, 0x25, 0xe6, 0x16, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70,
|
||||
0x1b, 0x09, 0xeb, 0x21, 0x19, 0xab, 0x17, 0x00, 0x96, 0x72, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21,
|
||||
0x08, 0xaa, 0x50, 0x69, 0x33, 0x23, 0x17, 0x1b, 0x44, 0x42, 0x48, 0x8f, 0x8b, 0x3d, 0x37, 0xb5,
|
||||
0x24, 0x23, 0x3f, 0x05, 0xa6, 0x5d, 0x04, 0x45, 0xbb, 0x2f, 0x44, 0x2e, 0x08, 0xa6, 0x48, 0x48,
|
||||
0x9b, 0x8b, 0xad, 0x38, 0x39, 0xbf, 0x20, 0xb5, 0x58, 0x82, 0x09, 0x8b, 0x6d, 0xc1, 0x60, 0xa9,
|
||||
0x20, 0xa8, 0x12, 0x90, 0xe1, 0xc9, 0x89, 0x65, 0xa9, 0x89, 0x25, 0xc5, 0x12, 0xcc, 0x58, 0x0c,
|
||||
0x77, 0x86, 0xc8, 0x05, 0xc1, 0x14, 0x59, 0xc9, 0xcc, 0x58, 0x20, 0xcf, 0xf0, 0x62, 0x81, 0x3c,
|
||||
0x63, 0xd7, 0xf3, 0x0d, 0x5a, 0xfc, 0xf0, 0x80, 0x83, 0xba, 0xda, 0x8e, 0x8b, 0x1d, 0xea, 0x1c,
|
||||
0x21, 0x09, 0x64, 0x57, 0x33, 0x6b, 0x70, 0xc2, 0xdd, 0x67, 0x25, 0x09, 0xd3, 0x2e, 0x00, 0xd7,
|
||||
0x0e, 0x95, 0x52, 0xb2, 0xe2, 0x62, 0x83, 0xb8, 0x4f, 0x48, 0x0c, 0xee, 0x09, 0x88, 0x6e, 0x28,
|
||||
0xcf, 0x4a, 0x02, 0xd3, 0x6e, 0x88, 0x8c, 0x92, 0x2d, 0x17, 0x3b, 0xd4, 0xb5, 0x20, 0xbb, 0x61,
|
||||
0x9e, 0x82, 0xda, 0x0d, 0x73, 0x3e, 0x16, 0xed, 0x10, 0x29, 0x27, 0xc7, 0x13, 0x8f, 0xe4, 0x18,
|
||||
0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5,
|
||||
0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce,
|
||||
0xcf, 0xd5, 0xcf, 0xcf, 0x2b, 0xce, 0xcf, 0x2b, 0xd2, 0x07, 0x13, 0x15, 0xfa, 0x70, 0x33, 0x4a,
|
||||
0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xb1, 0x6f, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xe5,
|
||||
0x08, 0x7e, 0x28, 0x50, 0x02, 0x00, 0x00,
|
||||
// 414 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x41, 0xcb, 0xd3, 0x30,
|
||||
0x18, 0xc7, 0x9b, 0xbd, 0x2f, 0x2d, 0xcb, 0x2b, 0xa8, 0xd9, 0x84, 0x6e, 0x8c, 0x6e, 0xf4, 0xe2,
|
||||
0x50, 0x68, 0xd9, 0xbc, 0xed, 0xb6, 0x09, 0x7a, 0x12, 0x46, 0xb7, 0x93, 0x08, 0x23, 0x6b, 0xb3,
|
||||
0xae, 0x60, 0x9b, 0x92, 0x64, 0xc3, 0x7d, 0x05, 0xbd, 0x78, 0xf4, 0xb8, 0x8f, 0x20, 0xf8, 0x25,
|
||||
0x76, 0xdc, 0xd1, 0x93, 0xc8, 0x76, 0xd0, 0x8f, 0x21, 0x4d, 0xd2, 0xea, 0x74, 0xe0, 0x25, 0x3c,
|
||||
0xcd, 0xef, 0xf9, 0xff, 0xfb, 0x7f, 0x1e, 0x02, 0x5b, 0x29, 0x0e, 0x31, 0xa3, 0x34, 0xf3, 0xb7,
|
||||
0x03, 0x3f, 0x26, 0x19, 0xe1, 0x09, 0xf7, 0x72, 0x46, 0x05, 0x45, 0x77, 0x25, 0xf2, 0xb6, 0x83,
|
||||
0xf6, 0x43, 0x9c, 0x26, 0x19, 0xf5, 0xe5, 0xa9, 0x78, 0xbb, 0x19, 0xd3, 0x98, 0xca, 0xd2, 0x2f,
|
||||
0x2a, 0x75, 0xeb, 0x8e, 0xe1, 0xbd, 0x97, 0xca, 0x66, 0x26, 0xb0, 0x20, 0x68, 0x00, 0xcd, 0x1c,
|
||||
0x33, 0x9c, 0x72, 0x1b, 0xf4, 0x40, 0xff, 0x6e, 0xd8, 0xf0, 0xfe, 0xb0, 0xf5, 0xa6, 0x12, 0x4d,
|
||||
0x6e, 0x0f, 0xdf, 0xba, 0x46, 0xa0, 0x1b, 0xdd, 0x2f, 0x00, 0x9a, 0x0a, 0x20, 0x0f, 0x5a, 0x29,
|
||||
0x11, 0x6b, 0x1a, 0x95, 0xf2, 0xe6, 0x85, 0xfc, 0x95, 0x62, 0x41, 0xd9, 0x84, 0x9e, 0x42, 0x93,
|
||||
0x87, 0x34, 0x27, 0xdc, 0xae, 0x5d, 0xf9, 0xdb, 0x4c, 0xa2, 0x40, 0xb7, 0x14, 0xe6, 0x21, 0xde,
|
||||
0x12, 0x2c, 0xb8, 0x7d, 0x73, 0xc5, 0xfc, 0xb9, 0x62, 0x41, 0xd9, 0x34, 0xea, 0x7c, 0xda, 0x77,
|
||||
0x8d, 0x9f, 0xfb, 0x2e, 0x78, 0xff, 0xe3, 0xf3, 0x93, 0xfb, 0xd5, 0xe2, 0x74, 0xea, 0x37, 0xd0,
|
||||
0xd2, 0x71, 0x90, 0x0d, 0xad, 0x88, 0xac, 0xf0, 0xe6, 0xad, 0x90, 0xa9, 0xeb, 0x41, 0xf9, 0x89,
|
||||
0x3a, 0xb0, 0xce, 0x37, 0x79, 0x4e, 0x99, 0x20, 0x91, 0x5d, 0xeb, 0xdd, 0xf4, 0xeb, 0xc1, 0xef,
|
||||
0x8b, 0x51, 0xab, 0x34, 0x7f, 0x50, 0x99, 0xeb, 0xc1, 0xdc, 0x39, 0x34, 0x55, 0x7a, 0x84, 0xe0,
|
||||
0xed, 0x12, 0x73, 0xa2, 0x9d, 0x65, 0xfd, 0x1f, 0x5b, 0xfb, 0xdf, 0xcc, 0x6a, 0x03, 0xee, 0x07,
|
||||
0x00, 0x2d, 0x3d, 0x26, 0x1a, 0xc2, 0x47, 0x95, 0x64, 0xb1, 0x4a, 0x18, 0x17, 0x8b, 0x1c, 0x33,
|
||||
0xb1, 0xb3, 0x81, 0xf4, 0x6b, 0x54, 0xf0, 0x45, 0xc1, 0xa6, 0x05, 0xba, 0xd4, 0x88, 0x75, 0xc2,
|
||||
0x22, 0xad, 0xa9, 0xfd, 0xa5, 0x99, 0x17, 0x4c, 0x6a, 0xae, 0xa5, 0x51, 0x0b, 0x9e, 0x8c, 0x0f,
|
||||
0x27, 0x07, 0x1c, 0x4f, 0x0e, 0xf8, 0x7e, 0x72, 0xc0, 0xc7, 0xb3, 0x63, 0x1c, 0xcf, 0x8e, 0xf1,
|
||||
0xf5, 0xec, 0x18, 0xaf, 0x1f, 0xc7, 0x89, 0x58, 0x6f, 0x96, 0x5e, 0x48, 0x53, 0x9f, 0x66, 0x9c,
|
||||
0x66, 0xcc, 0x97, 0xc7, 0x3b, 0xbf, 0xf2, 0x10, 0xbb, 0x9c, 0xf0, 0xa5, 0x29, 0x1f, 0xe1, 0xb3,
|
||||
0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xa6, 0x33, 0x5b, 0xd7, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *Params) Equal(that interface{}) bool {
|
||||
@@ -353,11 +381,14 @@ func (this *Methods) Equal(that interface{}) bool {
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if len(this.Methods) != len(that1.Methods) {
|
||||
if this.Default != that1.Default {
|
||||
return false
|
||||
}
|
||||
for i := range this.Methods {
|
||||
if this.Methods[i] != that1.Methods[i] {
|
||||
if len(this.Supported) != len(that1.Supported) {
|
||||
return false
|
||||
}
|
||||
for i := range this.Supported {
|
||||
if this.Supported[i] != that1.Supported[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -382,11 +413,14 @@ func (this *Scopes) Equal(that interface{}) bool {
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if len(this.Scopes) != len(that1.Scopes) {
|
||||
if this.Base != that1.Base {
|
||||
return false
|
||||
}
|
||||
for i := range this.Scopes {
|
||||
if this.Scopes[i] != that1.Scopes[i] {
|
||||
if len(this.Supported) != len(that1.Supported) {
|
||||
return false
|
||||
}
|
||||
for i := range this.Supported {
|
||||
if this.Supported[i] != that1.Supported[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -411,11 +445,19 @@ func (this *Caveats) Equal(that interface{}) bool {
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if len(this.Caveats) != len(that1.Caveats) {
|
||||
if len(this.SupportedFirstParty) != len(that1.SupportedFirstParty) {
|
||||
return false
|
||||
}
|
||||
for i := range this.Caveats {
|
||||
if this.Caveats[i] != that1.Caveats[i] {
|
||||
for i := range this.SupportedFirstParty {
|
||||
if this.SupportedFirstParty[i] != that1.SupportedFirstParty[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if len(this.SupportedThirdParty) != len(that1.SupportedThirdParty) {
|
||||
return false
|
||||
}
|
||||
for i := range this.SupportedThirdParty {
|
||||
if this.SupportedThirdParty[i] != that1.SupportedThirdParty[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -533,15 +575,22 @@ func (m *Methods) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Methods) > 0 {
|
||||
for iNdEx := len(m.Methods) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Methods[iNdEx])
|
||||
copy(dAtA[i:], m.Methods[iNdEx])
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Methods[iNdEx])))
|
||||
if len(m.Supported) > 0 {
|
||||
for iNdEx := len(m.Supported) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Supported[iNdEx])
|
||||
copy(dAtA[i:], m.Supported[iNdEx])
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Supported[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.Default) > 0 {
|
||||
i -= len(m.Default)
|
||||
copy(dAtA[i:], m.Default)
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Default)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
@@ -565,15 +614,22 @@ func (m *Scopes) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Scopes) > 0 {
|
||||
for iNdEx := len(m.Scopes) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Scopes[iNdEx])
|
||||
copy(dAtA[i:], m.Scopes[iNdEx])
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Scopes[iNdEx])))
|
||||
if len(m.Supported) > 0 {
|
||||
for iNdEx := len(m.Supported) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Supported[iNdEx])
|
||||
copy(dAtA[i:], m.Supported[iNdEx])
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Supported[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.Base) > 0 {
|
||||
i -= len(m.Base)
|
||||
copy(dAtA[i:], m.Base)
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Base)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
@@ -597,11 +653,20 @@ func (m *Caveats) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Caveats) > 0 {
|
||||
for iNdEx := len(m.Caveats) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Caveats[iNdEx])
|
||||
copy(dAtA[i:], m.Caveats[iNdEx])
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Caveats[iNdEx])))
|
||||
if len(m.SupportedThirdParty) > 0 {
|
||||
for iNdEx := len(m.SupportedThirdParty) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.SupportedThirdParty[iNdEx])
|
||||
copy(dAtA[i:], m.SupportedThirdParty[iNdEx])
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.SupportedThirdParty[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.SupportedFirstParty) > 0 {
|
||||
for iNdEx := len(m.SupportedFirstParty) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.SupportedFirstParty[iNdEx])
|
||||
copy(dAtA[i:], m.SupportedFirstParty[iNdEx])
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.SupportedFirstParty[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
@@ -658,8 +723,12 @@ func (m *Methods) Size() (n int) {
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Methods) > 0 {
|
||||
for _, s := range m.Methods {
|
||||
l = len(m.Default)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
if len(m.Supported) > 0 {
|
||||
for _, s := range m.Supported {
|
||||
l = len(s)
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
@@ -673,8 +742,12 @@ func (m *Scopes) Size() (n int) {
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Scopes) > 0 {
|
||||
for _, s := range m.Scopes {
|
||||
l = len(m.Base)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
if len(m.Supported) > 0 {
|
||||
for _, s := range m.Supported {
|
||||
l = len(s)
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
@@ -688,8 +761,14 @@ func (m *Caveats) Size() (n int) {
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Caveats) > 0 {
|
||||
for _, s := range m.Caveats {
|
||||
if len(m.SupportedFirstParty) > 0 {
|
||||
for _, s := range m.SupportedFirstParty {
|
||||
l = len(s)
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.SupportedThirdParty) > 0 {
|
||||
for _, s := range m.SupportedThirdParty {
|
||||
l = len(s)
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
@@ -975,7 +1054,7 @@ func (m *Methods) Unmarshal(dAtA []byte) error {
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Methods", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Default", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@@ -1003,7 +1082,39 @@ func (m *Methods) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Methods = append(m.Methods, string(dAtA[iNdEx:postIndex]))
|
||||
m.Default = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Supported", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
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 ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Supported = append(m.Supported, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
@@ -1057,7 +1168,7 @@ func (m *Scopes) Unmarshal(dAtA []byte) error {
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Scopes", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Base", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@@ -1085,7 +1196,39 @@ func (m *Scopes) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Scopes = append(m.Scopes, string(dAtA[iNdEx:postIndex]))
|
||||
m.Base = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Supported", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
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 ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Supported = append(m.Supported, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
@@ -1139,7 +1282,7 @@ func (m *Caveats) Unmarshal(dAtA []byte) error {
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Caveats", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SupportedFirstParty", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@@ -1167,7 +1310,39 @@ func (m *Caveats) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Caveats = append(m.Caveats, string(dAtA[iNdEx:postIndex]))
|
||||
m.SupportedFirstParty = append(m.SupportedFirstParty, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SupportedThirdParty", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
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 ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.SupportedThirdParty = append(m.SupportedThirdParty, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
|
||||
@@ -6,8 +6,11 @@ import (
|
||||
|
||||
// DefaultParams returns default module parameters.
|
||||
func DefaultParams() Params {
|
||||
// TODO:
|
||||
return Params{}
|
||||
return Params{
|
||||
Methods: DefaultMethods(),
|
||||
Scopes: DefaultScopes(),
|
||||
Caveats: DefaultCaveats(),
|
||||
}
|
||||
}
|
||||
|
||||
// Stringer method for Params.
|
||||
@@ -22,6 +25,28 @@ func (p Params) String() string {
|
||||
|
||||
// Validate does the sanity check on the params.
|
||||
func (p Params) Validate() error {
|
||||
// TODO:
|
||||
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: []string{"aud", "exp", "iat", "iss", "nbf", "nonce", "sub"},
|
||||
// Third party - UCAN Format
|
||||
SupportedThirdParty: []string{"cap", "nbf", "exp", "att", "prf", "rmt", "sig", "ucv"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,14 +99,99 @@ func (m *Grant) GetExpiryHeight() int64 {
|
||||
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{
|
||||
// 280 bytes of a gzipped FileDescriptorProto
|
||||
// 306 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,
|
||||
@@ -119,12 +204,14 @@ var fileDescriptor_2ade56339acadfd8 = []byte{
|
||||
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, 0x3a, 0x39, 0x9e, 0x78, 0x24, 0xc7,
|
||||
0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c,
|
||||
0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x7a, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72,
|
||||
0x7e, 0xae, 0x7e, 0x7e, 0x5e, 0x71, 0x7e, 0x5e, 0x91, 0x3e, 0x98, 0xa8, 0xd0, 0x87, 0x07, 0x55,
|
||||
0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x08, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff,
|
||||
0x83, 0x14, 0xb8, 0x7a, 0x43, 0x01, 0x00, 0x00,
|
||||
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, 0xb1, 0xfe, 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, 0xab, 0x93, 0xfc, 0x98, 0x1b, 0x02,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Grant) Marshal() (dAtA []byte, err error) {
|
||||
@@ -181,6 +268,67 @@ func (m *Grant) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
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
|
||||
@@ -219,6 +367,37 @@ func (m *Grant) Size() (n int) {
|
||||
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
|
||||
}
|
||||
@@ -409,6 +588,222 @@ func (m *Grant) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
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
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
nftkeeper "cosmossdk.io/x/nft/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@@ -44,6 +45,7 @@ type ModuleInputs struct {
|
||||
|
||||
DidKeeper didkeeper.Keeper
|
||||
MacaroonKeeper macaroonkeeper.Keeper
|
||||
NFTKeeper nftkeeper.Keeper
|
||||
StakingKeeper stakingkeeper.Keeper
|
||||
SlashingKeeper slashingkeeper.Keeper
|
||||
}
|
||||
@@ -58,7 +60,7 @@ type ModuleOutputs struct {
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
|
||||
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr)
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr, in.DidKeeper, in.MacaroonKeeper, in.NFTKeeper)
|
||||
m := NewAppModule(in.Cdc, k, in.DidKeeper, in.MacaroonKeeper)
|
||||
|
||||
return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}}
|
||||
|
||||
@@ -5,11 +5,14 @@ import (
|
||||
storetypes "cosmossdk.io/core/store"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/orm/model/ormdb"
|
||||
nftkeeper "cosmossdk.io/x/nft/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
apiv1 "github.com/onsonr/sonr/api/service/v1"
|
||||
didkeeper "github.com/onsonr/sonr/x/did/keeper"
|
||||
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
|
||||
"github.com/onsonr/sonr/x/service/types"
|
||||
)
|
||||
|
||||
@@ -24,6 +27,10 @@ type Keeper struct {
|
||||
OrmDB apiv1.StateStore
|
||||
|
||||
authority string
|
||||
|
||||
DidKeeper didkeeper.Keeper
|
||||
MacaroonKeeper macaroonkeeper.Keeper
|
||||
NFTKeeper nftkeeper.Keeper
|
||||
}
|
||||
|
||||
// NewKeeper creates a new Keeper instance
|
||||
@@ -32,6 +39,9 @@ func NewKeeper(
|
||||
storeService storetypes.KVStoreService,
|
||||
logger log.Logger,
|
||||
authority string,
|
||||
didKeeper didkeeper.Keeper,
|
||||
macaroonKeeper macaroonkeeper.Keeper,
|
||||
nftKeeper nftkeeper.Keeper,
|
||||
) Keeper {
|
||||
logger = logger.With(log.ModuleKey, "x/"+types.ModuleName)
|
||||
|
||||
@@ -59,6 +69,7 @@ func NewKeeper(
|
||||
OrmDB: store,
|
||||
|
||||
authority: authority,
|
||||
NFTKeeper: nftKeeper,
|
||||
}
|
||||
|
||||
schema, err := sb.Build()
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
nftkeeper "cosmossdk.io/x/nft/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
@@ -53,6 +54,7 @@ type testFixture struct {
|
||||
mack macaroonkeeper.Keeper
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
mintkeeper mintkeeper.Keeper
|
||||
nftkeeper nftkeeper.Keeper
|
||||
|
||||
addrs []sdk.AccAddress
|
||||
govModAddr string
|
||||
@@ -80,7 +82,7 @@ func SetupTest(t *testing.T) *testFixture {
|
||||
registerBaseSDKModules(f, encCfg, storeService, logger, require)
|
||||
|
||||
// Setup Keeper.
|
||||
f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr)
|
||||
f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr, f.didkeeper, f.mack, f.nftkeeper)
|
||||
f.msgServer = keeper.NewMsgServerImpl(f.k)
|
||||
f.queryServer = keeper.NewQuerier(f.k)
|
||||
f.appModule = module.NewAppModule(encCfg.Codec, f.k, f.didkeeper, f.mack)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"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"
|
||||
@@ -41,6 +42,7 @@ type ModuleInputs struct {
|
||||
StoreService store.KVStoreService
|
||||
AddressCodec address.Codec
|
||||
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
DidKeeper didkeeper.Keeper
|
||||
StakingKeeper stakingkeeper.Keeper
|
||||
SlashingKeeper slashingkeeper.Keeper
|
||||
@@ -56,7 +58,7 @@ type ModuleOutputs struct {
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
|
||||
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, log.NewLogger(os.Stderr), govAddr, in.DidKeeper)
|
||||
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{}}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"cosmossdk.io/orm/model/ormdb"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
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"
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
@@ -34,7 +35,8 @@ type Keeper struct {
|
||||
|
||||
ipfsClient *rpc.HttpApi
|
||||
|
||||
DIDKeeper didkeeper.Keeper
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
DIDKeeper didkeeper.Keeper
|
||||
}
|
||||
|
||||
// NewKeeper creates a new Keeper instance
|
||||
@@ -43,6 +45,7 @@ func NewKeeper(
|
||||
storeService storetypes.KVStoreService,
|
||||
logger log.Logger,
|
||||
authority string,
|
||||
authKeeper authkeeper.AccountKeeper,
|
||||
didk didkeeper.Keeper,
|
||||
) Keeper {
|
||||
logger = logger.With(log.ModuleKey, "x/"+types.ModuleName)
|
||||
@@ -65,11 +68,12 @@ func NewKeeper(
|
||||
|
||||
ipfsClient, _ := rpc.NewLocalApi()
|
||||
k := Keeper{
|
||||
cdc: cdc,
|
||||
logger: logger,
|
||||
DIDKeeper: didk,
|
||||
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
|
||||
OrmDB: store,
|
||||
cdc: cdc,
|
||||
logger: logger,
|
||||
DIDKeeper: didk,
|
||||
AccountKeeper: authKeeper,
|
||||
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
|
||||
OrmDB: store,
|
||||
|
||||
ipfsClient: ipfsClient,
|
||||
authority: authority,
|
||||
|
||||
@@ -78,7 +78,7 @@ func SetupTest(t *testing.T) *testFixture {
|
||||
registerBaseSDKModules(f, encCfg, storeService, logger, require)
|
||||
|
||||
// Setup Keeper.
|
||||
f.k = keeper.NewKeeper(encCfg.Codec, storeService, logger, f.govModAddr, f.didk)
|
||||
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)
|
||||
|
||||
@@ -56,6 +56,7 @@ func NewAppModule(
|
||||
return &AppModule{
|
||||
AppModuleBasic: AppModuleBasic{cdc: cdc},
|
||||
keeper: keeper,
|
||||
didk: didkeeper,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-9
@@ -2,6 +2,8 @@ package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/orm"
|
||||
)
|
||||
|
||||
// DefaultParams returns default module parameters.
|
||||
@@ -32,14 +34,14 @@ func (p Params) Validate() error {
|
||||
// DefaultSchema returns the default schema
|
||||
func DefaultSchema() *Schema {
|
||||
return &Schema{
|
||||
Version: 1,
|
||||
Account: "++, id, name, address, publicKey, chainCode, index, controller, createdAt",
|
||||
Asset: "++, id, name, symbol, decimals, chainCode, createdAt",
|
||||
Chain: "++, id, name, networkId, chainCode, createdAt",
|
||||
Credential: "++, id, subject, controller, attestationType, origin, label, deviceId, credentialId, publicKey, transport, signCount, userPresent, userVerified, backupEligible, backupState, cloneWarning, createdAt, updatedAt",
|
||||
Jwk: "++, kty, crv, x, y, n, e",
|
||||
Grant: "++, subject, controller, origin, token, scopes, createdAt, updatedAt",
|
||||
Keyshare: "++, id, data, role, createdAt, lastRefreshed",
|
||||
Profile: "++, id, subject, controller, originUri, publicMetadata, privateMetadata, createdAt, updatedAt",
|
||||
Version: orm.SCHEMA_VERSION,
|
||||
Account: orm.AccountSchema(),
|
||||
Asset: orm.AssetSchema(),
|
||||
Chain: orm.ChainSchema(),
|
||||
Credential: orm.CredentialSchema(),
|
||||
Jwk: orm.JwkSchema(),
|
||||
Grant: orm.GrantSchema(),
|
||||
Keyshare: orm.KeyshareSchema(),
|
||||
Profile: orm.ProfileSchema(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user