From 36d7cd25dd625782d8517c2e5f85b2fefa99bedb Mon Sep 17 00:00:00 2001 From: arnabghose997 Date: Fri, 20 Jan 2023 14:55:39 +0530 Subject: [PATCH 01/11] intial v0.29.2 integration --- .gitignore | 1 + Makefile | 3 +- app/ante.go | 67 +++++++ app/app.go | 336 +++++++++++++++++++++++++++-------- app/export.go | 4 +- app/prefix.go | 2 + app/wasm_integration_test.go | 119 +++++++++++++ cmd/hid-noded/cmd/root.go | 37 +++- go.mod | 26 +-- go.sum | 47 +++-- 10 files changed, 537 insertions(+), 105 deletions(-) create mode 100644 app/ante.go create mode 100644 app/wasm_integration_test.go diff --git a/.gitignore b/.gitignore index ede9195..837e3f3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.dll *.so *.dylib +*.wasm # Test binary, built with `go test -c` *.test diff --git a/Makefile b/Makefile index cf5b8cd..fafbc8d 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,8 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=hid-node \ -X github.com/cosmos/cosmos-sdk/version.AppName=hid-node \ -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ - -X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION) + -X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION) \ + -X github.com/hypersign-protocol/hid-node/app.ProposalsEnabled=true # enable x/wasm based proposals BUILD_FLAGS := -ldflags '$(ldflags)' diff --git a/app/ante.go b/app/ante.go new file mode 100644 index 0000000..ec3c9dd --- /dev/null +++ b/app/ante.go @@ -0,0 +1,67 @@ +package app + +import ( + "github.com/cosmos/cosmos-sdk/x/auth/ante" + "github.com/cosmos/ibc-go/v3/modules/core/keeper" + + sdk "github.com/cosmos/cosmos-sdk/types" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante" + wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC +// channel keeper. +type HandlerOptions struct { + ante.HandlerOptions + + IBCKeeper *keeper.Keeper + WasmConfig *wasmTypes.WasmConfig + TXCounterStoreKey sdk.StoreKey +} + +func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { + if options.AccountKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler") + } + if options.BankKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler") + } + if options.SignModeHandler == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") + } + if options.WasmConfig == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder") + } + if options.TXCounterStoreKey == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder") + } + + sigGasConsumer := options.SigGasConsumer + if sigGasConsumer == nil { + sigGasConsumer = ante.DefaultSigVerificationGasConsumer + } + + anteDecorators := []sdk.AnteDecorator{ + ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early + wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey), + ante.NewRejectExtensionOptionsDecorator(), + ante.NewMempoolFeeDecorator(), + ante.NewValidateBasicDecorator(), + ante.NewTxTimeoutHeightDecorator(), + ante.NewValidateMemoDecorator(options.AccountKeeper), + ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), + ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper), + // SetPubKeyDecorator must be called before all signature verification decorators + ante.NewSetPubKeyDecorator(options.AccountKeeper), + ante.NewValidateSigCountDecorator(options.AccountKeeper), + ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer), + ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), + ante.NewIncrementSequenceDecorator(options.AccountKeeper), + ibcante.NewAnteDecorator(options.IBCKeeper), + } + + return sdk.ChainAnteDecorators(anteDecorators...), nil +} diff --git a/app/app.go b/app/app.go index 7e3b1da..24550f0 100644 --- a/app/app.go +++ b/app/app.go @@ -1,10 +1,12 @@ package app import ( + "fmt" "io" "net/http" "os" "path/filepath" + "strings" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -71,6 +73,7 @@ import ( upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/ibc-go/v3/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper" @@ -99,6 +102,10 @@ import ( ssimodule "github.com/hypersign-protocol/hid-node/x/ssi" ssimodulekeeper "github.com/hypersign-protocol/hid-node/x/ssi/keeper" ssimoduletypes "github.com/hypersign-protocol/hid-node/x/ssi/types" + + "github.com/CosmWasm/wasmd/x/wasm" + wasmclient "github.com/CosmWasm/wasmd/x/wasm/client" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" ) const ( @@ -108,6 +115,7 @@ const ( func getGovProposalHandlers() []govclient.ProposalHandler { var govProposalHandlers []govclient.ProposalHandler + govProposalHandlers = wasmclient.ProposalHandlers govProposalHandlers = append(govProposalHandlers, paramsclient.ProposalHandler, distrclient.ProposalHandler, @@ -145,6 +153,7 @@ var ( evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, authzmodule.AppModuleBasic{}, + wasm.AppModuleBasic{}, ssimodule.AppModuleBasic{}, ) @@ -157,13 +166,42 @@ var ( stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + wasm.ModuleName: {authtypes.Burner}, } ) +// Wasm Vars var ( - _ cosmoscmd.App = (*App)(nil) - _ servertypes.Application = (*App)(nil) - _ simapp.App = (*App)(nil) + // If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals. + // If EnabledSpecificProposals is "", and this is not "true", then disable all x/wasm proposals. + ProposalsEnabled = "false" + // If set to non-empty string it must be comma-separated list of values that are all a subset + // of "EnableAllProposals" (takes precedence over ProposalsEnabled) + // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 + EnableSpecificProposals = "" +) + +// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to +// produce a list of enabled proposals to pass into wasmd app. +func GetEnabledProposals() []wasm.ProposalType { + if EnableSpecificProposals == "" { + if ProposalsEnabled == "true" { + return wasm.EnableAllProposals + } + return wasm.DisableAllProposals + } + chunks := strings.Split(EnableSpecificProposals, ",") + proposals, err := wasm.ConvertToProposals(chunks) + if err != nil { + panic(err) + } + return proposals +} + +var ( + _ cosmoscmd.App = (*HidnodeApp)(nil) + _ servertypes.Application = (*HidnodeApp)(nil) + _ simapp.App = (*HidnodeApp)(nil) ) func init() { @@ -175,10 +213,10 @@ func init() { DefaultNodeHome = filepath.Join(userHomeDir, "."+Name) } -// App extends an ABCI application, but with most of its parameters exported. +// HidnodeApp extends an ABCI application, but with most of its parameters exported. // They are exported for convenience in creating helper functions, as object // capabilities aren't needed for testing. -type App struct { +type HidnodeApp struct { *baseapp.BaseApp cdc *codec.LegacyAmino @@ -209,10 +247,12 @@ type App struct { TransferKeeper ibctransferkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper AuthzKeeper authzkeeper.Keeper + WasmKeeper wasm.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedWasmKeeper capabilitykeeper.ScopedKeeper SsiKeeper ssimodulekeeper.Keeper @@ -223,8 +263,8 @@ type App struct { sm *module.SimulationManager } -// New returns a reference to an initialized blockchain app -func New( +// NewHidnodeApp returns a reference to an initialized blockchain app +func NewHidnodeApp( logger log.Logger, db dbm.DB, traceStore io.Writer, @@ -233,9 +273,11 @@ func New( homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig, + enabledProposals []wasm.ProposalType, appOpts servertypes.AppOptions, + wasmOpts []wasm.Option, baseAppOptions ...func(*baseapp.BaseApp), -) *App { +) *HidnodeApp { appCodec := encodingConfig.Codec cdc := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -248,14 +290,15 @@ func New( keys := sdk.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, - evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, authzkeeper.StoreKey, - ssimoduletypes.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, + upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, + ibctransfertypes.StoreKey, capabilitytypes.StoreKey, authzkeeper.StoreKey, + ssimoduletypes.StoreKey, wasm.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - app := &App{ + app := &HidnodeApp{ BaseApp: bApp, cdc: cdc, appCodec: appCodec, @@ -266,45 +309,104 @@ func New( memKeys: memKeys, } - app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) + app.ParamsKeeper = initParamsKeeper( + appCodec, + cdc, + keys[paramstypes.StoreKey], + tkeys[paramstypes.TStoreKey], + ) // set the BaseApp's parameter store - bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) + bApp.SetParamStore( + app.ParamsKeeper. + Subspace(baseapp.Paramspace). + WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) + app.CapabilityKeeper = capabilitykeeper.NewKeeper( + appCodec, + keys[capabilitytypes.StoreKey], + memKeys[capabilitytypes.MemStoreKey], + ) // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName) + app.CapabilityKeeper.Seal() - // add keepers + // Keepers app.AccountKeeper = authkeeper.NewAccountKeeper( - appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, + appCodec, + keys[authtypes.StoreKey], + app.getSubspace(authtypes.ModuleName), + authtypes.ProtoBaseAccount, + maccPerms, ) + app.BankKeeper = bankkeeper.NewBaseKeeper( - appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), + appCodec, + keys[banktypes.StoreKey], + app.AccountKeeper, + app.getSubspace(banktypes.ModuleName), + app.ModuleAccountAddrs(), ) + stakingKeeper := stakingkeeper.NewKeeper( - appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), + appCodec, + keys[stakingtypes.StoreKey], + app.AccountKeeper, + app.BankKeeper, + app.getSubspace(stakingtypes.ModuleName), ) + app.MintKeeper = mintkeeper.NewKeeper( - appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper, - app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, + appCodec, keys[minttypes.StoreKey], + app.getSubspace(minttypes.ModuleName), + &stakingKeeper, + app.AccountKeeper, + app.BankKeeper, + authtypes.FeeCollectorName, ) + app.DistrKeeper = distrkeeper.NewKeeper( - appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), + appCodec, + keys[distrtypes.StoreKey], + app.getSubspace(distrtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + &stakingKeeper, + authtypes.FeeCollectorName, + app.ModuleAccountAddrs(), ) + app.SlashingKeeper = slashingkeeper.NewKeeper( - appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName), + appCodec, + keys[slashingtypes.StoreKey], + &stakingKeeper, + app.getSubspace(slashingtypes.ModuleName), ) + app.CrisisKeeper = crisiskeeper.NewKeeper( - app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, + app.getSubspace(crisistypes.ModuleName), + invCheckPeriod, + app.BankKeeper, + authtypes.FeeCollectorName, ) - app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) - app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper( + appCodec, + keys[feegrant.StoreKey], + app.AccountKeeper, + ) + + app.UpgradeKeeper = upgradekeeper.NewKeeper( + skipUpgradeHeights, + keys[upgradetypes.StoreKey], + appCodec, + homePath, + app.BaseApp, + ) app.UpgradeKeeper.SetUpgradeHandler("v011", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { ctx.Logger().Info("IBC upgrade to v3") @@ -329,18 +431,23 @@ func New( // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks app.StakingKeeper = *stakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), + stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), + app.SlashingKeeper.Hooks()), ) - // ... other modules keepers - // Create IBC Keeper app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + appCodec, keys[ibchost.StoreKey], + app.getSubspace(ibchost.ModuleName), + app.StakingKeeper, + app.UpgradeKeeper, + scopedIBCKeeper, ) authzKeeper := authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), + keys[authzkeeper.StoreKey], + appCodec, + app.MsgServiceRouter(), ) app.AuthzKeeper = authzKeeper @@ -356,7 +463,7 @@ func New( app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], - app.GetSubspace(ibctransfertypes.ModuleName), + app.getSubspace(ibctransfertypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, @@ -374,22 +481,76 @@ func New( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper - app.GovKeeper = govkeeper.NewKeeper( - appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, govRouter, - ) - app.SsiKeeper = *ssimodulekeeper.NewKeeper( appCodec, keys[ssimoduletypes.StoreKey], keys[ssimoduletypes.MemStoreKey], - app.GetSubspace(ssimoduletypes.ModuleName), + app.getSubspace(ssimoduletypes.ModuleName), ) - ssiModule := ssimodule.NewAppModule(appCodec, app.SsiKeeper, app.AccountKeeper, app.BankKeeper) + ssiModule := ssimodule.NewAppModule( + appCodec, + app.SsiKeeper, + app.AccountKeeper, + app.BankKeeper, + ) + + // x/wasm keeper + wasmDir := filepath.Join(homePath, "wasm") + wasmConfig, err := wasm.ReadWasmConfig(appOpts) + if err != nil { + panic(fmt.Sprintf("error while reading wasm config: %s", err)) + } + + // The last arguments can contain custom message handlers, and custom query handlers, + // if we want to allow any custom callbacks + availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1" + + app.WasmKeeper = wasm.NewKeeper( + appCodec, + keys[wasm.StoreKey], + app.getSubspace(wasm.ModuleName), + app.AccountKeeper, + app.BankKeeper, + app.StakingKeeper, + app.DistrKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + scopedWasmKeeper, + app.TransferKeeper, + app.MsgServiceRouter(), + app.GRPCQueryRouter(), + wasmDir, + wasmConfig, + availableCapabilities, + wasmOpts..., + ) + + // The gov proposal types can be individually enabled (x/wasm) + if len(enabledProposals) != 0 { + govRouter.AddRoute( + wasm.RouterKey, + wasm.NewWasmProposalHandler( + app.WasmKeeper, + enabledProposals, + )) + } + + app.GovKeeper = govkeeper.NewKeeper( + appCodec, + keys[govtypes.StoreKey], + app.getSubspace(govtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + &stakingKeeper, + govRouter, + ) + // Create static IBC router, add transfer route, then set and seal it ibcRouter := ibcporttypes.NewRouter() - ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + ibcRouter. + AddRoute(ibctransfertypes.ModuleName, transferIBCModule). + AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper)) app.IBCKeeper.SetRouter(ibcRouter) /**** Module Options ****/ @@ -418,6 +579,7 @@ func New( distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), upgrade.NewAppModule(app.UpgradeKeeper), + wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), params.NewAppModule(app.ParamsKeeper), @@ -448,6 +610,7 @@ func New( genutiltypes.ModuleName, crisistypes.ModuleName, paramstypes.ModuleName, + wasm.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -469,6 +632,7 @@ func New( slashingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, + wasm.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -495,6 +659,7 @@ func New( authz.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, + wasm.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -506,56 +671,80 @@ func New( app.MountTransientStores(tkeys) app.MountMemoryStores(memKeys) - // initialize BaseApp - app.SetInitChainer(app.InitChainer) - app.SetBeginBlocker(app.BeginBlocker) - - anteHandler, err := ante.NewAnteHandler( - ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), - FeegrantKeeper: app.FeeGrantKeeper, - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + anteHandler, err := NewAnteHandler( + HandlerOptions{ + HandlerOptions: ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + FeegrantKeeper: app.FeeGrantKeeper, + SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + IBCKeeper: app.IBCKeeper, + WasmConfig: &wasmConfig, + TXCounterStoreKey: keys[wasm.StoreKey], }, ) if err != nil { - panic(err) + panic(fmt.Errorf("failed to create AnteHandler: %s", err)) } + // initialize BaseApp + app.SetInitChainer(app.InitChainer) + app.SetBeginBlocker(app.BeginBlocker) app.SetAnteHandler(anteHandler) app.SetEndBlocker(app.EndBlocker) + // must be before Loading version + // requires the snapshot store to be created and registered as a BaseAppOption + // see cmd/wasmd/root.go: 206 - 214 approx + if manager := app.SnapshotManager(); manager != nil { + err := manager.RegisterExtensions( + wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmKeeper), + ) + if err != nil { + panic(fmt.Errorf("failed to register snapshot extension: %s", err)) + } + } + if loadLatest { if err := app.LoadLatestVersion(); err != nil { - tmos.Exit(err.Error()) + tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err)) + } + + ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{}) + + // Initialize pinned codes in wasmvm as they are not persisted there + if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil { + tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) } } app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper + app.ScopedWasmKeeper = scopedWasmKeeper return app } // Name returns the name of the App -func (app *App) Name() string { return app.BaseApp.Name() } +func (app *HidnodeApp) Name() string { return app.BaseApp.Name() } // GetBaseApp returns the base app of the application -func (app App) GetBaseApp() *baseapp.BaseApp { return app.BaseApp } +func (app HidnodeApp) GetBaseApp() *baseapp.BaseApp { return app.BaseApp } // BeginBlocker application updates every begin block -func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { +func (app *HidnodeApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { return app.mm.BeginBlock(ctx, req) } // EndBlocker application updates every end block -func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { +func (app *HidnodeApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { return app.mm.EndBlock(ctx, req) } // InitChainer application update at chain initialization -func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *HidnodeApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { var genesisState GenesisState if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) @@ -565,12 +754,12 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res } // LoadHeight loads a particular height -func (app *App) LoadHeight(height int64) error { +func (app *HidnodeApp) LoadHeight(height int64) error { return app.LoadVersion(height) } // ModuleAccountAddrs returns all the app's module account addresses. -func (app *App) ModuleAccountAddrs() map[string]bool { +func (app *HidnodeApp) ModuleAccountAddrs() map[string]bool { modAccAddrs := make(map[string]bool) for acc := range maccPerms { modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true @@ -583,7 +772,7 @@ func (app *App) ModuleAccountAddrs() map[string]bool { // // NOTE: This is solely to be used for testing purposes as it may be desirable // for modules to register their own custom testing types. -func (app *App) LegacyAmino() *codec.LegacyAmino { +func (app *HidnodeApp) LegacyAmino() *codec.LegacyAmino { return app.cdc } @@ -591,47 +780,47 @@ func (app *App) LegacyAmino() *codec.LegacyAmino { // // NOTE: This is solely to be used for testing purposes as it may be desirable // for modules to register their own custom testing types. -func (app *App) AppCodec() codec.Codec { +func (app *HidnodeApp) AppCodec() codec.Codec { return app.appCodec } // InterfaceRegistry returns an InterfaceRegistry -func (app *App) InterfaceRegistry() types.InterfaceRegistry { +func (app *HidnodeApp) InterfaceRegistry() types.InterfaceRegistry { return app.interfaceRegistry } // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. -func (app *App) GetKey(storeKey string) *sdk.KVStoreKey { +func (app *HidnodeApp) GetKey(storeKey string) *sdk.KVStoreKey { return app.keys[storeKey] } // GetTKey returns the TransientStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. -func (app *App) GetTKey(storeKey string) *sdk.TransientStoreKey { +func (app *HidnodeApp) GetTKey(storeKey string) *sdk.TransientStoreKey { return app.tkeys[storeKey] } // GetMemKey returns the MemStoreKey for the provided mem key. // // NOTE: This is solely used for testing purposes. -func (app *App) GetMemKey(storeKey string) *sdk.MemoryStoreKey { +func (app *HidnodeApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey { return app.memKeys[storeKey] } -// GetSubspace returns a param subspace for a given module name. +// getSubspace returns a param subspace for a given module name. // // NOTE: This is solely to be used for testing purposes. -func (app *App) GetSubspace(moduleName string) paramstypes.Subspace { +func (app *HidnodeApp) getSubspace(moduleName string) paramstypes.Subspace { subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) return subspace } // RegisterAPIRoutes registers all application module routes with the provided // API server. -func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { +func (app *HidnodeApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { clientCtx := apiSvr.ClientCtx rpc.RegisterRoutes(clientCtx, apiSvr.Router) // Register legacy tx routes. @@ -651,12 +840,12 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig } // RegisterTxService implements the Application.RegisterTxService method. -func (app *App) RegisterTxService(clientCtx client.Context) { +func (app *HidnodeApp) RegisterTxService(clientCtx client.Context) { authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. -func (app *App) RegisterTendermintService(clientCtx client.Context) { +func (app *HidnodeApp) RegisterTendermintService(clientCtx client.Context) { tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) } @@ -684,11 +873,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) paramsKeeper.Subspace(ssimoduletypes.ModuleName) + paramsKeeper.Subspace(wasm.ModuleName) return paramsKeeper } // SimulationManager implements the SimulationApp interface -func (app *App) SimulationManager() *module.SimulationManager { +func (app *HidnodeApp) SimulationManager() *module.SimulationManager { return app.sm } diff --git a/app/export.go b/app/export.go index 41dcc83..1ca7d25 100644 --- a/app/export.go +++ b/app/export.go @@ -15,7 +15,7 @@ import ( // ExportAppStateAndValidators exports the state of the application for a genesis // file. -func (app *App) ExportAppStateAndValidators( +func (app *HidnodeApp) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs []string, ) (servertypes.ExportedApp, error) { @@ -52,7 +52,7 @@ func (app *App) ExportAppStateAndValidators( // NOTE zero height genesis is a temporary feature which will be deprecated // // in favour of export at a block height -func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { +func (app *HidnodeApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false // check if there is a allowed address list diff --git a/app/prefix.go b/app/prefix.go index 635ce35..8f63090 100644 --- a/app/prefix.go +++ b/app/prefix.go @@ -2,6 +2,7 @@ package app import ( sdk "github.com/cosmos/cosmos-sdk/types" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) const ( @@ -21,5 +22,6 @@ func SetConfig() { config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix) config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix) config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix) + config.SetAddressVerifier(wasmtypes.VerifyAddressLen()) config.Seal() } diff --git a/app/wasm_integration_test.go b/app/wasm_integration_test.go new file mode 100644 index 0000000..6e6150e --- /dev/null +++ b/app/wasm_integration_test.go @@ -0,0 +1,119 @@ +package app + +import ( + "encoding/json" + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + db "github.com/tendermint/tm-db" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/CosmWasm/wasmd/x/wasm" +) + +var emptyWasmOpts []wasm.Option = nil + +type EmptyBaseAppOptions struct{} + +// Get implements AppOptions +func (ao EmptyBaseAppOptions) Get(o string) interface{} { + return nil +} + +func TestWasmdExport(t *testing.T) { + db := db.NewMemDB() + gapp := NewHidnodeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeTestEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) + + encodingConfig := MakeTestEncodingConfig() + genesisState := NewDefaultGenesisState(encodingConfig.Codec) + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + require.NoError(t, err) + + // Initialize the chain + gapp.InitChain( + abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + AppStateBytes: stateBytes, + }, + ) + gapp.Commit() + + // Making a new app object with the db, so that initchain hasn't been called + newGapp := NewHidnodeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeTestEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) + _, err = newGapp.ExportAppStateAndValidators(false, []string{}) + require.NoError(t, err, "ExportAppStateAndValidators should not have an error") +} + +// ensure that blocked addresses are properly set in bank keeper +func TestBlockedAddrs(t *testing.T) { + db := db.NewMemDB() + gapp := NewHidnodeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeTestEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts) + + for acc := range maccPerms { + t.Run(acc, func(t *testing.T) { + require.True(t, gapp.BankKeeper.BlockedAddr(gapp.AccountKeeper.GetModuleAddress(acc)), + "ensure that blocked addresses are properly set in bank keeper", + ) + }) + } +} + +func TestGetMaccPerms(t *testing.T) { + dup := GetMaccPerms() + require.Equal(t, maccPerms, dup, "duplicated module account permissions differed from actual module account permissions") +} + +func TestGetEnabledProposals(t *testing.T) { + cases := map[string]struct { + proposalsEnabled string + specificEnabled string + expected []wasm.ProposalType + }{ + "all disabled": { + proposalsEnabled: "false", + expected: wasm.DisableAllProposals, + }, + "all enabled": { + proposalsEnabled: "true", + expected: wasm.EnableAllProposals, + }, + "some enabled": { + proposalsEnabled: "okay", + specificEnabled: "StoreCode,InstantiateContract", + expected: []wasm.ProposalType{wasm.ProposalTypeStoreCode, wasm.ProposalTypeInstantiateContract}, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + ProposalsEnabled = tc.proposalsEnabled + EnableSpecificProposals = tc.specificEnabled + proposals := GetEnabledProposals() + assert.Equal(t, tc.expected, proposals) + }) + } +} + +func setGenesis(gapp *HidnodeApp) error { + encodingConfig := MakeTestEncodingConfig() + genesisState := NewDefaultGenesisState(encodingConfig.Codec) + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + if err != nil { + return err + } + + // Initialize the chain + gapp.InitChain( + abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + AppStateBytes: stateBytes, + }, + ) + + gapp.Commit() + return nil +} diff --git a/cmd/hid-noded/cmd/root.go b/cmd/hid-noded/cmd/root.go index e30235a..94f07c5 100644 --- a/cmd/hid-noded/cmd/root.go +++ b/cmd/hid-noded/cmd/root.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/keys" @@ -24,6 +25,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + "github.com/prometheus/client_golang/prometheus" "github.com/spf13/cast" "github.com/spf13/cobra" @@ -33,6 +35,9 @@ import ( hidnode "github.com/hypersign-protocol/hid-node/app" "github.com/hypersign-protocol/hid-node/app/params" + + "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" ) // NewRootCmd creates a new root command for simd. It is called once in the @@ -50,12 +55,23 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). WithBroadcastMode(flags.BroadcastBlock). - WithHomeDir(hidnode.DefaultNodeHome) + WithHomeDir(hidnode.DefaultNodeHome). + WithViper("") rootCmd := &cobra.Command{ Use: "hid-noded", Short: "Hypersign Identity Network (hid-noded) CLI", PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { + initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags()) + if err != nil { + return err + } + + initClientCtx, err = config.ReadFromClientConfig(initClientCtx) + if err != nil { + return err + } + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } @@ -106,6 +122,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { func addModuleInitFlags(startCmd *cobra.Command) { crisis.AddModuleInitFlags(startCmd) + wasm.AddModuleInitFlags(startCmd) } func queryCommand() *cobra.Command { @@ -195,12 +212,19 @@ func (ac appCreator) newApp( panic(err) } - return hidnode.New( + var wasmOpts []wasm.Option + if cast.ToBool(appOpts.Get("telemetry.enabled")) { + wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer)) + } + + return hidnode.NewHidnodeApp( logger, db, traceStore, true, skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), ac.encCfg, + hidnode.GetEnabledProposals(), appOpts, + wasmOpts, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), @@ -234,7 +258,8 @@ func (ac appCreator) appExport( loadLatest = true } - gaiaApp := hidnode.New( + var emptyWasmOpts []wasm.Option + hidNodeApp := hidnode.NewHidnodeApp( logger, db, traceStore, @@ -243,14 +268,16 @@ func (ac appCreator) appExport( homePath, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), ac.encCfg, + hidnode.GetEnabledProposals(), appOpts, + emptyWasmOpts, ) if height != -1 { - if err := gaiaApp.LoadHeight(height); err != nil { + if err := hidNodeApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } - return gaiaApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) + return hidNodeApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) } diff --git a/go.mod b/go.mod index 10f0c8f..b17f998 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,13 @@ module github.com/hypersign-protocol/hid-node go 1.18 require ( + github.com/CosmWasm/wasmd v0.29.2 github.com/cosmos/cosmos-sdk v0.45.11 github.com/cosmos/ibc-go/v3 v3.3.0 github.com/gogo/protobuf v1.3.3 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/prometheus/client_golang v1.13.0 github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.6.0 github.com/stretchr/testify v1.8.0 @@ -20,9 +22,10 @@ require ( require ( filippo.io/edwards25519 v1.0.0-beta.2 // indirect - github.com/99designs/keyring v1.1.6 // indirect + github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect + github.com/99designs/keyring v1.2.1 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/DataDog/zstd v1.4.5 // indirect + github.com/CosmWasm/wasmvm v1.1.1 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect github.com/armon/go-metrics v0.4.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -33,20 +36,22 @@ require ( github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect github.com/confio/ics23/go v0.7.0 // indirect github.com/cosmos/btcutil v1.0.4 // indirect + github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect + github.com/cosmos/gogoproto v1.4.2 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/iavl v0.19.4 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect - github.com/danieljoos/wincred v1.0.2 // indirect + github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgraph-io/badger/v2 v2.2007.2 // indirect - github.com/dgraph-io/ristretto v0.0.3 // indirect + github.com/dgraph-io/badger/v2 v2.2007.4 // indirect + github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect - github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect + github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -54,8 +59,10 @@ require ( github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/gateway v1.1.0 // indirect + github.com/golang/glog v1.0.0 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/btree v1.0.0 // indirect + github.com/google/btree v1.1.2 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect @@ -70,7 +77,6 @@ require ( github.com/improbable-eng/grpc-web v0.14.1 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/jmhodges/levigo v1.0.0 // indirect - github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect github.com/klauspost/compress v1.15.11 // indirect github.com/lib/pq v1.10.6 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect @@ -80,7 +86,6 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mr-tron/base58 v1.1.0 // indirect github.com/mtibben/percent v0.2.1 // indirect @@ -91,9 +96,8 @@ require ( github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.34.0 // indirect + github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect github.com/rakyll/statik v0.1.7 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect diff --git a/go.sum b/go.sum index c47b636..b2f20b8 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,11 @@ contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EU dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI= filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= -github.com/99designs/keyring v1.1.6 h1:kVDC2uCgVwecxCk+9zoCt2uEL6dt+dfVzMvGgnVcIuM= +github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= +github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU= +github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o= +github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/Antonboom/errname v0.1.4/go.mod h1:jRXo3m0E0EuCnK3wbsSVH3X55Z4iTDLl6ZfCxwFj4TM= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= @@ -72,9 +75,12 @@ github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/CosmWasm/wasmd v0.29.2 h1:xYZpQjoCixaebMeZs2WGAbBQ8N9PUHVZieuNWy+avI8= +github.com/CosmWasm/wasmd v0.29.2/go.mod h1:agYHzj3R0O+UExLHlXLuEfLqhIrCC+pF5ouAmbe9/68= +github.com/CosmWasm/wasmvm v1.1.1 h1:0xtdrmmsP9fibe+x42WcMkp5aQ738BICgcH3FNVLzm4= +github.com/CosmWasm/wasmvm v1.1.1/go.mod h1:ei0xpvomwSdONsxDuONzV7bL1jSET1M8brEx0FCXc+A= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= @@ -217,6 +223,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= +github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= +github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= github.com/cosmos/cosmos-sdk v0.44.2/go.mod h1:fwQJdw+aECatpTvQTo1tSfHEsxACdZYU80QCZUPnHr4= github.com/cosmos/cosmos-sdk v0.44.3/go.mod h1:bA3+VenaR/l/vDiYzaiwbWvRPWHMBX2jG0ygiFtiBp0= github.com/cosmos/cosmos-sdk v0.45.11 h1:Pc44fFEkai0KXFND5Ys/2ZJkfVdstMIBzKBN8MY7Ll0= @@ -226,6 +234,8 @@ github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpF github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= +github.com/cosmos/gogoproto v1.4.2 h1:UeGRcmFW41l0G0MiefWhkPEVEwvu78SZsHBvI78dAYw= +github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.15.0-rc3.0.20201009144442-230e9bdf52cd/go.mod h1:3xOIaNNX19p0QrX0VqWa6voPRoJRGGYtny+DH8NEPvE= @@ -237,6 +247,7 @@ github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONAp github.com/cosmos/ibc-go v1.2.2/go.mod h1:XmYjsRFOs6Q9Cz+CSsX21icNoH27vQKb3squgnCOCbs= github.com/cosmos/ibc-go/v3 v3.3.0 h1:r8gYUvQreMQrf4R5RgedK9gcbjLk4uE2q6fuZGjf4n0= github.com/cosmos/ibc-go/v3 v3.3.0/go.mod h1:VUWLHw0C3USmTQZnTdkuXXdUdLbW8zsK3lV1Ieposog= +github.com/cosmos/interchain-accounts v0.1.0 h1:QmuwNsf1Hxl3P5GSGt7Z+JeuHPiZw4Z34R/038P5T6s= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -251,8 +262,9 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/daixiang0/gci v0.2.9/go.mod h1:+4dZ7TISfSmqfAGv59ePaHfNzgGtIkHAhhdKggP1JAc= -github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= +github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= +github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -264,11 +276,13 @@ github.com/denis-tingajkin/go-header v0.4.2/go.mod h1:eLRHAVXzE5atsKAnNRDB90WHCF github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger/v2 v2.2007.1/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= -github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= +github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= +github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI= github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= +github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= @@ -284,8 +298,9 @@ github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbT github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b h1:HBah4D48ypg3J7Np4N+HY/ZR76fx3HEUGxDU6Uk39oQ= github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= +github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= +github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= @@ -390,6 +405,8 @@ github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14j github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -427,6 +444,7 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4= @@ -440,8 +458,9 @@ github.com/golangci/misspell v0.3.5/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPP github.com/golangci/revgrep v0.0.0-20210208091834-cd28932614b5/go.mod h1:LK+zW4MpyytAWQRz0M4xnzEk50lSvqDQKfx304apFkY= github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= github.com/google/certificate-transparency-go v1.1.1/go.mod h1:FDKqPvSXawb2ecErVRrD+nfy23RCzyl7eqVCEmlT1Zs= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -455,6 +474,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -630,7 +650,6 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/julz/importas v0.0.0-20210419104244-841f0c0fe66d/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= -github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -641,6 +660,7 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -731,7 +751,6 @@ github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLT github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= @@ -887,8 +906,8 @@ github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= -github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= +github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -908,8 +927,8 @@ github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16 github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.34.0 h1:RBmGO9d/FVjqHT0yUGQwBJhkwKV+wPCn7KGpvfab0uE= -github.com/prometheus/common v0.34.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= +github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -1406,6 +1425,7 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1699,6 +1719,7 @@ mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jC mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7/go.mod h1:hBpJkZE8H/sb+VRFvw2+rBpHNsTBcvSpk61hr8mzXZE= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= From f24004336cb87b7b142e03c0811268f1631e9c8f Mon Sep 17 00:00:00 2001 From: arnabghose997 Date: Tue, 24 Jan 2023 09:24:10 +0530 Subject: [PATCH 02/11] fixed common tx flags by adding --output json flag --- tests/e2e/ssi_tests/transactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/ssi_tests/transactions.py b/tests/e2e/ssi_tests/transactions.py index f9f0959..905a95d 100644 --- a/tests/e2e/ssi_tests/transactions.py +++ b/tests/e2e/ssi_tests/transactions.py @@ -7,7 +7,7 @@ import json from utils import run_command -COMMON_TX_COMMAND_FLAGS = "--chain-id hidnode --broadcast-mode block --keyring-backend test --yes" +COMMON_TX_COMMAND_FLAGS = "--chain-id hidnode --output json --broadcast-mode block --keyring-backend test --yes" def form_did_create_tx(did_doc, kp, blockchain_account, verificationMethodId=None, signing_algo="ed25519"): private_key = kp["priv_key_base_64"] From c7ef717a6e8a65c41c60985daf68d97533b6b6cb Mon Sep 17 00:00:00 2001 From: arnabghose997 Date: Tue, 31 Jan 2023 10:13:13 +0530 Subject: [PATCH 03/11] lint fix: removed unused setGenesis() function --- app/wasm_integration_test.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/app/wasm_integration_test.go b/app/wasm_integration_test.go index 6e6150e..2965b6e 100644 --- a/app/wasm_integration_test.go +++ b/app/wasm_integration_test.go @@ -98,22 +98,3 @@ func TestGetEnabledProposals(t *testing.T) { } } -func setGenesis(gapp *HidnodeApp) error { - encodingConfig := MakeTestEncodingConfig() - genesisState := NewDefaultGenesisState(encodingConfig.Codec) - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - if err != nil { - return err - } - - // Initialize the chain - gapp.InitChain( - abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - AppStateBytes: stateBytes, - }, - ) - - gapp.Commit() - return nil -} From a8fca3b7214eedfad9f1e2d48df15dfcc27c1fc8 Mon Sep 17 00:00:00 2001 From: Arnab Ghose Date: Tue, 25 Jul 2023 21:31:01 +0530 Subject: [PATCH 04/11] feat: added identityfee module to make ssi related transactions incur fixed fee --- app/ante.go | 53 ++ app/app.go | 36 +- client/docs/config.json | 3 + client/docs/swagger-ui/swagger.yaml | 210 ++++++- proto/identityfee/v1/genesis.proto | 17 + proto/identityfee/v1/query.proto | 26 + tests/e2e/ssi_tests/transactions.py | 22 +- x/identityfee/ante/decorators.go | 260 +++++++++ x/identityfee/ante/types.go | 25 + x/identityfee/client/cli/query.go | 51 ++ x/identityfee/genesis.go | 36 ++ x/identityfee/keeper/grpc_query.go | 27 + x/identityfee/keeper/keeper.go | 33 ++ x/identityfee/keeper/params.go | 15 + x/identityfee/module.go | 163 ++++++ x/identityfee/types/genesis.go | 27 + x/identityfee/types/genesis.pb.go | 614 ++++++++++++++++++++ x/identityfee/types/keys.go | 15 + x/identityfee/types/params.go | 20 + x/identityfee/types/query.pb.go | 847 ++++++++++++++++++++++++++++ x/identityfee/types/query.pb.gw.go | 153 +++++ 21 files changed, 2623 insertions(+), 30 deletions(-) create mode 100644 app/ante.go create mode 100644 proto/identityfee/v1/genesis.proto create mode 100644 proto/identityfee/v1/query.proto create mode 100644 x/identityfee/ante/decorators.go create mode 100644 x/identityfee/ante/types.go create mode 100644 x/identityfee/client/cli/query.go create mode 100644 x/identityfee/genesis.go create mode 100644 x/identityfee/keeper/grpc_query.go create mode 100644 x/identityfee/keeper/keeper.go create mode 100644 x/identityfee/keeper/params.go create mode 100644 x/identityfee/module.go create mode 100644 x/identityfee/types/genesis.go create mode 100644 x/identityfee/types/genesis.pb.go create mode 100644 x/identityfee/types/keys.go create mode 100644 x/identityfee/types/params.go create mode 100644 x/identityfee/types/query.pb.go create mode 100644 x/identityfee/types/query.pb.gw.go diff --git a/app/ante.go b/app/ante.go new file mode 100644 index 0000000..b69aa85 --- /dev/null +++ b/app/ante.go @@ -0,0 +1,53 @@ +package app + +import ( + "github.com/cosmos/cosmos-sdk/x/auth/ante" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + identityfeeante "github.com/hypersign-protocol/hid-node/x/identityfee/ante" +) + +type HandlerOptions struct { + ante.HandlerOptions + + IdentityFeeKeeper identityfeeante.IdentityFeeKeeper +} + +func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { + if options.AccountKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder") + } + + if options.BankKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder") + } + + if options.SignModeHandler == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") + } + + sigGasConsumer := options.SigGasConsumer + if sigGasConsumer == nil { + sigGasConsumer = ante.DefaultSigVerificationGasConsumer + } + + anteDecorators := []sdk.AnteDecorator{ + ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + ante.NewRejectExtensionOptionsDecorator(), + identityfeeante.NewSSITxDecorator(), + identityfeeante.NewMempoolFeeDecorator(), + ante.NewValidateBasicDecorator(), + ante.NewTxTimeoutHeightDecorator(), + ante.NewValidateMemoDecorator(options.AccountKeeper), + ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), + identityfeeante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.IdentityFeeKeeper), + ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators + ante.NewValidateSigCountDecorator(options.AccountKeeper), + ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer), + ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), + ante.NewIncrementSequenceDecorator(options.AccountKeeper), + } + + return sdk.ChainAnteDecorators(anteDecorators...), nil +} diff --git a/app/app.go b/app/app.go index eed15f0..8a2a515 100644 --- a/app/app.go +++ b/app/app.go @@ -99,6 +99,10 @@ import ( ssimodule "github.com/hypersign-protocol/hid-node/x/ssi" ssimodulekeeper "github.com/hypersign-protocol/hid-node/x/ssi/keeper" ssimoduletypes "github.com/hypersign-protocol/hid-node/x/ssi/types" + + identifyfeemodule "github.com/hypersign-protocol/hid-node/x/identityfee" + identifyfeekeeper "github.com/hypersign-protocol/hid-node/x/identityfee/keeper" + identifyfeetypes "github.com/hypersign-protocol/hid-node/x/identityfee/types" ) const ( @@ -146,6 +150,7 @@ var ( transfer.AppModuleBasic{}, authzmodule.AppModuleBasic{}, ssimodule.AppModuleBasic{}, + identifyfeemodule.AppModuleBasic{}, ) // module account permissions @@ -209,6 +214,7 @@ type App struct { TransferKeeper ibctransferkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper AuthzKeeper authzkeeper.Keeper + IdentityFeeKeeper identifyfeekeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -372,6 +378,12 @@ func New( ) ssiModule := ssimodule.NewAppModule(appCodec, app.SsiKeeper, app.AccountKeeper, app.BankKeeper) + app.IdentityFeeKeeper = *identifyfeekeeper.NewKeeper( + appCodec, + app.GetSubspace(identifyfeetypes.ModuleName), + ) + identityFeeModule := identifyfeemodule.NewAppModule(appCodec, app.IdentityFeeKeeper) + // Create static IBC router, add transfer route, then set and seal it ibcRouter := ibcporttypes.NewRouter() ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) @@ -408,6 +420,7 @@ func New( params.NewAppModule(app.ParamsKeeper), transferModule, ssiModule, + identityFeeModule, ) // During begin block slashing happens after distr.BeginBlocker so that @@ -430,6 +443,7 @@ func New( feegrant.ModuleName, authz.ModuleName, ssimoduletypes.ModuleName, + identifyfeetypes.ModuleName, genutiltypes.ModuleName, crisistypes.ModuleName, paramstypes.ModuleName, @@ -445,6 +459,7 @@ func New( distrtypes.ModuleName, upgradetypes.ModuleName, ssimoduletypes.ModuleName, + identifyfeetypes.ModuleName, genutiltypes.ModuleName, feegrant.ModuleName, authz.ModuleName, @@ -476,6 +491,7 @@ func New( evidencetypes.ModuleName, ibctransfertypes.ModuleName, ssimoduletypes.ModuleName, + identifyfeetypes.ModuleName, feegrant.ModuleName, authz.ModuleName, paramstypes.ModuleName, @@ -495,13 +511,16 @@ func New( app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) - anteHandler, err := ante.NewAnteHandler( - ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), - FeegrantKeeper: app.FeeGrantKeeper, - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + anteHandler, err := NewAnteHandler( + HandlerOptions{ + HandlerOptions: ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), + FeegrantKeeper: app.FeeGrantKeeper, + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + IdentityFeeKeeper: app.IdentityFeeKeeper, }, ) if err != nil { @@ -669,7 +688,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) paramsKeeper.Subspace(ssimoduletypes.ModuleName) - + paramsKeeper.Subspace(identifyfeetypes.ModuleName).WithKeyTable(identifyfeetypes.ParamKeyTable()) + return paramsKeeper } diff --git a/client/docs/config.json b/client/docs/config.json index 6f9b03d..933a217 100644 --- a/client/docs/config.json +++ b/client/docs/config.json @@ -9,6 +9,9 @@ { "url": "./.cache/tmp/swagger-gen/ssi/v1/query.swagger.json" }, + { + "url": "./.cache/tmp/swagger-gen/identityfee/v1/query.swagger.json" + }, { "url": "https://github.com/cosmos/cosmos-sdk/raw/v0.45.7/client/docs/swagger-ui/swagger.yaml", "dereference": { diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 1fe7318..21d87f1 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -257,6 +257,8 @@ paths: type: string publicKeyMultibase: type: string + blockchainAccountId: + type: string authentication: type: array items: @@ -424,6 +426,8 @@ paths: type: string publicKeyMultibase: type: string + blockchainAccountId: + type: string authentication: type: array items: @@ -722,12 +726,121 @@ paths: type: string tags: - Query + /hypersign-protocol/hidnode/identityfee: + get: + summary: Get the list of fixed fees for every x/ssi module transactions + operationId: QuerySSIFee + responses: + '200': + description: A successful response. + schema: + type: object + properties: + create_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + update_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + deactivate_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + create_schema_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + register_credential_status_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + tags: + - Query /node_info: get: description: Information about the connected node summary: The properties of the connected node tags: - - Service + - Gaia REST produces: - application/json responses: @@ -24608,6 +24721,8 @@ definitions: type: string publicKeyMultibase: type: string + blockchainAccountId: + type: string authentication: type: array items: @@ -24764,6 +24879,8 @@ definitions: type: string publicKeyMultibase: type: string + blockchainAccountId: + type: string authentication: type: array items: @@ -24847,6 +24964,8 @@ definitions: type: string publicKeyMultibase: type: string + blockchainAccountId: + type: string authentication: type: array items: @@ -25087,6 +25206,83 @@ definitions: type: string publicKeyMultibase: type: string + blockchainAccountId: + type: string + cosmos.base.v1beta1.Coin: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + hypersignprotocol.hidnode.identityfee.QuerySSIFeeResponse: + type: object + properties: + create_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + update_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + deactivate_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + create_schema_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + register_credential_status_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. CheckTxResult: type: object properties: @@ -27328,18 +27524,6 @@ definitions: description: |- SendEnabled maps coin denom to a send_enabled status (whether a denom is sendable). - cosmos.base.v1beta1.Coin: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse: type: object properties: diff --git a/proto/identityfee/v1/genesis.proto b/proto/identityfee/v1/genesis.proto new file mode 100644 index 0000000..cc22827 --- /dev/null +++ b/proto/identityfee/v1/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package hypersignprotocol.hidnode.identityfee; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/hypersign-protocol/hid-node/x/identityfee/types"; +option (gogoproto.equal_all) = true; + +// GenesisState defines the identityfee module's genesis state. +message GenesisState { + cosmos.base.v1beta1.Coin create_did_fee = 1; + cosmos.base.v1beta1.Coin update_did_fee = 2; + cosmos.base.v1beta1.Coin deactivate_did_fee = 3; + cosmos.base.v1beta1.Coin create_schema_fee = 4; + cosmos.base.v1beta1.Coin register_credential_status_fee = 5; +} diff --git a/proto/identityfee/v1/query.proto b/proto/identityfee/v1/query.proto new file mode 100644 index 0000000..cb6cf05 --- /dev/null +++ b/proto/identityfee/v1/query.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package hypersignprotocol.hidnode.identityfee; + +import "google/api/annotations.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/hypersign-protocol/hid-node/x/identityfee/types"; +option (gogoproto.equal_all) = true; + +service Query { + // Get the list of fixed fees for every x/ssi module transactions + rpc QuerySSIFee(QuerySSIFeeRequest) returns (QuerySSIFeeResponse) { + option (google.api.http).get = "/hypersign-protocol/hidnode/identityfee"; + } +} + +message QuerySSIFeeRequest {} + +message QuerySSIFeeResponse { + cosmos.base.v1beta1.Coin create_did_fee = 1; + cosmos.base.v1beta1.Coin update_did_fee = 2; + cosmos.base.v1beta1.Coin deactivate_did_fee = 3; + cosmos.base.v1beta1.Coin create_schema_fee = 4; + cosmos.base.v1beta1.Coin register_credential_status_fee = 5; +} diff --git a/tests/e2e/ssi_tests/transactions.py b/tests/e2e/ssi_tests/transactions.py index 3c4eb88..45637c1 100644 --- a/tests/e2e/ssi_tests/transactions.py +++ b/tests/e2e/ssi_tests/transactions.py @@ -7,7 +7,11 @@ import json from utils import run_command -COMMON_TX_COMMAND_FLAGS = "--chain-id hidnode --output json --broadcast-mode block --keyring-backend test --yes" +COMMON_CREATE_DID_TX_COMMAND_FLAGS = "--chain-id hidnode --output json --broadcast-mode block --fees 4000uhid --keyring-backend test --yes" +COMMON_UPDATE_DID_TX_COMMAND_FLAGS = "--chain-id hidnode --output json --broadcast-mode block --fees 1000uhid --keyring-backend test --yes" +COMMON_DEACTIVATE_DID_COMMAND_FLAGS = "--chain-id hidnode --output json --broadcast-mode block --fees 1000uhid --keyring-backend test --yes" +COMMON_CREATE_SCHEMA_COMMAND_FLAGS = "--chain-id hidnode --output json --broadcast-mode block --fees 2000uhid --keyring-backend test --yes" +COMMON_REGISTER_CREDENTIAL_STATUS_COMMAND_FLAGS = "--chain-id hidnode --output json --broadcast-mode block --fees 2000uhid --keyring-backend test --yes" def form_did_create_tx_multisig(diddoc, signPairs, blockchain_account): signPairStr = "" @@ -24,7 +28,7 @@ def form_did_create_tx_multisig(diddoc, signPairs, blockchain_account): signPairStr += f"{vmId} {private_key} {signAlgo} " - cmd_string = f"hid-noded tx ssi create-did '{json.dumps(diddoc)}' {signPairStr} --from {blockchain_account} " + COMMON_TX_COMMAND_FLAGS + cmd_string = f"hid-noded tx ssi create-did '{json.dumps(diddoc)}' {signPairStr} --from {blockchain_account} " + COMMON_CREATE_DID_TX_COMMAND_FLAGS return cmd_string def form_did_update_tx_multisig(diddoc, signPairs, blockchain_account): @@ -43,7 +47,7 @@ def form_did_update_tx_multisig(diddoc, signPairs, blockchain_account): signPairStr += f"{vmId} {private_key} {signAlgo} " version_id = query_did(diddoc["id"])["didDocumentMetadata"]["versionId"] - cmd_string = f"hid-noded tx ssi update-did '{json.dumps(diddoc)}' '{version_id}' {signPairStr} --from {blockchain_account} " + COMMON_TX_COMMAND_FLAGS + cmd_string = f"hid-noded tx ssi update-did '{json.dumps(diddoc)}' '{version_id}' {signPairStr} --from {blockchain_account} " + COMMON_UPDATE_DID_TX_COMMAND_FLAGS return cmd_string def form_did_deactivate_tx_multisig(didId, signPairs, blockchain_account): @@ -62,7 +66,7 @@ def form_did_deactivate_tx_multisig(didId, signPairs, blockchain_account): signPairStr += f"{vmId} {private_key} {signAlgo} " version_id = query_did(didId)["didDocumentMetadata"]["versionId"] - cmd_string = f"hid-noded tx ssi deactivate-did '{didId}' '{version_id}' {signPairStr} --from {blockchain_account} " + COMMON_TX_COMMAND_FLAGS + cmd_string = f"hid-noded tx ssi deactivate-did '{didId}' '{version_id}' {signPairStr} --from {blockchain_account} " + COMMON_DEACTIVATE_DID_COMMAND_FLAGS return cmd_string def form_did_create_tx(did_doc, kp, blockchain_account, verificationMethodId=None, signing_algo="ed25519"): @@ -74,15 +78,15 @@ def form_did_create_tx(did_doc, kp, blockchain_account, verificationMethodId=Non if not verificationMethodId: verificationMethodId = did_doc["authentication"][0] - cmd_string = f"hid-noded tx ssi create-did '{json.dumps(did_doc)}' {verificationMethodId} {private_key} {signing_algo} --from {blockchain_account} " + COMMON_TX_COMMAND_FLAGS + cmd_string = f"hid-noded tx ssi create-did '{json.dumps(did_doc)}' {verificationMethodId} {private_key} {signing_algo} --from {blockchain_account} " + COMMON_CREATE_DID_TX_COMMAND_FLAGS return cmd_string def form_create_schema_tx(schema_msg, schema_proof, blockchain_account): - cmd_string = f"hid-noded tx ssi create-schema '{json.dumps(schema_msg)}' '{json.dumps(schema_proof)}' --from {blockchain_account} " + COMMON_TX_COMMAND_FLAGS + cmd_string = f"hid-noded tx ssi create-schema '{json.dumps(schema_msg)}' '{json.dumps(schema_proof)}' --from {blockchain_account} " + COMMON_CREATE_SCHEMA_COMMAND_FLAGS return cmd_string def form_create_cred_status_tx(cred_msg, cred_proof, blockchain_account): - cmd_string = f"hid-noded tx ssi register-credential-status '{json.dumps(cred_msg)}' '{json.dumps(cred_proof)}' --from {blockchain_account} " + COMMON_TX_COMMAND_FLAGS + cmd_string = f"hid-noded tx ssi register-credential-status '{json.dumps(cred_msg)}' '{json.dumps(cred_proof)}' --from {blockchain_account} " + COMMON_REGISTER_CREDENTIAL_STATUS_COMMAND_FLAGS return cmd_string def form_did_update_tx(did_doc, kp, blockchain_account, verificationMethodId=None, signing_algo="ed25519"): @@ -94,7 +98,7 @@ def form_did_update_tx(did_doc, kp, blockchain_account, verificationMethodId=Non if not verificationMethodId: verificationMethodId = did_doc["authentication"][0] version_id = query_did(did_doc["id"])["didDocumentMetadata"]["versionId"] - cmd_string = f"hid-noded tx ssi update-did '{json.dumps(did_doc)}' '{version_id}' '{verificationMethodId}' {private_key} {signing_algo} --from {blockchain_account} " + COMMON_TX_COMMAND_FLAGS + cmd_string = f"hid-noded tx ssi update-did '{json.dumps(did_doc)}' '{version_id}' '{verificationMethodId}' {private_key} {signing_algo} --from {blockchain_account} " + COMMON_UPDATE_DID_TX_COMMAND_FLAGS return cmd_string def form_did_deactivate_tx(did_doc_id, kp, blockchain_account, verificationMethodId=None, signing_algo="ed25519"): @@ -106,7 +110,7 @@ def form_did_deactivate_tx(did_doc_id, kp, blockchain_account, verificationMetho if not verificationMethodId: verificationMethodId = query_did(did_doc_id)["didDocument"]["authentication"][0] version_id = query_did(did_doc_id)["didDocumentMetadata"]["versionId"] - cmd_string = f"hid-noded tx ssi deactivate-did '{did_doc_id}' '{version_id}' '{verificationMethodId}' {private_key} {signing_algo} --from {blockchain_account} " + COMMON_TX_COMMAND_FLAGS + cmd_string = f"hid-noded tx ssi deactivate-did '{did_doc_id}' '{version_id}' '{verificationMethodId}' {private_key} {signing_algo} --from {blockchain_account} " + COMMON_DEACTIVATE_DID_COMMAND_FLAGS return cmd_string def query_did(did_id): diff --git a/x/identityfee/ante/decorators.go b/x/identityfee/ante/decorators.go new file mode 100644 index 0000000..def5930 --- /dev/null +++ b/x/identityfee/ante/decorators.go @@ -0,0 +1,260 @@ +package ante + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/types" + identityfeetypes "github.com/hypersign-protocol/hid-node/x/identityfee/types" + ssitypes "github.com/hypersign-protocol/hid-node/x/ssi/types" +) + +type DeductFeeDecorator struct { + ak AccountKeeper + bankKeeper BankKeeper + feegrantKeeper FeegrantKeeper + identityFeeKeeper IdentityFeeKeeper +} + +// ModifiedFeeDecorator extends NewDeductFeeDecorator by making all x/ssi module related transactions incur fixed fee cost. +// Fixed fee is seperate for each x/ssi module transactions and are updated through Governance based proposals. Please refer +// HIP-9 to know more: https://github.com/hypersign-protocol/HIPs/blob/main/HIPs/hip-9.md +func NewDeductFeeDecorator(ak AccountKeeper, bk BankKeeper, fk FeegrantKeeper, ifk IdentityFeeKeeper) DeductFeeDecorator { + return DeductFeeDecorator{ + ak: ak, + bankKeeper: bk, + feegrantKeeper: fk, + identityFeeKeeper: ifk, + } +} + +func (mfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") + } + + if addr := mfd.ak.GetModuleAddress(types.FeeCollectorName); addr == nil { + return ctx, fmt.Errorf("fee collector module account (%s) has not been set", types.FeeCollectorName) + } + + fee := feeTx.GetFee() + feePayer := feeTx.FeePayer() + feeGranter := feeTx.FeeGranter() + deductFeesFrom := feePayer + + // if feegranter set deduct fee from feegranter account. + // this works with only when feegrant enabled. + if feeGranter != nil { + if mfd.feegrantKeeper == nil { + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee grants are not enabled") + } else if !feeGranter.Equals(feePayer) { + err := mfd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, tx.GetMsgs()) + if err != nil { + return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", feeGranter, feePayer) + } + } + + deductFeesFrom = feeGranter + } + deductFeesFromAcc := mfd.ak.GetAccount(ctx, deductFeesFrom) + + // Get the mint module address + if deductFeesFromAcc == nil { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", deductFeesFrom) + } + + // If present, calculate the total fee of all fixed-cost x/ssi messages + if isSSIMsgPresentInTx(feeTx) { + var fixedSSIFee sdk.Coins = sdk.NewCoins(sdk.NewCoin("uhid", sdk.NewInt(0))) + + for _, msg := range tx.GetMsgs() { + switch msg.(type) { + case *ssitypes.MsgCreateDID: + createDidFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyCreateDidFee) + fixedSSIFee = fixedSSIFee.Add(createDidFee) + case *ssitypes.MsgUpdateDID: + updateDidFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyUpdateDidFee) + fixedSSIFee = fixedSSIFee.Add(updateDidFee) + case *ssitypes.MsgDeactivateDID: + deactivateDidFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyDeactivateDidFee) + fixedSSIFee = fixedSSIFee.Add(deactivateDidFee) + case *ssitypes.MsgCreateSchema: + createSchemaFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyCreateSchemaFee) + fixedSSIFee = fixedSSIFee.Add(createSchemaFee) + case *ssitypes.MsgRegisterCredentialStatus: + registerCredentialStatusFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyRegisterCredentialStatusFee) + fixedSSIFee = fixedSSIFee.Add(registerCredentialStatusFee) + } + } + + // If there is atleast one x/ssi message, check if the fee provided meets the requirement for the fixedSSIFee by asserting if the former + // is greater than or equal to the latter. If fixedSSIFee is Zero, go ahead with normal fee deduction + if !fee.IsEqual(fixedSSIFee) { + errMsg1 := "the transaction consists of x/ssi module based messages which incurs fixed cost. " + errMsg2 := "The fee provided MUST BE equal to the required fees which is the sum of all fixed-fee x/ssi. " + errMsg3 := "To know about the fixed-fee cost of all x/ssi transactions, refer to the API endpoint /hypersign-protocol/hidnode/identityfee . " + + return ctx, sdkerrors.Wrapf( + sdkerrors.ErrInsufficientFee, + errMsg1+errMsg2+errMsg3+"expected fees to be %v, got %v", + fixedSSIFee.String(), + fee.String(), + ) + } + + // Deduct fixed SSI fee + err := deductFees(mfd.bankKeeper, ctx, deductFeesFromAcc, fee) + if err != nil { + return ctx, err + } + + events := sdk.Events{ + sdk.NewEvent( + sdk.EventTypeTx, + sdk.NewAttribute(sdk.AttributeKeyFee, fixedSSIFee.String()), + sdk.NewAttribute(sdk.AttributeKeyFeePayer, deductFeesFrom.String()), + ), + } + ctx.EventManager().EmitEvents(events) + + return next(ctx, tx, simulate) + } + + // Deduct default fees + if !feeTx.GetFee().IsZero() { + err := deductFees(mfd.bankKeeper, ctx, deductFeesFromAcc, fee) + if err != nil { + return ctx, err + } + } + + events := sdk.Events{ + sdk.NewEvent( + sdk.EventTypeTx, + sdk.NewAttribute(sdk.AttributeKeyFee, fee.String()), + sdk.NewAttribute(sdk.AttributeKeyFeePayer, deductFeesFrom.String()), + ), + } + ctx.EventManager().EmitEvents(events) + + return next(ctx, tx, simulate) +} + +// deductFees deducts fees from the given account. +func deductFees(bankKeeper BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error { + if !fees.IsValid() { + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) + } + + err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, fees) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) + } + + return nil +} + +// isSSIMsgPresentInTx checks if there is any SSI message present in the transaction +func isSSIMsgPresentInTx(tx sdk.Tx) bool { + for _, msg := range tx.GetMsgs() { + if isSSIMsg(msg) { + return true + } + } + + return false +} + +// isNonSSIMsgPresentInTx checks if there is any non-SSI message present in the transaction +func isNonSSIMsgPresentInTx(tx sdk.Tx) bool { + for _, msg := range tx.GetMsgs() { + if !isSSIMsg(msg) { + return true + } + } + + return false +} + +// isSSIMsg checks if the message is of SSI type or not +func isSSIMsg(msg sdk.Msg) bool { + switch msg.(type) { + case *ssitypes.MsgCreateDID: + return true + case *ssitypes.MsgUpdateDID: + return true + case *ssitypes.MsgDeactivateDID: + return true + case *ssitypes.MsgCreateSchema: + return true + case *ssitypes.MsgRegisterCredentialStatus: + return true + default: + return false + } +} + +// MempoolFeeDecorator will check if the transaction's fee is at least as large +// as the local validator's minimum gasFee (defined in validator config). +// If fee is too low, decorator returns error and tx is rejected from mempool. +// Note this only applies when ctx.CheckTx = true and transaction with only non-SSI messages +// If fee is high enough or not CheckTx or the transaction consists of only SSI messages, then call next AnteHandler +// CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator +type MempoolFeeDecorator struct{} + +func NewMempoolFeeDecorator() MempoolFeeDecorator { + return MempoolFeeDecorator{} +} + +func (mfd MempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") + } + + feeCoins := feeTx.GetFee() + gas := feeTx.GetGas() + + // Ensure that the provided fees meet a minimum threshold for the validator, + // if this is a CheckTx. This is only for local mempool purposes, and thus + // is only ran on check tx. SSI messages incur fixed fee regardless of their size + // and hence any transaction consisting of only SSI messages should skip the following check + if ctx.IsCheckTx() && !simulate && !isSSIMsgPresentInTx(feeTx) { + minGasPrices := ctx.MinGasPrices() + if !minGasPrices.IsZero() { + requiredFees := make(sdk.Coins, len(minGasPrices)) + + // Determine the required fees by multiplying each required minimum gas + // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). + glDec := sdk.NewDec(int64(gas)) + for i, gp := range minGasPrices { + fee := gp.Amount.Mul(glDec) + requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) + } + + if !feeCoins.IsAnyGTE(requiredFees) { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) + } + } + } + + return next(ctx, tx, simulate) +} + +// SSITxDecorator ensures that any transaction which contains SSI messages should not have messages of other modules, since fees for +// SSI messages are fixed regardless of the size of message, they should not be mixed other module's messages. +type SSITxDecorator struct{} + +func NewSSITxDecorator() SSITxDecorator { + return SSITxDecorator{} +} + +func (ssifd SSITxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + if isNonSSIMsgPresentInTx(tx) && isSSIMsgPresentInTx(tx) { + return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "ssi transaction messages cannot be grouped with other module messages") + } + + return next(ctx, tx, simulate) +} diff --git a/x/identityfee/ante/types.go b/x/identityfee/ante/types.go new file mode 100644 index 0000000..ef409cc --- /dev/null +++ b/x/identityfee/ante/types.go @@ -0,0 +1,25 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +type AccountKeeper interface { + GetParams(ctx sdk.Context) (params types.Params) + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + SetAccount(ctx sdk.Context, acc types.AccountI) + GetModuleAddress(moduleName string) sdk.AccAddress +} + +type BankKeeper interface { + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error +} + +type FeegrantKeeper interface { + UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error +} + +type IdentityFeeKeeper interface { + GetFeeParams(ctx sdk.Context, identityfeeParamStoreKey []byte) sdk.Coin +} diff --git a/x/identityfee/client/cli/query.go b/x/identityfee/client/cli/query.go new file mode 100644 index 0000000..b4b0907 --- /dev/null +++ b/x/identityfee/client/cli/query.go @@ -0,0 +1,51 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/hypersign-protocol/hid-node/x/identityfee/types" + "github.com/spf13/cobra" +) + +// GetQueryCmd returns the cli query commands for identityfee module +func GetQueryCmd() *cobra.Command { + // Group identityfee queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(cmdListFees()) + return cmd +} + + +func cmdListFees() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-fees", + Short: "List fee for all SSI based transactions", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QuerySSIFee(cmd.Context(), &types.QuerySSIFeeRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} \ No newline at end of file diff --git a/x/identityfee/genesis.go b/x/identityfee/genesis.go new file mode 100644 index 0000000..e963325 --- /dev/null +++ b/x/identityfee/genesis.go @@ -0,0 +1,36 @@ +package ssifee + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/hypersign-protocol/hid-node/x/identityfee/keeper" + "github.com/hypersign-protocol/hid-node/x/identityfee/types" +) + +// InitGenesis initializes the identityfee module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + k.SetFeeParam(ctx, *genState.CreateDidFee, types.ParamStoreKeyCreateDidFee) + k.SetFeeParam(ctx, *genState.UpdateDidFee, types.ParamStoreKeyUpdateDidFee) + k.SetFeeParam(ctx, *genState.DeactivateDidFee, types.ParamStoreKeyDeactivateDidFee) + k.SetFeeParam(ctx, *genState.CreateSchemaFee, types.ParamStoreKeyCreateSchemaFee) + k.SetFeeParam(ctx, *genState.RegisterCredentialStatusFee, types.ParamStoreKeyRegisterCredentialStatusFee) +} + +// ExportGenesis returns the identity module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + + createDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyCreateDidFee) + updateDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyUpdateDidFee) + deactivateDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyDeactivateDidFee) + createSchemaFee := k.GetFeeParams(ctx, types.ParamStoreKeyCreateSchemaFee) + registerCredentialStatusFee := k.GetFeeParams(ctx, types.ParamStoreKeyRegisterCredentialStatusFee) + + genesis.CreateDidFee = &createDidFee + genesis.UpdateDidFee = &updateDidFee + genesis.DeactivateDidFee = &deactivateDidFee + genesis.CreateSchemaFee = &createSchemaFee + genesis.RegisterCredentialStatusFee = ®isterCredentialStatusFee + + return genesis +} diff --git a/x/identityfee/keeper/grpc_query.go b/x/identityfee/keeper/grpc_query.go new file mode 100644 index 0000000..4ed0b43 --- /dev/null +++ b/x/identityfee/keeper/grpc_query.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/hypersign-protocol/hid-node/x/identityfee/types" +) + +// QuerySSIFee fetches fees for all SSI based transactions +func (k Keeper) QuerySSIFee(goCtx context.Context, _ *types.QuerySSIFeeRequest) (*types.QuerySSIFeeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + createDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyCreateDidFee) + updateDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyUpdateDidFee) + deactivateDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyDeactivateDidFee) + createSchemaFee := k.GetFeeParams(ctx, types.ParamStoreKeyCreateSchemaFee) + registerCredentialStatusFee := k.GetFeeParams(ctx, types.ParamStoreKeyRegisterCredentialStatusFee) + + return &types.QuerySSIFeeResponse{ + CreateDidFee: &createDidFee, + UpdateDidFee: &updateDidFee, + DeactivateDidFee: &deactivateDidFee, + CreateSchemaFee: &createSchemaFee, + RegisterCredentialStatusFee: ®isterCredentialStatusFee, + }, nil +} diff --git a/x/identityfee/keeper/keeper.go b/x/identityfee/keeper/keeper.go new file mode 100644 index 0000000..99444a9 --- /dev/null +++ b/x/identityfee/keeper/keeper.go @@ -0,0 +1,33 @@ +package keeper + +import ( + "fmt" + + "github.com/tendermint/tendermint/libs/log" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/hypersign-protocol/hid-node/x/identityfee/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + paramSpace paramtypes.Subspace + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + ps paramtypes.Subspace, +) *Keeper { + return &Keeper{ + cdc: cdc, + paramSpace: ps, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/identityfee/keeper/params.go b/x/identityfee/keeper/params.go new file mode 100644 index 0000000..a8502a3 --- /dev/null +++ b/x/identityfee/keeper/params.go @@ -0,0 +1,15 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetFeeParam(ctx sdk.Context, fee sdk.Coin, identityfeeParamStoreKey []byte) { + k.paramSpace.Set(ctx, identityfeeParamStoreKey, fee) +} + +func (k Keeper) GetFeeParams(ctx sdk.Context, identityfeeParamStoreKey []byte) sdk.Coin { + var fee sdk.Coin + k.paramSpace.Get(ctx, identityfeeParamStoreKey, &fee) + return fee +} diff --git a/x/identityfee/module.go b/x/identityfee/module.go new file mode 100644 index 0000000..0ac8a56 --- /dev/null +++ b/x/identityfee/module.go @@ -0,0 +1,163 @@ +package ssifee + +import ( + "context" + "encoding/json" + "fmt" + "log" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/hypersign-protocol/hid-node/x/identityfee/client/cli" + "github.com/hypersign-protocol/hid-node/x/identityfee/keeper" + "github.com/hypersign-protocol/hid-node/x/identityfee/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { +} + +// DefaultGenesis returns the ssi module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + log.Fatal(err) + } +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + + +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the capability module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the capability module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the ssi module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the ssi module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 2 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/identityfee/types/genesis.go b/x/identityfee/types/genesis.go new file mode 100644 index 0000000..3720af9 --- /dev/null +++ b/x/identityfee/types/genesis.go @@ -0,0 +1,27 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + DefaultCreateDIDFee = sdk.NewInt64Coin("uhid", 4000) + DefaultUpdateDIDFee = sdk.NewInt64Coin("uhid", 1000) + DefaultDeactivateDIDFee = sdk.NewInt64Coin("uhid", 1000) + DefaultCreateSchemaFee = sdk.NewInt64Coin("uhid", 2000) + DefaultRegisterCredentialStatusFee = sdk.NewInt64Coin("uhid", 2000) +) + +func DefaultGenesis() *GenesisState { + return &GenesisState{ + CreateDidFee: &DefaultCreateDIDFee, + UpdateDidFee: &DefaultUpdateDIDFee, + DeactivateDidFee: &DefaultDeactivateDIDFee, + CreateSchemaFee: &DefaultCreateSchemaFee, + RegisterCredentialStatusFee: &DefaultRegisterCredentialStatusFee, + } +} + +func (gs GenesisState) Validate() error { + return nil +} diff --git a/x/identityfee/types/genesis.pb.go b/x/identityfee/types/genesis.pb.go new file mode 100644 index 0000000..7e24732 --- /dev/null +++ b/x/identityfee/types/genesis.pb.go @@ -0,0 +1,614 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: identityfee/v1/genesis.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +// GenesisState defines the ssifee module's genesis state. +type GenesisState struct { + CreateDidFee *types.Coin `protobuf:"bytes,1,opt,name=create_did_fee,json=createDidFee,proto3" json:"create_did_fee,omitempty"` + UpdateDidFee *types.Coin `protobuf:"bytes,2,opt,name=update_did_fee,json=updateDidFee,proto3" json:"update_did_fee,omitempty"` + DeactivateDidFee *types.Coin `protobuf:"bytes,3,opt,name=deactivate_did_fee,json=deactivateDidFee,proto3" json:"deactivate_did_fee,omitempty"` + CreateSchemaFee *types.Coin `protobuf:"bytes,4,opt,name=create_schema_fee,json=createSchemaFee,proto3" json:"create_schema_fee,omitempty"` + RegisterCredentialStatusFee *types.Coin `protobuf:"bytes,5,opt,name=register_credential_status_fee,json=registerCredentialStatusFee,proto3" json:"register_credential_status_fee,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_14d65fa1d8b5cdf2, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetCreateDidFee() *types.Coin { + if m != nil { + return m.CreateDidFee + } + return nil +} + +func (m *GenesisState) GetUpdateDidFee() *types.Coin { + if m != nil { + return m.UpdateDidFee + } + return nil +} + +func (m *GenesisState) GetDeactivateDidFee() *types.Coin { + if m != nil { + return m.DeactivateDidFee + } + return nil +} + +func (m *GenesisState) GetCreateSchemaFee() *types.Coin { + if m != nil { + return m.CreateSchemaFee + } + return nil +} + +func (m *GenesisState) GetRegisterCredentialStatusFee() *types.Coin { + if m != nil { + return m.RegisterCredentialStatusFee + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "hypersignprotocol.hidnode.identityfee.GenesisState") +} + +func init() { proto.RegisterFile("identityfee/v1/genesis.proto", fileDescriptor_14d65fa1d8b5cdf2) } + +var fileDescriptor_14d65fa1d8b5cdf2 = []byte{ + // 339 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0xd2, 0x3f, 0x4b, 0xc3, 0x40, + 0x18, 0xc7, 0xf1, 0xc6, 0xaa, 0x43, 0x2c, 0xfe, 0x29, 0x0e, 0x5a, 0xe5, 0x10, 0x41, 0x70, 0xe9, + 0x1d, 0xd5, 0xcd, 0x45, 0xb0, 0xda, 0xee, 0x76, 0x11, 0x07, 0xc3, 0xe5, 0xee, 0x69, 0x72, 0xd0, + 0xe6, 0x42, 0xee, 0x69, 0xb1, 0x9b, 0x2f, 0xc1, 0x97, 0xe1, 0x4b, 0x71, 0xec, 0xe8, 0x28, 0xe9, + 0x1b, 0x91, 0xdc, 0xa5, 0x35, 0x5b, 0xb6, 0x84, 0xdc, 0xf7, 0x13, 0x12, 0x7e, 0xfe, 0xb9, 0x92, + 0x90, 0xa0, 0xc2, 0xc5, 0x18, 0x80, 0xcd, 0x7b, 0x2c, 0x82, 0x04, 0x8c, 0x32, 0x34, 0xcd, 0x34, + 0xea, 0xf6, 0x55, 0xbc, 0x48, 0x21, 0x33, 0x2a, 0x4a, 0xec, 0xbd, 0xd0, 0x13, 0x1a, 0x2b, 0x99, + 0x68, 0x09, 0xb4, 0xd2, 0x75, 0x8e, 0x23, 0x1d, 0x69, 0x7b, 0x82, 0x15, 0x57, 0x2e, 0xee, 0x10, + 0xa1, 0xcd, 0x54, 0x1b, 0x16, 0x72, 0x53, 0xd0, 0x21, 0x20, 0xef, 0x31, 0xa1, 0x55, 0xe2, 0x9e, + 0x5f, 0x7e, 0x34, 0xfd, 0xd6, 0xd0, 0xbd, 0x6e, 0x84, 0x1c, 0xa1, 0x7d, 0xef, 0xef, 0x8b, 0x0c, + 0x38, 0x42, 0x20, 0x95, 0x0c, 0xc6, 0x00, 0x27, 0xde, 0x85, 0x77, 0xbd, 0x77, 0x73, 0x4a, 0x9d, + 0x44, 0x0b, 0x89, 0x96, 0x12, 0xed, 0x6b, 0x95, 0x3c, 0xb7, 0x5c, 0xf0, 0xa8, 0xe4, 0x00, 0x2c, + 0x30, 0x4b, 0x65, 0x15, 0xd8, 0xaa, 0x05, 0x5c, 0x50, 0x02, 0x43, 0xbf, 0x2d, 0x81, 0x0b, 0x54, + 0xf3, 0x2a, 0xd2, 0xac, 0x43, 0x0e, 0xff, 0xa3, 0x12, 0x7a, 0xf2, 0x8f, 0xca, 0x4f, 0x31, 0x22, + 0x86, 0x29, 0xb7, 0xce, 0x76, 0x9d, 0x73, 0xe0, 0x9a, 0x91, 0x4d, 0x0a, 0xe6, 0xcd, 0x27, 0x19, + 0x44, 0xca, 0x20, 0x64, 0x81, 0xc8, 0xc0, 0xfe, 0x72, 0x3e, 0x09, 0x0c, 0x72, 0x9c, 0x19, 0x6b, + 0xee, 0xd4, 0x99, 0x67, 0x6b, 0xa0, 0xbf, 0xe9, 0x47, 0x36, 0x1f, 0x00, 0x3c, 0xbc, 0x7c, 0xe5, + 0xc4, 0xfb, 0xce, 0x89, 0xb7, 0xcc, 0x89, 0xf7, 0x9b, 0x13, 0xef, 0x73, 0x45, 0x1a, 0xcb, 0x15, + 0x69, 0xfc, 0xac, 0x48, 0xe3, 0xf5, 0x2e, 0x52, 0x18, 0xcf, 0x42, 0x2a, 0xf4, 0x94, 0x6d, 0x86, + 0xd0, 0x5d, 0x2f, 0x81, 0xc5, 0x4a, 0x76, 0x8b, 0x29, 0xb0, 0x77, 0x56, 0x1d, 0x11, 0x2e, 0x52, + 0x30, 0xe1, 0xae, 0x3d, 0x76, 0xfb, 0x17, 0x00, 0x00, 0xff, 0xff, 0x2d, 0xa5, 0x4e, 0xe3, 0x60, + 0x02, 0x00, 0x00, +} + +func (this *GenesisState) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*GenesisState) + if !ok { + that2, ok := that.(GenesisState) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.CreateDidFee.Equal(that1.CreateDidFee) { + return false + } + if !this.UpdateDidFee.Equal(that1.UpdateDidFee) { + return false + } + if !this.DeactivateDidFee.Equal(that1.DeactivateDidFee) { + return false + } + if !this.CreateSchemaFee.Equal(that1.CreateSchemaFee) { + return false + } + if !this.RegisterCredentialStatusFee.Equal(that1.RegisterCredentialStatusFee) { + return false + } + return true +} +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RegisterCredentialStatusFee != nil { + { + size, err := m.RegisterCredentialStatusFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.CreateSchemaFee != nil { + { + size, err := m.CreateSchemaFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.DeactivateDidFee != nil { + { + size, err := m.DeactivateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.UpdateDidFee != nil { + { + size, err := m.UpdateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.CreateDidFee != nil { + { + size, err := m.CreateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreateDidFee != nil { + l = m.CreateDidFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.UpdateDidFee != nil { + l = m.UpdateDidFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.DeactivateDidFee != nil { + l = m.DeactivateDidFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.CreateSchemaFee != nil { + l = m.CreateSchemaFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.RegisterCredentialStatusFee != nil { + l = m.RegisterCredentialStatusFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CreateDidFee == nil { + m.CreateDidFee = &types.Coin{} + } + if err := m.CreateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateDidFee == nil { + m.UpdateDidFee = &types.Coin{} + } + if err := m.UpdateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeactivateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DeactivateDidFee == nil { + m.DeactivateDidFee = &types.Coin{} + } + if err := m.DeactivateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateSchemaFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CreateSchemaFee == nil { + m.CreateSchemaFee = &types.Coin{} + } + if err := m.CreateSchemaFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RegisterCredentialStatusFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RegisterCredentialStatusFee == nil { + m.RegisterCredentialStatusFee = &types.Coin{} + } + if err := m.RegisterCredentialStatusFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/identityfee/types/keys.go b/x/identityfee/types/keys.go new file mode 100644 index 0000000..edf3f4d --- /dev/null +++ b/x/identityfee/types/keys.go @@ -0,0 +1,15 @@ +package types + +const ( + ModuleName = "identityfee" + + QuerierRoute = ModuleName +) + +var ( + ParamStoreKeyCreateDidFee = []byte("CreateDidFee") + ParamStoreKeyUpdateDidFee = []byte("UpdateDidFee") + ParamStoreKeyDeactivateDidFee = []byte("DeactivateDidFee") + ParamStoreKeyCreateSchemaFee = []byte("CreateSchemaFee") + ParamStoreKeyRegisterCredentialStatusFee = []byte("RegisterCredentialStatusFee") +) \ No newline at end of file diff --git a/x/identityfee/types/params.go b/x/identityfee/types/params.go new file mode 100644 index 0000000..9290f69 --- /dev/null +++ b/x/identityfee/types/params.go @@ -0,0 +1,20 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable( + paramtypes.NewParamSetPair(ParamStoreKeyCreateDidFee, sdk.Coin{}, validateFeeParams), + paramtypes.NewParamSetPair(ParamStoreKeyUpdateDidFee, sdk.Coin{}, validateFeeParams), + paramtypes.NewParamSetPair(ParamStoreKeyDeactivateDidFee, sdk.Coin{}, validateFeeParams), + paramtypes.NewParamSetPair(ParamStoreKeyCreateSchemaFee, sdk.Coin{}, validateFeeParams), + paramtypes.NewParamSetPair(ParamStoreKeyRegisterCredentialStatusFee, sdk.Coin{}, validateFeeParams), + ) +} + +func validateFeeParams(i interface{}) error { + return nil +} \ No newline at end of file diff --git a/x/identityfee/types/query.pb.go b/x/identityfee/types/query.pb.go new file mode 100644 index 0000000..36d68ff --- /dev/null +++ b/x/identityfee/types/query.pb.go @@ -0,0 +1,847 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: identityfee/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 QuerySSIFeeRequest struct { +} + +func (m *QuerySSIFeeRequest) Reset() { *m = QuerySSIFeeRequest{} } +func (m *QuerySSIFeeRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySSIFeeRequest) ProtoMessage() {} +func (*QuerySSIFeeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_657f65a9c7940d56, []int{0} +} +func (m *QuerySSIFeeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySSIFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySSIFeeRequest.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 *QuerySSIFeeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySSIFeeRequest.Merge(m, src) +} +func (m *QuerySSIFeeRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySSIFeeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySSIFeeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySSIFeeRequest proto.InternalMessageInfo + +type QuerySSIFeeResponse struct { + CreateDidFee *types.Coin `protobuf:"bytes,1,opt,name=create_did_fee,json=createDidFee,proto3" json:"create_did_fee,omitempty"` + UpdateDidFee *types.Coin `protobuf:"bytes,2,opt,name=update_did_fee,json=updateDidFee,proto3" json:"update_did_fee,omitempty"` + DeactivateDidFee *types.Coin `protobuf:"bytes,3,opt,name=deactivate_did_fee,json=deactivateDidFee,proto3" json:"deactivate_did_fee,omitempty"` + CreateSchemaFee *types.Coin `protobuf:"bytes,4,opt,name=create_schema_fee,json=createSchemaFee,proto3" json:"create_schema_fee,omitempty"` + RegisterCredentialStatusFee *types.Coin `protobuf:"bytes,5,opt,name=register_credential_status_fee,json=registerCredentialStatusFee,proto3" json:"register_credential_status_fee,omitempty"` +} + +func (m *QuerySSIFeeResponse) Reset() { *m = QuerySSIFeeResponse{} } +func (m *QuerySSIFeeResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySSIFeeResponse) ProtoMessage() {} +func (*QuerySSIFeeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_657f65a9c7940d56, []int{1} +} +func (m *QuerySSIFeeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySSIFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySSIFeeResponse.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 *QuerySSIFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySSIFeeResponse.Merge(m, src) +} +func (m *QuerySSIFeeResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySSIFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySSIFeeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySSIFeeResponse proto.InternalMessageInfo + +func (m *QuerySSIFeeResponse) GetCreateDidFee() *types.Coin { + if m != nil { + return m.CreateDidFee + } + return nil +} + +func (m *QuerySSIFeeResponse) GetUpdateDidFee() *types.Coin { + if m != nil { + return m.UpdateDidFee + } + return nil +} + +func (m *QuerySSIFeeResponse) GetDeactivateDidFee() *types.Coin { + if m != nil { + return m.DeactivateDidFee + } + return nil +} + +func (m *QuerySSIFeeResponse) GetCreateSchemaFee() *types.Coin { + if m != nil { + return m.CreateSchemaFee + } + return nil +} + +func (m *QuerySSIFeeResponse) GetRegisterCredentialStatusFee() *types.Coin { + if m != nil { + return m.RegisterCredentialStatusFee + } + return nil +} + +func init() { + proto.RegisterType((*QuerySSIFeeRequest)(nil), "hypersignprotocol.hidnode.identityfee.QuerySSIFeeRequest") + proto.RegisterType((*QuerySSIFeeResponse)(nil), "hypersignprotocol.hidnode.identityfee.QuerySSIFeeResponse") +} + +func init() { proto.RegisterFile("identityfee/v1/query.proto", fileDescriptor_657f65a9c7940d56) } + +var fileDescriptor_657f65a9c7940d56 = []byte{ + // 426 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0x3f, 0x6f, 0xd4, 0x30, + 0x18, 0x06, 0xf0, 0x73, 0x4b, 0x19, 0x5c, 0xc4, 0x9f, 0xd0, 0x01, 0x0e, 0x64, 0xa1, 0x93, 0x10, + 0x30, 0xd4, 0x56, 0xcb, 0x44, 0x17, 0x24, 0x0a, 0x87, 0x18, 0x69, 0x16, 0xc4, 0x40, 0xe4, 0xd8, + 0x6f, 0x13, 0x4b, 0x77, 0x7e, 0xd3, 0xd8, 0xa9, 0xc8, 0xca, 0xc2, 0x8a, 0xc4, 0x97, 0xe0, 0x0b, + 0x30, 0xb3, 0x32, 0x56, 0x62, 0x61, 0x44, 0x39, 0x3e, 0x08, 0x8a, 0x93, 0x96, 0x20, 0x84, 0x82, + 0xba, 0x39, 0x4e, 0x9e, 0xdf, 0x1b, 0xeb, 0x31, 0x9d, 0x1a, 0x0d, 0xd6, 0x1b, 0x5f, 0x1f, 0x02, + 0x88, 0xe3, 0x1d, 0x71, 0x54, 0x41, 0x59, 0xf3, 0xa2, 0x44, 0x8f, 0xd1, 0xdd, 0xbc, 0x2e, 0xa0, + 0x74, 0x26, 0xb3, 0xe1, 0x59, 0xe1, 0x82, 0xe7, 0x46, 0x5b, 0xd4, 0xc0, 0x07, 0xa9, 0xe9, 0xed, + 0x0c, 0x31, 0x5b, 0x80, 0x90, 0x85, 0x11, 0xd2, 0x5a, 0xf4, 0xd2, 0x1b, 0xb4, 0xae, 0x43, 0xa6, + 0x4c, 0xa1, 0x5b, 0xa2, 0x13, 0xa9, 0x74, 0xed, 0x80, 0x14, 0xbc, 0xdc, 0x11, 0x0a, 0x8d, 0xed, + 0xdf, 0x6f, 0x65, 0x98, 0x61, 0x58, 0x8a, 0x76, 0xd5, 0xed, 0xce, 0xb6, 0x68, 0xf4, 0xb2, 0xfd, + 0x93, 0x38, 0x7e, 0x31, 0x07, 0x38, 0x80, 0xa3, 0x0a, 0x9c, 0x9f, 0xbd, 0x5f, 0xa7, 0xd7, 0xff, + 0xd8, 0x76, 0x05, 0x5a, 0x07, 0xd1, 0x63, 0x7a, 0x59, 0x95, 0x20, 0x3d, 0x24, 0xda, 0xe8, 0xe4, + 0x10, 0xe0, 0x06, 0xb9, 0x43, 0xee, 0x6f, 0xee, 0xde, 0xe4, 0xdd, 0x70, 0xde, 0x0e, 0xe7, 0xfd, + 0x70, 0xbe, 0x8f, 0xc6, 0x1e, 0x5c, 0xea, 0x02, 0x4f, 0x8d, 0x9e, 0x43, 0x00, 0xaa, 0x42, 0x0f, + 0x81, 0xb5, 0x51, 0xa0, 0x0b, 0xf4, 0xc0, 0x73, 0x1a, 0x69, 0x90, 0xca, 0x9b, 0xe3, 0x21, 0xb2, + 0x3e, 0x86, 0x5c, 0xfd, 0x1d, 0xea, 0xa1, 0x67, 0xf4, 0x5a, 0x7f, 0x14, 0xa7, 0x72, 0x58, 0xca, + 0xe0, 0x5c, 0x18, 0x73, 0xae, 0x74, 0x99, 0x38, 0x44, 0x5a, 0xe6, 0x0d, 0x65, 0x25, 0x64, 0xc6, + 0x79, 0x28, 0x13, 0x55, 0x42, 0x68, 0x4b, 0x2e, 0x12, 0xe7, 0xa5, 0xaf, 0x5c, 0x30, 0x37, 0xc6, + 0xcc, 0x5b, 0xa7, 0xc0, 0xfe, 0x59, 0x3e, 0x0e, 0xf1, 0x39, 0xc0, 0xee, 0x17, 0x42, 0x37, 0x42, + 0x13, 0xd1, 0x67, 0x42, 0x37, 0x07, 0x9d, 0x44, 0x8f, 0xf8, 0x7f, 0xdd, 0x1a, 0xfe, 0x77, 0xbd, + 0xd3, 0xbd, 0xf3, 0x44, 0xbb, 0x2b, 0x30, 0x13, 0xef, 0xbe, 0xfd, 0xfc, 0xb8, 0xf6, 0x20, 0xba, + 0x27, 0xce, 0x8c, 0xed, 0x53, 0x44, 0xf4, 0x88, 0x18, 0x20, 0x4f, 0x5e, 0x7d, 0x6a, 0x18, 0xf9, + 0xda, 0x30, 0x72, 0xd2, 0x30, 0xf2, 0xa3, 0x61, 0xe4, 0xc3, 0x8a, 0x4d, 0x4e, 0x56, 0x6c, 0xf2, + 0x7d, 0xc5, 0x26, 0xaf, 0xf7, 0x32, 0xe3, 0xf3, 0x2a, 0xe5, 0x0a, 0x97, 0xff, 0x00, 0xb7, 0x83, + 0xf8, 0x76, 0x68, 0x0a, 0x5f, 0x17, 0xe0, 0xd2, 0x8b, 0xe1, 0xb3, 0x87, 0xbf, 0x02, 0x00, 0x00, + 0xff, 0xff, 0xfc, 0xb7, 0xf5, 0x5c, 0x5b, 0x03, 0x00, 0x00, +} + +func (this *QuerySSIFeeRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*QuerySSIFeeRequest) + if !ok { + that2, ok := that.(QuerySSIFeeRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *QuerySSIFeeResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*QuerySSIFeeResponse) + if !ok { + that2, ok := that.(QuerySSIFeeResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.CreateDidFee.Equal(that1.CreateDidFee) { + return false + } + if !this.UpdateDidFee.Equal(that1.UpdateDidFee) { + return false + } + if !this.DeactivateDidFee.Equal(that1.DeactivateDidFee) { + return false + } + if !this.CreateSchemaFee.Equal(that1.CreateSchemaFee) { + return false + } + if !this.RegisterCredentialStatusFee.Equal(that1.RegisterCredentialStatusFee) { + return false + } + return true +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Get the list of fixed fees for every x/ssi module transactions + QuerySSIFee(ctx context.Context, in *QuerySSIFeeRequest, opts ...grpc.CallOption) (*QuerySSIFeeResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) QuerySSIFee(ctx context.Context, in *QuerySSIFeeRequest, opts ...grpc.CallOption) (*QuerySSIFeeResponse, error) { + out := new(QuerySSIFeeResponse) + err := c.cc.Invoke(ctx, "/hypersignprotocol.hidnode.identityfee.Query/QuerySSIFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Get the list of fixed fees for every x/ssi module transactions + QuerySSIFee(context.Context, *QuerySSIFeeRequest) (*QuerySSIFeeResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) QuerySSIFee(ctx context.Context, req *QuerySSIFeeRequest) (*QuerySSIFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QuerySSIFee not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_QuerySSIFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySSIFeeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QuerySSIFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hypersignprotocol.hidnode.identityfee.Query/QuerySSIFee", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QuerySSIFee(ctx, req.(*QuerySSIFeeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "hypersignprotocol.hidnode.identityfee.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "QuerySSIFee", + Handler: _Query_QuerySSIFee_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "identityfee/v1/query.proto", +} + +func (m *QuerySSIFeeRequest) 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 *QuerySSIFeeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySSIFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QuerySSIFeeResponse) 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 *QuerySSIFeeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySSIFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RegisterCredentialStatusFee != nil { + { + size, err := m.RegisterCredentialStatusFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.CreateSchemaFee != nil { + { + size, err := m.CreateSchemaFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.DeactivateDidFee != nil { + { + size, err := m.DeactivateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.UpdateDidFee != nil { + { + size, err := m.UpdateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.CreateDidFee != nil { + { + size, err := m.CreateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QuerySSIFeeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QuerySSIFeeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreateDidFee != nil { + l = m.CreateDidFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.UpdateDidFee != nil { + l = m.UpdateDidFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.DeactivateDidFee != nil { + l = m.DeactivateDidFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.CreateSchemaFee != nil { + l = m.CreateSchemaFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.RegisterCredentialStatusFee != nil { + l = m.RegisterCredentialStatusFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QuerySSIFeeRequest) 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 ErrIntOverflowQuery + } + 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: QuerySSIFeeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySSIFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySSIFeeResponse) 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 ErrIntOverflowQuery + } + 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: QuerySSIFeeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySSIFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CreateDidFee == nil { + m.CreateDidFee = &types.Coin{} + } + if err := m.CreateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateDidFee == nil { + m.UpdateDidFee = &types.Coin{} + } + if err := m.UpdateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeactivateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DeactivateDidFee == nil { + m.DeactivateDidFee = &types.Coin{} + } + if err := m.DeactivateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateSchemaFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CreateSchemaFee == nil { + m.CreateSchemaFee = &types.Coin{} + } + if err := m.CreateSchemaFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RegisterCredentialStatusFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RegisterCredentialStatusFee == nil { + m.RegisterCredentialStatusFee = &types.Coin{} + } + if err := m.RegisterCredentialStatusFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/identityfee/types/query.pb.gw.go b/x/identityfee/types/query.pb.gw.go new file mode 100644 index 0000000..e395f5b --- /dev/null +++ b/x/identityfee/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: identityfee/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_QuerySSIFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySSIFeeRequest + var metadata runtime.ServerMetadata + + msg, err := client.QuerySSIFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QuerySSIFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySSIFeeRequest + var metadata runtime.ServerMetadata + + msg, err := server.QuerySSIFee(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_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_QuerySSIFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"hypersign-protocol", "hidnode", "identityfee"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_QuerySSIFee_0 = runtime.ForwardResponseMessage +) From a734c4c677de3407bab3680b081ab811572379b8 Mon Sep 17 00:00:00 2001 From: Arnab Ghose Date: Wed, 26 Jul 2023 18:11:42 +0530 Subject: [PATCH 05/11] added tests for fixed fee ssi txs --- .../ssi_tests/broadcast_txs/tx_broadcast.json | 1 + tests/e2e/ssi_tests/e2e_tests.py | 113 +++++++++++++++++- tests/e2e/ssi_tests/generate_doc.py | 41 +++++++ tests/e2e/ssi_tests/run.py | 2 + 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/ssi_tests/broadcast_txs/tx_broadcast.json diff --git a/tests/e2e/ssi_tests/broadcast_txs/tx_broadcast.json b/tests/e2e/ssi_tests/broadcast_txs/tx_broadcast.json new file mode 100644 index 0000000..fc2d93a --- /dev/null +++ b/tests/e2e/ssi_tests/broadcast_txs/tx_broadcast.json @@ -0,0 +1 @@ +{"body":{"messages":[{"@type":"/hypersignprotocol.hidnode.ssi.MsgCreateDID","didDocString":{"context":["https://www.w3.org/ns/did/v1"],"id":"did:hid:devnet:zJ959XC5ArA2CKzA6weShfX7dMeJFHsGdF4aKZreEsNas","controller":["did:hid:devnet:zJ959XC5ArA2CKzA6weShfX7dMeJFHsGdF4aKZreEsNas"],"alsoKnownAs":[],"verificationMethod":[{"id":"did:hid:devnet:zJ959XC5ArA2CKzA6weShfX7dMeJFHsGdF4aKZreEsNas#k1","type":"Ed25519VerificationKey2020","controller":"did:hid:devnet:zJ959XC5ArA2CKzA6weShfX7dMeJFHsGdF4aKZreEsNas","publicKeyMultibase":"zJ959XC5ArA2CKzA6weShfX7dMeJFHsGdF4aKZreEsNas","blockchainAccountId":""}],"authentication":[],"assertionMethod":[],"keyAgreement":[],"capabilityInvocation":[],"capabilityDelegation":[],"service":[]},"signatures":[{"verification_method_id":"did:hid:devnet:zJ959XC5ArA2CKzA6weShfX7dMeJFHsGdF4aKZreEsNas#k1","signature":"s57Xc+v7ZwMTYJwbeybPgOFEWAv+BIot+1PpEFtdYne5XGjDJYxIXtb4dHRFCV4nt+hyKoSZgE5VVSO/NhlHCA==","clientSpec":null}],"creator":"hid17eq5ykk3dxh3uhfpy67gznf50wr9ydx2fz0mnq"},{"@type":"/hypersignprotocol.hidnode.ssi.MsgCreateDID","didDocString":{"context":["https://www.w3.org/ns/did/v1"],"id":"did:hid:devnet:z5VTY7sxgRzVVrvFLJdHyefg9dzW6FNCzY4zFdY6axMQt","controller":["did:hid:devnet:z5VTY7sxgRzVVrvFLJdHyefg9dzW6FNCzY4zFdY6axMQt"],"alsoKnownAs":[],"verificationMethod":[{"id":"did:hid:devnet:z5VTY7sxgRzVVrvFLJdHyefg9dzW6FNCzY4zFdY6axMQt#k1","type":"Ed25519VerificationKey2020","controller":"did:hid:devnet:z5VTY7sxgRzVVrvFLJdHyefg9dzW6FNCzY4zFdY6axMQt","publicKeyMultibase":"z5VTY7sxgRzVVrvFLJdHyefg9dzW6FNCzY4zFdY6axMQt","blockchainAccountId":""}],"authentication":[],"assertionMethod":[],"keyAgreement":[],"capabilityInvocation":[],"capabilityDelegation":[],"service":[]},"signatures":[{"verification_method_id":"did:hid:devnet:z5VTY7sxgRzVVrvFLJdHyefg9dzW6FNCzY4zFdY6axMQt#k1","signature":"pLLZOFgY2JCobd9yAvuHe8iNFtzrOfgyR+iqlUghbxQbcRvMIzpOxfrnqxsVqIOk4f4JFayg5FQgQnuX0fOzDQ==","clientSpec":null}],"creator":"hid17eq5ykk3dxh3uhfpy67gznf50wr9ydx2fz0mnq"},{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"hid17eq5ykk3dxh3uhfpy67gznf50wr9ydx2fz0mnq","to_address":"hid1gmhlnhj7zpr6dmdqagqhu2uww92vgj6f9wqrz2","amount":[{"denom":"uhid","amount":"10000000"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A10zRiyF+DCDixJ+Tb1bq5Q8OVbKTlRDONfWUnwkNfxT"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"11"}],"fee":{"amount":[{"denom":"uhid","amount":"8000"}],"gas_limit":"200000","payer":"","granter":""}},"signatures":["rFmlkLDDMUChYsm0JwSAtUahGxGesGvnT7p+W0prvrxERmDaKN+0J9ZKvgNGd2Jbf73MtlRURSNH9+2vouePcA=="]} diff --git a/tests/e2e/ssi_tests/e2e_tests.py b/tests/e2e/ssi_tests/e2e_tests.py index 2139395..db33428 100644 --- a/tests/e2e/ssi_tests/e2e_tests.py +++ b/tests/e2e/ssi_tests/e2e_tests.py @@ -4,11 +4,122 @@ import time from utils import run_blockchain_command, generate_key_pair, secp256k1_pubkey_to_address, add_keyAgreeemnt_pubKeyMultibase -from generate_doc import generate_did_document, generate_schema_document, generate_cred_status_document +from generate_doc import generate_did_document, generate_schema_document, generate_cred_status_document, generate_multi_vm_did from transactions import form_did_create_tx_multisig, form_did_update_tx_multisig, \ query_did, form_create_schema_tx, form_did_deactivate_tx_multisig, form_create_cred_status_tx from constants import DEFAULT_BLOCKCHAIN_ACCOUNT_NAME +def big_did_tx_test(): + print("\n-- Executing a CreatDID Tx with the DID Document having 230 Verification Methods and only paying the param fee for CreateDID (4000uhid)--\n") + + keyPairs = [] + n_vms = 230 + for i in range(0, n_vms): + kp = generate_key_pair() + keyPairs.append(kp) + + signers = [] + did_doc_string = generate_multi_vm_did(keyPairs) + did_doc_alice = did_doc_string["id"] + + for i in range(0, n_vms): + signer = { + "kp": keyPairs[i], + "verificationMethodId": did_doc_string["verificationMethod"][i]["id"], + "signing_algo": "ed25519" + } + signers.append(signer) + + create_tx_cmd = form_did_create_tx_multisig(did_doc_string, signers, DEFAULT_BLOCKCHAIN_ACCOUNT_NAME) + create_tx_cmd = create_tx_cmd + " --gas 85687400" + run_blockchain_command(create_tx_cmd, f"Registering Alice's DID with Id: {did_doc_alice}") + print("-- Test Completed --\n") + +def ssi_fee_test(): + print("\n--- Fixed Fee SSI Tx Test ---\n") + + print("--1. FAIL: Paying invalid fee for CreateDID Tx--\n") + kp_alice = generate_key_pair() + signers = [] + did_doc_string = generate_did_document(kp_alice) + did_doc_alice = did_doc_string["id"] + signPair_alice = { + "kp": kp_alice, + "verificationMethodId": did_doc_string["verificationMethod"][0]["id"], + "signing_algo": "ed25519" + } + signers.append(signPair_alice) + create_tx_cmd = form_did_create_tx_multisig(did_doc_string, signers, DEFAULT_BLOCKCHAIN_ACCOUNT_NAME) + create_tx_cmd = create_tx_cmd.replace("--fees 4000uhid", "--fees 7043uhid") + run_blockchain_command(create_tx_cmd, f"Registering Alice's DID with Id: {did_doc_alice}", True) + + print("--2. PASS: Paying valid fee for CreateDID Tx--\n") + create_tx_cmd = create_tx_cmd.replace("--fees 7043uhid", "--fees 4000uhid") + run_blockchain_command(create_tx_cmd, f"Registering Alice's DID with Id: {did_doc_alice}") + + print("--3. FAIL: Paying invalid fee for UpdateDID Tx--\n") + did_doc_string["context"] = ["someContext"] + update_tx_cmd = form_did_update_tx_multisig(did_doc_string, signers, DEFAULT_BLOCKCHAIN_ACCOUNT_NAME) + update_tx_cmd = update_tx_cmd.replace("--fees 1000uhid", "--fees 67043uhid") + run_blockchain_command(update_tx_cmd, f"Updating Alice's DID with Id: {did_doc_alice}", True) + + print("--4. PASS: Paying valid fee for UpdateDID Tx--\n") + update_tx_cmd = update_tx_cmd.replace("--fees 67043uhid", "--fees 1000uhid") + run_blockchain_command(update_tx_cmd, f"Updating Alice's DID with Id: {did_doc_alice}") + + print("--5. FAIL: Paying invalid fee for CreateSchema Tx--\n") + schema_doc, schema_proof = generate_schema_document( + kp_alice, + did_doc_alice, + did_doc_string["verificationMethod"][0]["id"] + ) + create_schema_cmd = form_create_schema_tx( + schema_doc, + schema_proof, + DEFAULT_BLOCKCHAIN_ACCOUNT_NAME + ) + create_schema_cmd = create_schema_cmd.replace("--fees 2000uhid", "--fees 4700uhid") + schema_doc_id = schema_doc["id"] + run_blockchain_command(create_schema_cmd, f"Registering Schema with Id: {schema_doc_id}", True) + + print("--6. PASS: Paying valid fee for CreateSchema Tx--\n") + create_schema_cmd = create_schema_cmd.replace("--fees 4700uhid", "--fees 2000uhid") + run_blockchain_command(create_schema_cmd, f"Registering Schema with Id: {schema_doc_id}") + + print("--7. FAIL: Paying invalid fee for RegisterCredentialStatus Tx --\n") + cred_doc, cred_proof = generate_cred_status_document( + kp_alice, + did_doc_alice, + did_doc_string["verificationMethod"][0]["id"] + ) + register_cred_status_cmd = form_create_cred_status_tx( + cred_doc, + cred_proof, + DEFAULT_BLOCKCHAIN_ACCOUNT_NAME + ) + cred_id = cred_doc["claim"]["id"] + register_cred_status_cmd = register_cred_status_cmd.replace("--fees 2000uhid", "--fees 3700uhid") + run_blockchain_command(register_cred_status_cmd, f"Registering Credential status with Id: {cred_id}", True) + + print("--8. PASS: Paying valid fee for RegisterCredentialStatus Tx --\n") + register_cred_status_cmd = register_cred_status_cmd.replace("--fees 3700uhid", "--fees 2000uhid") + run_blockchain_command(register_cred_status_cmd, f"Registering Credential status with Id: {cred_id}") + + print("--9. FAIL: Paying invalid fee for DeactivateDID Tx--\n") + deactivate_tx_cmd = form_did_deactivate_tx_multisig(did_doc_alice, signers, DEFAULT_BLOCKCHAIN_ACCOUNT_NAME) + deactivate_tx_cmd = deactivate_tx_cmd.replace("--fees 1000uhid", "--fees 7543uhid") + run_blockchain_command(deactivate_tx_cmd, f"Deactivating of Org's DID with Id: {did_doc_alice}", True) + + print("--10. PASS: Paying valid fee for DeactivateDID Tx--\n") + deactivate_tx_cmd = deactivate_tx_cmd.replace("--fees 7543uhid", "--fees 1000uhid") + run_blockchain_command(deactivate_tx_cmd, f"Deactivating Alice's DID with Id: {did_doc_alice}") + + print("--11. FAIL: Grouping two SSI (CreateDID) and a non-SSI messages (Token Transfer) in a single transaction") + cmd = "hid-noded tx broadcast ./tests/e2e/ssi_tests/broadcast_txs/tx_broadcast.json --chain-id hidnode --broadcast-mode block --yes --output json" + run_blockchain_command(cmd, "Grouping two SSI (CreateDID) and a non-SSI messages (Token Transfer) in a single transaction", True) + + print("--- Fixed Fee SSI Tx Test Completed ---\n") + def key_agrement_test(): print("\n--1. FAIL: Ed25519VerificationKey2020 based Verification Method ID being added to keyAgreement attribute--\n") diff --git a/tests/e2e/ssi_tests/generate_doc.py b/tests/e2e/ssi_tests/generate_doc.py index f668520..389dcfc 100644 --- a/tests/e2e/ssi_tests/generate_doc.py +++ b/tests/e2e/ssi_tests/generate_doc.py @@ -6,6 +6,47 @@ from utils import run_command, generate_document_id, get_document_signature, \ secp256k1_pubkey_to_address +def generate_multi_vm_did(key_pairs, algo="ed25519", is_uuid=False): + base_document = { + "context" : [ + "https://www.w3.org/ns/did/v1" + ], + "id": "", + "controller": [], + "verificationMethod": [], + "authentication": [], + } + + did_id = generate_document_id("did", key_pairs[0], algo, is_uuid) + + # Form the DID Document + vm_type = "Ed25519VerificationKey2020" + + verification_methods = [] + + for i in range(0, len(key_pairs)): + verification_method = { + "id": "", + "type": "", + "controller": "", + "blockchainAccountId": "", + "publicKeyMultibase": "" + } + verification_method["publicKeyMultibase"] = key_pairs[i]["pub_key_multibase"] + verification_method["controller"] = did_id + verification_method["type"] = vm_type + verification_method["id"] = did_id + "#k" + str(i) + + verification_methods.append(verification_method) + + base_document["id"] = did_id + base_document["controller"] = [did_id] + base_document["verificationMethod"] = verification_methods + base_document["authentication"] = [] + base_document["assertionMethod"] = [] + + return base_document + def generate_did_document(key_pair, algo="ed25519", bech32prefix="hid", is_uuid=False): base_document = { "context" : [ diff --git a/tests/e2e/ssi_tests/run.py b/tests/e2e/ssi_tests/run.py index 76bd089..6399f76 100644 --- a/tests/e2e/ssi_tests/run.py +++ b/tests/e2e/ssi_tests/run.py @@ -35,6 +35,8 @@ def run_all_tests(): method_specific_id_test() unique_wallet_address_test() key_agrement_test() + ssi_fee_test() + big_did_tx_test() print("============= 😃️ All test cases completed successfully ============== \n") From a7a44b731ff182d21f30df988bf75a95fe54c25b Mon Sep 17 00:00:00 2001 From: Arnab Ghose Date: Sat, 5 Aug 2023 14:21:24 +0530 Subject: [PATCH 06/11] refactor: removed x/identityfee module and moved the fixed fee functionality under x/ssi module --- app/ante.go | 14 +- app/app.go | 55 +- client/docs/config.json | 3 - client/docs/swagger-ui/swagger.yaml | 368 ++++---- proto/identityfee/v1/genesis.proto | 17 - proto/identityfee/v1/query.proto | 26 - proto/ssi/v1/genesis.proto | 11 + proto/ssi/v1/query.proto | 18 + x/identityfee/client/cli/query.go | 51 -- x/identityfee/genesis.go | 36 - x/identityfee/keeper/keeper.go | 33 - x/identityfee/keeper/params.go | 15 - x/identityfee/module.go | 163 ---- x/identityfee/types/genesis.go | 27 - x/identityfee/types/genesis.pb.go | 614 ------------- x/identityfee/types/keys.go | 15 - x/identityfee/types/params.go | 20 - x/identityfee/types/query.pb.go | 847 ------------------ x/identityfee/types/query.pb.gw.go | 153 ---- x/{identityfee => ssi}/ante/decorators.go | 71 +- x/{identityfee => ssi}/ante/types.go | 4 +- x/ssi/ante/utils.go | 46 + x/ssi/client/cli/query.go | 1 + x/ssi/client/cli/query_ssi.go | 25 + x/ssi/genesis.go | 18 + .../keeper/grpc_query_fee.go} | 2 +- x/ssi/keeper/keeper.go | 4 +- x/ssi/keeper/params.go | 15 + x/ssi/types/genesis.go | 5 +- x/ssi/types/genesis.pb.go | 523 ++++++++++- x/ssi/types/keys.go | 10 + x/ssi/types/params.go | 50 ++ x/ssi/types/query.pb.go | 713 +++++++++++++-- x/ssi/types/query.pb.gw.go | 65 ++ 34 files changed, 1653 insertions(+), 2385 deletions(-) delete mode 100644 proto/identityfee/v1/genesis.proto delete mode 100644 proto/identityfee/v1/query.proto delete mode 100644 x/identityfee/client/cli/query.go delete mode 100644 x/identityfee/genesis.go delete mode 100644 x/identityfee/keeper/keeper.go delete mode 100644 x/identityfee/keeper/params.go delete mode 100644 x/identityfee/module.go delete mode 100644 x/identityfee/types/genesis.go delete mode 100644 x/identityfee/types/genesis.pb.go delete mode 100644 x/identityfee/types/keys.go delete mode 100644 x/identityfee/types/params.go delete mode 100644 x/identityfee/types/query.pb.go delete mode 100644 x/identityfee/types/query.pb.gw.go rename x/{identityfee => ssi}/ante/decorators.go (80%) rename x/{identityfee => ssi}/ante/types.go (85%) create mode 100644 x/ssi/ante/utils.go rename x/{identityfee/keeper/grpc_query.go => ssi/keeper/grpc_query_fee.go} (94%) create mode 100644 x/ssi/keeper/params.go create mode 100644 x/ssi/types/params.go diff --git a/app/ante.go b/app/ante.go index b69aa85..0422b6d 100644 --- a/app/ante.go +++ b/app/ante.go @@ -5,13 +5,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - identityfeeante "github.com/hypersign-protocol/hid-node/x/identityfee/ante" + ssiante "github.com/hypersign-protocol/hid-node/x/ssi/ante" ) type HandlerOptions struct { ante.HandlerOptions - IdentityFeeKeeper identityfeeante.IdentityFeeKeeper + SsiKeeper ssiante.SsiKeeper } func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { @@ -27,6 +27,10 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") } + if options.SsiKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "ssi keeper is required for ante builder") + } + sigGasConsumer := options.SigGasConsumer if sigGasConsumer == nil { sigGasConsumer = ante.DefaultSigVerificationGasConsumer @@ -35,13 +39,13 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first ante.NewRejectExtensionOptionsDecorator(), - identityfeeante.NewSSITxDecorator(), - identityfeeante.NewMempoolFeeDecorator(), + ssiante.NewSSITxDecorator(), + ssiante.NewMempoolFeeDecorator(), ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), - identityfeeante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.IdentityFeeKeeper), + ssiante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.SsiKeeper), ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewValidateSigCountDecorator(options.AccountKeeper), ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer), diff --git a/app/app.go b/app/app.go index 8a2a515..e70edde 100644 --- a/app/app.go +++ b/app/app.go @@ -99,10 +99,6 @@ import ( ssimodule "github.com/hypersign-protocol/hid-node/x/ssi" ssimodulekeeper "github.com/hypersign-protocol/hid-node/x/ssi/keeper" ssimoduletypes "github.com/hypersign-protocol/hid-node/x/ssi/types" - - identifyfeemodule "github.com/hypersign-protocol/hid-node/x/identityfee" - identifyfeekeeper "github.com/hypersign-protocol/hid-node/x/identityfee/keeper" - identifyfeetypes "github.com/hypersign-protocol/hid-node/x/identityfee/types" ) const ( @@ -150,7 +146,6 @@ var ( transfer.AppModuleBasic{}, authzmodule.AppModuleBasic{}, ssimodule.AppModuleBasic{}, - identifyfeemodule.AppModuleBasic{}, ) // module account permissions @@ -198,23 +193,22 @@ type App struct { memKeys map[string]*sdk.MemoryStoreKey // keepers - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - EvidenceKeeper evidencekeeper.Keeper - TransferKeeper ibctransferkeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - AuthzKeeper authzkeeper.Keeper - IdentityFeeKeeper identifyfeekeeper.Keeper + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + EvidenceKeeper evidencekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + AuthzKeeper authzkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -378,12 +372,6 @@ func New( ) ssiModule := ssimodule.NewAppModule(appCodec, app.SsiKeeper, app.AccountKeeper, app.BankKeeper) - app.IdentityFeeKeeper = *identifyfeekeeper.NewKeeper( - appCodec, - app.GetSubspace(identifyfeetypes.ModuleName), - ) - identityFeeModule := identifyfeemodule.NewAppModule(appCodec, app.IdentityFeeKeeper) - // Create static IBC router, add transfer route, then set and seal it ibcRouter := ibcporttypes.NewRouter() ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) @@ -420,7 +408,6 @@ func New( params.NewAppModule(app.ParamsKeeper), transferModule, ssiModule, - identityFeeModule, ) // During begin block slashing happens after distr.BeginBlocker so that @@ -443,7 +430,6 @@ func New( feegrant.ModuleName, authz.ModuleName, ssimoduletypes.ModuleName, - identifyfeetypes.ModuleName, genutiltypes.ModuleName, crisistypes.ModuleName, paramstypes.ModuleName, @@ -459,7 +445,6 @@ func New( distrtypes.ModuleName, upgradetypes.ModuleName, ssimoduletypes.ModuleName, - identifyfeetypes.ModuleName, genutiltypes.ModuleName, feegrant.ModuleName, authz.ModuleName, @@ -491,7 +476,6 @@ func New( evidencetypes.ModuleName, ibctransfertypes.ModuleName, ssimoduletypes.ModuleName, - identifyfeetypes.ModuleName, feegrant.ModuleName, authz.ModuleName, paramstypes.ModuleName, @@ -520,7 +504,7 @@ func New( FeegrantKeeper: app.FeeGrantKeeper, SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - IdentityFeeKeeper: app.IdentityFeeKeeper, + SsiKeeper: app.SsiKeeper, }, ) if err != nil { @@ -687,9 +671,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) - paramsKeeper.Subspace(ssimoduletypes.ModuleName) - paramsKeeper.Subspace(identifyfeetypes.ModuleName).WithKeyTable(identifyfeetypes.ParamKeyTable()) - + paramsKeeper.Subspace(ssimoduletypes.ModuleName).WithKeyTable(ssimoduletypes.ParamKeyTable()) + return paramsKeeper } diff --git a/client/docs/config.json b/client/docs/config.json index 933a217..6f9b03d 100644 --- a/client/docs/config.json +++ b/client/docs/config.json @@ -9,9 +9,6 @@ { "url": "./.cache/tmp/swagger-gen/ssi/v1/query.swagger.json" }, - { - "url": "./.cache/tmp/swagger-gen/identityfee/v1/query.swagger.json" - }, { "url": "https://github.com/cosmos/cosmos-sdk/raw/v0.45.7/client/docs/swagger-ui/swagger.yaml", "dereference": { diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 21d87f1..da63478 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -499,6 +499,115 @@ paths: type: string tags: - Query + /hypersign-protocol/hidnode/ssi/fixedfee: + get: + summary: Get the list of fixed fees for every x/ssi module transactions + operationId: QuerySSIFee + responses: + '200': + description: A successful response. + schema: + type: object + properties: + create_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + update_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + deactivate_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + create_schema_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + register_credential_status_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + tags: + - Query /hypersign-protocol/hidnode/ssi/schema: get: summary: Get the count and list of registered Schemas @@ -726,115 +835,6 @@ paths: type: string tags: - Query - /hypersign-protocol/hidnode/identityfee: - get: - summary: Get the list of fixed fees for every x/ssi module transactions - operationId: QuerySSIFee - responses: - '200': - description: A successful response. - schema: - type: object - properties: - create_did_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - update_did_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - deactivate_did_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - create_schema_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - register_credential_status_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - value: - type: string - format: byte - tags: - - Query /node_info: get: description: Information about the connected node @@ -24303,6 +24303,18 @@ definitions: title: |- PageRequest is to be embedded in gRPC request messages for efficient pagination. Ex: + cosmos.base.v1beta1.Coin: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. google.protobuf.Any: type: object properties: @@ -25008,6 +25020,69 @@ definitions: type: boolean versionId: type: string + hypersignprotocol.hidnode.ssi.QuerySSIFeeResponse: + type: object + properties: + create_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + update_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + deactivate_did_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + create_schema_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + register_credential_status_fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. hypersignprotocol.hidnode.ssi.QuerySchemaResponse: type: object properties: @@ -25208,81 +25283,6 @@ definitions: type: string blockchainAccountId: type: string - cosmos.base.v1beta1.Coin: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - hypersignprotocol.hidnode.identityfee.QuerySSIFeeResponse: - type: object - properties: - create_did_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - update_did_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - deactivate_did_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - create_schema_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - register_credential_status_fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. CheckTxResult: type: object properties: diff --git a/proto/identityfee/v1/genesis.proto b/proto/identityfee/v1/genesis.proto deleted file mode 100644 index cc22827..0000000 --- a/proto/identityfee/v1/genesis.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; -package hypersignprotocol.hidnode.identityfee; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -option go_package = "github.com/hypersign-protocol/hid-node/x/identityfee/types"; -option (gogoproto.equal_all) = true; - -// GenesisState defines the identityfee module's genesis state. -message GenesisState { - cosmos.base.v1beta1.Coin create_did_fee = 1; - cosmos.base.v1beta1.Coin update_did_fee = 2; - cosmos.base.v1beta1.Coin deactivate_did_fee = 3; - cosmos.base.v1beta1.Coin create_schema_fee = 4; - cosmos.base.v1beta1.Coin register_credential_status_fee = 5; -} diff --git a/proto/identityfee/v1/query.proto b/proto/identityfee/v1/query.proto deleted file mode 100644 index cb6cf05..0000000 --- a/proto/identityfee/v1/query.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; -package hypersignprotocol.hidnode.identityfee; - -import "google/api/annotations.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/hypersign-protocol/hid-node/x/identityfee/types"; -option (gogoproto.equal_all) = true; - -service Query { - // Get the list of fixed fees for every x/ssi module transactions - rpc QuerySSIFee(QuerySSIFeeRequest) returns (QuerySSIFeeResponse) { - option (google.api.http).get = "/hypersign-protocol/hidnode/identityfee"; - } -} - -message QuerySSIFeeRequest {} - -message QuerySSIFeeResponse { - cosmos.base.v1beta1.Coin create_did_fee = 1; - cosmos.base.v1beta1.Coin update_did_fee = 2; - cosmos.base.v1beta1.Coin deactivate_did_fee = 3; - cosmos.base.v1beta1.Coin create_schema_fee = 4; - cosmos.base.v1beta1.Coin register_credential_status_fee = 5; -} diff --git a/proto/ssi/v1/genesis.proto b/proto/ssi/v1/genesis.proto index 06a73ae..a1d33b2 100644 --- a/proto/ssi/v1/genesis.proto +++ b/proto/ssi/v1/genesis.proto @@ -2,10 +2,21 @@ syntax = "proto3"; package hypersignprotocol.hidnode.ssi; import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/hypersign-protocol/hid-node/x/ssi/types"; // GenesisState defines the ssi module's genesis state. message GenesisState { string chain_namespace = 1; + Params params = 2; } + +// Param defines the ssi module's params. +message Params { + cosmos.base.v1beta1.Coin create_did_fee = 1; + cosmos.base.v1beta1.Coin update_did_fee = 2; + cosmos.base.v1beta1.Coin deactivate_did_fee = 3; + cosmos.base.v1beta1.Coin create_schema_fee = 4; + cosmos.base.v1beta1.Coin register_credential_status_fee = 5; +} \ No newline at end of file diff --git a/proto/ssi/v1/query.proto b/proto/ssi/v1/query.proto index d66ed6a..aceaa2c 100644 --- a/proto/ssi/v1/query.proto +++ b/proto/ssi/v1/query.proto @@ -7,6 +7,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "ssi/v1/schema.proto"; import "ssi/v1/did.proto"; import "ssi/v1/credential.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/hypersign-protocol/hid-node/x/ssi/types"; @@ -41,6 +42,23 @@ service Query { rpc QueryCredentials(QueryCredentialsRequest) returns (QueryCredentialsResponse) { option (google.api.http).get = "/hypersign-protocol/hidnode/ssi/credential"; } + + // Get the list of fixed fees for every x/ssi module transactions + rpc QuerySSIFee(QuerySSIFeeRequest) returns (QuerySSIFeeResponse) { + option (google.api.http).get = "/hypersign-protocol/hidnode/ssi/fixedfee"; + } +} + +// Fixed SSI Fee + +message QuerySSIFeeRequest {} + +message QuerySSIFeeResponse { + cosmos.base.v1beta1.Coin create_did_fee = 1; + cosmos.base.v1beta1.Coin update_did_fee = 2; + cosmos.base.v1beta1.Coin deactivate_did_fee = 3; + cosmos.base.v1beta1.Coin create_schema_fee = 4; + cosmos.base.v1beta1.Coin register_credential_status_fee = 5; } // Schema Messages diff --git a/x/identityfee/client/cli/query.go b/x/identityfee/client/cli/query.go deleted file mode 100644 index b4b0907..0000000 --- a/x/identityfee/client/cli/query.go +++ /dev/null @@ -1,51 +0,0 @@ -package cli - -import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/hypersign-protocol/hid-node/x/identityfee/types" - "github.com/spf13/cobra" -) - -// GetQueryCmd returns the cli query commands for identityfee module -func GetQueryCmd() *cobra.Command { - // Group identityfee queries under a subcommand - cmd := &cobra.Command{ - Use: types.ModuleName, - Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand(cmdListFees()) - return cmd -} - - -func cmdListFees() *cobra.Command { - cmd := &cobra.Command{ - Use: "list-fees", - Short: "List fee for all SSI based transactions", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.QuerySSIFee(cmd.Context(), &types.QuerySSIFeeRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - flags.AddQueryFlagsToCmd(cmd) - return cmd -} \ No newline at end of file diff --git a/x/identityfee/genesis.go b/x/identityfee/genesis.go deleted file mode 100644 index e963325..0000000 --- a/x/identityfee/genesis.go +++ /dev/null @@ -1,36 +0,0 @@ -package ssifee - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/hypersign-protocol/hid-node/x/identityfee/keeper" - "github.com/hypersign-protocol/hid-node/x/identityfee/types" -) - -// InitGenesis initializes the identityfee module's state from a provided genesis -// state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - k.SetFeeParam(ctx, *genState.CreateDidFee, types.ParamStoreKeyCreateDidFee) - k.SetFeeParam(ctx, *genState.UpdateDidFee, types.ParamStoreKeyUpdateDidFee) - k.SetFeeParam(ctx, *genState.DeactivateDidFee, types.ParamStoreKeyDeactivateDidFee) - k.SetFeeParam(ctx, *genState.CreateSchemaFee, types.ParamStoreKeyCreateSchemaFee) - k.SetFeeParam(ctx, *genState.RegisterCredentialStatusFee, types.ParamStoreKeyRegisterCredentialStatusFee) -} - -// ExportGenesis returns the identity module's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() - - createDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyCreateDidFee) - updateDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyUpdateDidFee) - deactivateDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyDeactivateDidFee) - createSchemaFee := k.GetFeeParams(ctx, types.ParamStoreKeyCreateSchemaFee) - registerCredentialStatusFee := k.GetFeeParams(ctx, types.ParamStoreKeyRegisterCredentialStatusFee) - - genesis.CreateDidFee = &createDidFee - genesis.UpdateDidFee = &updateDidFee - genesis.DeactivateDidFee = &deactivateDidFee - genesis.CreateSchemaFee = &createSchemaFee - genesis.RegisterCredentialStatusFee = ®isterCredentialStatusFee - - return genesis -} diff --git a/x/identityfee/keeper/keeper.go b/x/identityfee/keeper/keeper.go deleted file mode 100644 index 99444a9..0000000 --- a/x/identityfee/keeper/keeper.go +++ /dev/null @@ -1,33 +0,0 @@ -package keeper - -import ( - "fmt" - - "github.com/tendermint/tendermint/libs/log" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/hypersign-protocol/hid-node/x/identityfee/types" -) - -type ( - Keeper struct { - cdc codec.BinaryCodec - paramSpace paramtypes.Subspace - } -) - -func NewKeeper( - cdc codec.BinaryCodec, - ps paramtypes.Subspace, -) *Keeper { - return &Keeper{ - cdc: cdc, - paramSpace: ps, - } -} - -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) -} diff --git a/x/identityfee/keeper/params.go b/x/identityfee/keeper/params.go deleted file mode 100644 index a8502a3..0000000 --- a/x/identityfee/keeper/params.go +++ /dev/null @@ -1,15 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k Keeper) SetFeeParam(ctx sdk.Context, fee sdk.Coin, identityfeeParamStoreKey []byte) { - k.paramSpace.Set(ctx, identityfeeParamStoreKey, fee) -} - -func (k Keeper) GetFeeParams(ctx sdk.Context, identityfeeParamStoreKey []byte) sdk.Coin { - var fee sdk.Coin - k.paramSpace.Get(ctx, identityfeeParamStoreKey, &fee) - return fee -} diff --git a/x/identityfee/module.go b/x/identityfee/module.go deleted file mode 100644 index 0ac8a56..0000000 --- a/x/identityfee/module.go +++ /dev/null @@ -1,163 +0,0 @@ -package ssifee - -import ( - "context" - "encoding/json" - "fmt" - "log" - - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/hypersign-protocol/hid-node/x/identityfee/client/cli" - "github.com/hypersign-protocol/hid-node/x/identityfee/keeper" - "github.com/hypersign-protocol/hid-node/x/identityfee/types" -) - -var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} -) - -type AppModuleBasic struct { - cdc codec.BinaryCodec -} - -func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { - return AppModuleBasic{cdc: cdc} -} - -// Name returns the capability module's name. -func (AppModuleBasic) Name() string { - return types.ModuleName -} - -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { -} - -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { -} - -// RegisterInterfaces registers the module's interface types -func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { -} - -// DefaultGenesis returns the ssi module's default genesis state. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesis()) -} - -// ValidateGenesis performs genesis state validation for the capability module. -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - var genState types.GenesisState - if err := cdc.UnmarshalJSON(bz, &genState); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - } - return genState.Validate() -} - -// RegisterRESTRoutes registers the capability module's REST service handlers. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { -} - -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) - if err != nil { - log.Fatal(err) - } -} - -// GetTxCmd returns the capability module's root tx command. -func (a AppModuleBasic) GetTxCmd() *cobra.Command { - return nil -} - -// GetQueryCmd returns the capability module's root query command. -func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() -} - - -type AppModule struct { - AppModuleBasic - - keeper keeper.Keeper -} - -func NewAppModule( - cdc codec.Codec, - keeper keeper.Keeper, -) AppModule { - return AppModule{ - AppModuleBasic: NewAppModuleBasic(cdc), - keeper: keeper, - } -} - -// Name returns the capability module's name. -func (am AppModule) Name() string { - return am.AppModuleBasic.Name() -} - -// Route returns the capability module's message routing key. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the capability module's query routing key. -func (AppModule) QuerierRoute() string { return types.QuerierRoute } - -// LegacyQuerierHandler returns the capability module's Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return nil -} - -// RegisterServices registers a GRPC query service to respond to the -// module-specific GRPC queries. -func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) -} - -// RegisterInvariants registers the capability module's invariants. -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} - -// InitGenesis performs the ssi module's genesis initialization It returns -// no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { - var genState types.GenesisState - // Initialize global index to index in genesis state - cdc.MustUnmarshalJSON(gs, &genState) - - InitGenesis(ctx, am.keeper, genState) - - return []abci.ValidatorUpdate{} -} - -// ExportGenesis returns the ssi module's exported genesis state as raw JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - genState := ExportGenesis(ctx, am.keeper) - return cdc.MustMarshalJSON(genState) -} - -// ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } - -// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { -} - -// EndBlock executes all ABCI EndBlock logic respective to the capability module. It -// returns no validator updates. -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} diff --git a/x/identityfee/types/genesis.go b/x/identityfee/types/genesis.go deleted file mode 100644 index 3720af9..0000000 --- a/x/identityfee/types/genesis.go +++ /dev/null @@ -1,27 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - DefaultCreateDIDFee = sdk.NewInt64Coin("uhid", 4000) - DefaultUpdateDIDFee = sdk.NewInt64Coin("uhid", 1000) - DefaultDeactivateDIDFee = sdk.NewInt64Coin("uhid", 1000) - DefaultCreateSchemaFee = sdk.NewInt64Coin("uhid", 2000) - DefaultRegisterCredentialStatusFee = sdk.NewInt64Coin("uhid", 2000) -) - -func DefaultGenesis() *GenesisState { - return &GenesisState{ - CreateDidFee: &DefaultCreateDIDFee, - UpdateDidFee: &DefaultUpdateDIDFee, - DeactivateDidFee: &DefaultDeactivateDIDFee, - CreateSchemaFee: &DefaultCreateSchemaFee, - RegisterCredentialStatusFee: &DefaultRegisterCredentialStatusFee, - } -} - -func (gs GenesisState) Validate() error { - return nil -} diff --git a/x/identityfee/types/genesis.pb.go b/x/identityfee/types/genesis.pb.go deleted file mode 100644 index 7e24732..0000000 --- a/x/identityfee/types/genesis.pb.go +++ /dev/null @@ -1,614 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: identityfee/v1/genesis.proto - -package types - -import ( - fmt "fmt" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/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 - -// GenesisState defines the ssifee module's genesis state. -type GenesisState struct { - CreateDidFee *types.Coin `protobuf:"bytes,1,opt,name=create_did_fee,json=createDidFee,proto3" json:"create_did_fee,omitempty"` - UpdateDidFee *types.Coin `protobuf:"bytes,2,opt,name=update_did_fee,json=updateDidFee,proto3" json:"update_did_fee,omitempty"` - DeactivateDidFee *types.Coin `protobuf:"bytes,3,opt,name=deactivate_did_fee,json=deactivateDidFee,proto3" json:"deactivate_did_fee,omitempty"` - CreateSchemaFee *types.Coin `protobuf:"bytes,4,opt,name=create_schema_fee,json=createSchemaFee,proto3" json:"create_schema_fee,omitempty"` - RegisterCredentialStatusFee *types.Coin `protobuf:"bytes,5,opt,name=register_credential_status_fee,json=registerCredentialStatusFee,proto3" json:"register_credential_status_fee,omitempty"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_14d65fa1d8b5cdf2, []int{0} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetCreateDidFee() *types.Coin { - if m != nil { - return m.CreateDidFee - } - return nil -} - -func (m *GenesisState) GetUpdateDidFee() *types.Coin { - if m != nil { - return m.UpdateDidFee - } - return nil -} - -func (m *GenesisState) GetDeactivateDidFee() *types.Coin { - if m != nil { - return m.DeactivateDidFee - } - return nil -} - -func (m *GenesisState) GetCreateSchemaFee() *types.Coin { - if m != nil { - return m.CreateSchemaFee - } - return nil -} - -func (m *GenesisState) GetRegisterCredentialStatusFee() *types.Coin { - if m != nil { - return m.RegisterCredentialStatusFee - } - return nil -} - -func init() { - proto.RegisterType((*GenesisState)(nil), "hypersignprotocol.hidnode.identityfee.GenesisState") -} - -func init() { proto.RegisterFile("identityfee/v1/genesis.proto", fileDescriptor_14d65fa1d8b5cdf2) } - -var fileDescriptor_14d65fa1d8b5cdf2 = []byte{ - // 339 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0xd2, 0x3f, 0x4b, 0xc3, 0x40, - 0x18, 0xc7, 0xf1, 0xc6, 0xaa, 0x43, 0x2c, 0xfe, 0x29, 0x0e, 0x5a, 0xe5, 0x10, 0x41, 0x70, 0xe9, - 0x1d, 0xd5, 0xcd, 0x45, 0xb0, 0xda, 0xee, 0x76, 0x11, 0x07, 0xc3, 0xe5, 0xee, 0x69, 0x72, 0xd0, - 0xe6, 0x42, 0xee, 0x69, 0xb1, 0x9b, 0x2f, 0xc1, 0x97, 0xe1, 0x4b, 0x71, 0xec, 0xe8, 0x28, 0xe9, - 0x1b, 0x91, 0xdc, 0xa5, 0x35, 0x5b, 0xb6, 0x84, 0xdc, 0xf7, 0x13, 0x12, 0x7e, 0xfe, 0xb9, 0x92, - 0x90, 0xa0, 0xc2, 0xc5, 0x18, 0x80, 0xcd, 0x7b, 0x2c, 0x82, 0x04, 0x8c, 0x32, 0x34, 0xcd, 0x34, - 0xea, 0xf6, 0x55, 0xbc, 0x48, 0x21, 0x33, 0x2a, 0x4a, 0xec, 0xbd, 0xd0, 0x13, 0x1a, 0x2b, 0x99, - 0x68, 0x09, 0xb4, 0xd2, 0x75, 0x8e, 0x23, 0x1d, 0x69, 0x7b, 0x82, 0x15, 0x57, 0x2e, 0xee, 0x10, - 0xa1, 0xcd, 0x54, 0x1b, 0x16, 0x72, 0x53, 0xd0, 0x21, 0x20, 0xef, 0x31, 0xa1, 0x55, 0xe2, 0x9e, - 0x5f, 0x7e, 0x34, 0xfd, 0xd6, 0xd0, 0xbd, 0x6e, 0x84, 0x1c, 0xa1, 0x7d, 0xef, 0xef, 0x8b, 0x0c, - 0x38, 0x42, 0x20, 0x95, 0x0c, 0xc6, 0x00, 0x27, 0xde, 0x85, 0x77, 0xbd, 0x77, 0x73, 0x4a, 0x9d, - 0x44, 0x0b, 0x89, 0x96, 0x12, 0xed, 0x6b, 0x95, 0x3c, 0xb7, 0x5c, 0xf0, 0xa8, 0xe4, 0x00, 0x2c, - 0x30, 0x4b, 0x65, 0x15, 0xd8, 0xaa, 0x05, 0x5c, 0x50, 0x02, 0x43, 0xbf, 0x2d, 0x81, 0x0b, 0x54, - 0xf3, 0x2a, 0xd2, 0xac, 0x43, 0x0e, 0xff, 0xa3, 0x12, 0x7a, 0xf2, 0x8f, 0xca, 0x4f, 0x31, 0x22, - 0x86, 0x29, 0xb7, 0xce, 0x76, 0x9d, 0x73, 0xe0, 0x9a, 0x91, 0x4d, 0x0a, 0xe6, 0xcd, 0x27, 0x19, - 0x44, 0xca, 0x20, 0x64, 0x81, 0xc8, 0xc0, 0xfe, 0x72, 0x3e, 0x09, 0x0c, 0x72, 0x9c, 0x19, 0x6b, - 0xee, 0xd4, 0x99, 0x67, 0x6b, 0xa0, 0xbf, 0xe9, 0x47, 0x36, 0x1f, 0x00, 0x3c, 0xbc, 0x7c, 0xe5, - 0xc4, 0xfb, 0xce, 0x89, 0xb7, 0xcc, 0x89, 0xf7, 0x9b, 0x13, 0xef, 0x73, 0x45, 0x1a, 0xcb, 0x15, - 0x69, 0xfc, 0xac, 0x48, 0xe3, 0xf5, 0x2e, 0x52, 0x18, 0xcf, 0x42, 0x2a, 0xf4, 0x94, 0x6d, 0x86, - 0xd0, 0x5d, 0x2f, 0x81, 0xc5, 0x4a, 0x76, 0x8b, 0x29, 0xb0, 0x77, 0x56, 0x1d, 0x11, 0x2e, 0x52, - 0x30, 0xe1, 0xae, 0x3d, 0x76, 0xfb, 0x17, 0x00, 0x00, 0xff, 0xff, 0x2d, 0xa5, 0x4e, 0xe3, 0x60, - 0x02, 0x00, 0x00, -} - -func (this *GenesisState) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*GenesisState) - if !ok { - that2, ok := that.(GenesisState) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.CreateDidFee.Equal(that1.CreateDidFee) { - return false - } - if !this.UpdateDidFee.Equal(that1.UpdateDidFee) { - return false - } - if !this.DeactivateDidFee.Equal(that1.DeactivateDidFee) { - return false - } - if !this.CreateSchemaFee.Equal(that1.CreateSchemaFee) { - return false - } - if !this.RegisterCredentialStatusFee.Equal(that1.RegisterCredentialStatusFee) { - return false - } - return true -} -func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.RegisterCredentialStatusFee != nil { - { - size, err := m.RegisterCredentialStatusFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - if m.CreateSchemaFee != nil { - { - size, err := m.CreateSchemaFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.DeactivateDidFee != nil { - { - size, err := m.DeactivateDidFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.UpdateDidFee != nil { - { - size, err := m.UpdateDidFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.CreateDidFee != nil { - { - size, err := m.CreateDidFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CreateDidFee != nil { - l = m.CreateDidFee.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if m.UpdateDidFee != nil { - l = m.UpdateDidFee.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if m.DeactivateDidFee != nil { - l = m.DeactivateDidFee.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if m.CreateSchemaFee != nil { - l = m.CreateSchemaFee.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if m.RegisterCredentialStatusFee != nil { - l = m.RegisterCredentialStatusFee.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GenesisState) 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 ErrIntOverflowGenesis - } - 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: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateDidFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CreateDidFee == nil { - m.CreateDidFee = &types.Coin{} - } - if err := m.CreateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdateDidFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.UpdateDidFee == nil { - m.UpdateDidFee = &types.Coin{} - } - if err := m.UpdateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeactivateDidFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DeactivateDidFee == nil { - m.DeactivateDidFee = &types.Coin{} - } - if err := m.DeactivateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateSchemaFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CreateSchemaFee == nil { - m.CreateSchemaFee = &types.Coin{} - } - if err := m.CreateSchemaFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RegisterCredentialStatusFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RegisterCredentialStatusFee == nil { - m.RegisterCredentialStatusFee = &types.Coin{} - } - if err := m.RegisterCredentialStatusFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenesis(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, ErrIntOverflowGenesis - } - 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, ErrIntOverflowGenesis - } - 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, ErrIntOverflowGenesis - } - 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, ErrInvalidLengthGenesis - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenesis - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenesis - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/identityfee/types/keys.go b/x/identityfee/types/keys.go deleted file mode 100644 index edf3f4d..0000000 --- a/x/identityfee/types/keys.go +++ /dev/null @@ -1,15 +0,0 @@ -package types - -const ( - ModuleName = "identityfee" - - QuerierRoute = ModuleName -) - -var ( - ParamStoreKeyCreateDidFee = []byte("CreateDidFee") - ParamStoreKeyUpdateDidFee = []byte("UpdateDidFee") - ParamStoreKeyDeactivateDidFee = []byte("DeactivateDidFee") - ParamStoreKeyCreateSchemaFee = []byte("CreateSchemaFee") - ParamStoreKeyRegisterCredentialStatusFee = []byte("RegisterCredentialStatusFee") -) \ No newline at end of file diff --git a/x/identityfee/types/params.go b/x/identityfee/types/params.go deleted file mode 100644 index 9290f69..0000000 --- a/x/identityfee/types/params.go +++ /dev/null @@ -1,20 +0,0 @@ -package types - -import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable( - paramtypes.NewParamSetPair(ParamStoreKeyCreateDidFee, sdk.Coin{}, validateFeeParams), - paramtypes.NewParamSetPair(ParamStoreKeyUpdateDidFee, sdk.Coin{}, validateFeeParams), - paramtypes.NewParamSetPair(ParamStoreKeyDeactivateDidFee, sdk.Coin{}, validateFeeParams), - paramtypes.NewParamSetPair(ParamStoreKeyCreateSchemaFee, sdk.Coin{}, validateFeeParams), - paramtypes.NewParamSetPair(ParamStoreKeyRegisterCredentialStatusFee, sdk.Coin{}, validateFeeParams), - ) -} - -func validateFeeParams(i interface{}) error { - return nil -} \ No newline at end of file diff --git a/x/identityfee/types/query.pb.go b/x/identityfee/types/query.pb.go deleted file mode 100644 index 36d68ff..0000000 --- a/x/identityfee/types/query.pb.go +++ /dev/null @@ -1,847 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: identityfee/v1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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 QuerySSIFeeRequest struct { -} - -func (m *QuerySSIFeeRequest) Reset() { *m = QuerySSIFeeRequest{} } -func (m *QuerySSIFeeRequest) String() string { return proto.CompactTextString(m) } -func (*QuerySSIFeeRequest) ProtoMessage() {} -func (*QuerySSIFeeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_657f65a9c7940d56, []int{0} -} -func (m *QuerySSIFeeRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QuerySSIFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QuerySSIFeeRequest.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 *QuerySSIFeeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySSIFeeRequest.Merge(m, src) -} -func (m *QuerySSIFeeRequest) XXX_Size() int { - return m.Size() -} -func (m *QuerySSIFeeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySSIFeeRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QuerySSIFeeRequest proto.InternalMessageInfo - -type QuerySSIFeeResponse struct { - CreateDidFee *types.Coin `protobuf:"bytes,1,opt,name=create_did_fee,json=createDidFee,proto3" json:"create_did_fee,omitempty"` - UpdateDidFee *types.Coin `protobuf:"bytes,2,opt,name=update_did_fee,json=updateDidFee,proto3" json:"update_did_fee,omitempty"` - DeactivateDidFee *types.Coin `protobuf:"bytes,3,opt,name=deactivate_did_fee,json=deactivateDidFee,proto3" json:"deactivate_did_fee,omitempty"` - CreateSchemaFee *types.Coin `protobuf:"bytes,4,opt,name=create_schema_fee,json=createSchemaFee,proto3" json:"create_schema_fee,omitempty"` - RegisterCredentialStatusFee *types.Coin `protobuf:"bytes,5,opt,name=register_credential_status_fee,json=registerCredentialStatusFee,proto3" json:"register_credential_status_fee,omitempty"` -} - -func (m *QuerySSIFeeResponse) Reset() { *m = QuerySSIFeeResponse{} } -func (m *QuerySSIFeeResponse) String() string { return proto.CompactTextString(m) } -func (*QuerySSIFeeResponse) ProtoMessage() {} -func (*QuerySSIFeeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_657f65a9c7940d56, []int{1} -} -func (m *QuerySSIFeeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QuerySSIFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QuerySSIFeeResponse.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 *QuerySSIFeeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySSIFeeResponse.Merge(m, src) -} -func (m *QuerySSIFeeResponse) XXX_Size() int { - return m.Size() -} -func (m *QuerySSIFeeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySSIFeeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QuerySSIFeeResponse proto.InternalMessageInfo - -func (m *QuerySSIFeeResponse) GetCreateDidFee() *types.Coin { - if m != nil { - return m.CreateDidFee - } - return nil -} - -func (m *QuerySSIFeeResponse) GetUpdateDidFee() *types.Coin { - if m != nil { - return m.UpdateDidFee - } - return nil -} - -func (m *QuerySSIFeeResponse) GetDeactivateDidFee() *types.Coin { - if m != nil { - return m.DeactivateDidFee - } - return nil -} - -func (m *QuerySSIFeeResponse) GetCreateSchemaFee() *types.Coin { - if m != nil { - return m.CreateSchemaFee - } - return nil -} - -func (m *QuerySSIFeeResponse) GetRegisterCredentialStatusFee() *types.Coin { - if m != nil { - return m.RegisterCredentialStatusFee - } - return nil -} - -func init() { - proto.RegisterType((*QuerySSIFeeRequest)(nil), "hypersignprotocol.hidnode.identityfee.QuerySSIFeeRequest") - proto.RegisterType((*QuerySSIFeeResponse)(nil), "hypersignprotocol.hidnode.identityfee.QuerySSIFeeResponse") -} - -func init() { proto.RegisterFile("identityfee/v1/query.proto", fileDescriptor_657f65a9c7940d56) } - -var fileDescriptor_657f65a9c7940d56 = []byte{ - // 426 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0x3f, 0x6f, 0xd4, 0x30, - 0x18, 0x06, 0xf0, 0x73, 0x4b, 0x19, 0x5c, 0xc4, 0x9f, 0xd0, 0x01, 0x0e, 0x64, 0xa1, 0x93, 0x10, - 0x30, 0xd4, 0x56, 0xcb, 0x44, 0x17, 0x24, 0x0a, 0x87, 0x18, 0x69, 0x16, 0xc4, 0x40, 0xe4, 0xd8, - 0x6f, 0x13, 0x4b, 0x77, 0x7e, 0xd3, 0xd8, 0xa9, 0xc8, 0xca, 0xc2, 0x8a, 0xc4, 0x97, 0xe0, 0x0b, - 0x30, 0xb3, 0x32, 0x56, 0x62, 0x61, 0x44, 0x39, 0x3e, 0x08, 0x8a, 0x93, 0x96, 0x20, 0x84, 0x82, - 0xba, 0x39, 0x4e, 0x9e, 0xdf, 0x1b, 0xeb, 0x31, 0x9d, 0x1a, 0x0d, 0xd6, 0x1b, 0x5f, 0x1f, 0x02, - 0x88, 0xe3, 0x1d, 0x71, 0x54, 0x41, 0x59, 0xf3, 0xa2, 0x44, 0x8f, 0xd1, 0xdd, 0xbc, 0x2e, 0xa0, - 0x74, 0x26, 0xb3, 0xe1, 0x59, 0xe1, 0x82, 0xe7, 0x46, 0x5b, 0xd4, 0xc0, 0x07, 0xa9, 0xe9, 0xed, - 0x0c, 0x31, 0x5b, 0x80, 0x90, 0x85, 0x11, 0xd2, 0x5a, 0xf4, 0xd2, 0x1b, 0xb4, 0xae, 0x43, 0xa6, - 0x4c, 0xa1, 0x5b, 0xa2, 0x13, 0xa9, 0x74, 0xed, 0x80, 0x14, 0xbc, 0xdc, 0x11, 0x0a, 0x8d, 0xed, - 0xdf, 0x6f, 0x65, 0x98, 0x61, 0x58, 0x8a, 0x76, 0xd5, 0xed, 0xce, 0xb6, 0x68, 0xf4, 0xb2, 0xfd, - 0x93, 0x38, 0x7e, 0x31, 0x07, 0x38, 0x80, 0xa3, 0x0a, 0x9c, 0x9f, 0xbd, 0x5f, 0xa7, 0xd7, 0xff, - 0xd8, 0x76, 0x05, 0x5a, 0x07, 0xd1, 0x63, 0x7a, 0x59, 0x95, 0x20, 0x3d, 0x24, 0xda, 0xe8, 0xe4, - 0x10, 0xe0, 0x06, 0xb9, 0x43, 0xee, 0x6f, 0xee, 0xde, 0xe4, 0xdd, 0x70, 0xde, 0x0e, 0xe7, 0xfd, - 0x70, 0xbe, 0x8f, 0xc6, 0x1e, 0x5c, 0xea, 0x02, 0x4f, 0x8d, 0x9e, 0x43, 0x00, 0xaa, 0x42, 0x0f, - 0x81, 0xb5, 0x51, 0xa0, 0x0b, 0xf4, 0xc0, 0x73, 0x1a, 0x69, 0x90, 0xca, 0x9b, 0xe3, 0x21, 0xb2, - 0x3e, 0x86, 0x5c, 0xfd, 0x1d, 0xea, 0xa1, 0x67, 0xf4, 0x5a, 0x7f, 0x14, 0xa7, 0x72, 0x58, 0xca, - 0xe0, 0x5c, 0x18, 0x73, 0xae, 0x74, 0x99, 0x38, 0x44, 0x5a, 0xe6, 0x0d, 0x65, 0x25, 0x64, 0xc6, - 0x79, 0x28, 0x13, 0x55, 0x42, 0x68, 0x4b, 0x2e, 0x12, 0xe7, 0xa5, 0xaf, 0x5c, 0x30, 0x37, 0xc6, - 0xcc, 0x5b, 0xa7, 0xc0, 0xfe, 0x59, 0x3e, 0x0e, 0xf1, 0x39, 0xc0, 0xee, 0x17, 0x42, 0x37, 0x42, - 0x13, 0xd1, 0x67, 0x42, 0x37, 0x07, 0x9d, 0x44, 0x8f, 0xf8, 0x7f, 0xdd, 0x1a, 0xfe, 0x77, 0xbd, - 0xd3, 0xbd, 0xf3, 0x44, 0xbb, 0x2b, 0x30, 0x13, 0xef, 0xbe, 0xfd, 0xfc, 0xb8, 0xf6, 0x20, 0xba, - 0x27, 0xce, 0x8c, 0xed, 0x53, 0x44, 0xf4, 0x88, 0x18, 0x20, 0x4f, 0x5e, 0x7d, 0x6a, 0x18, 0xf9, - 0xda, 0x30, 0x72, 0xd2, 0x30, 0xf2, 0xa3, 0x61, 0xe4, 0xc3, 0x8a, 0x4d, 0x4e, 0x56, 0x6c, 0xf2, - 0x7d, 0xc5, 0x26, 0xaf, 0xf7, 0x32, 0xe3, 0xf3, 0x2a, 0xe5, 0x0a, 0x97, 0xff, 0x00, 0xb7, 0x83, - 0xf8, 0x76, 0x68, 0x0a, 0x5f, 0x17, 0xe0, 0xd2, 0x8b, 0xe1, 0xb3, 0x87, 0xbf, 0x02, 0x00, 0x00, - 0xff, 0xff, 0xfc, 0xb7, 0xf5, 0x5c, 0x5b, 0x03, 0x00, 0x00, -} - -func (this *QuerySSIFeeRequest) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*QuerySSIFeeRequest) - if !ok { - that2, ok := that.(QuerySSIFeeRequest) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - return true -} -func (this *QuerySSIFeeResponse) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*QuerySSIFeeResponse) - if !ok { - that2, ok := that.(QuerySSIFeeResponse) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.CreateDidFee.Equal(that1.CreateDidFee) { - return false - } - if !this.UpdateDidFee.Equal(that1.UpdateDidFee) { - return false - } - if !this.DeactivateDidFee.Equal(that1.DeactivateDidFee) { - return false - } - if !this.CreateSchemaFee.Equal(that1.CreateSchemaFee) { - return false - } - if !this.RegisterCredentialStatusFee.Equal(that1.RegisterCredentialStatusFee) { - return false - } - return true -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Get the list of fixed fees for every x/ssi module transactions - QuerySSIFee(ctx context.Context, in *QuerySSIFeeRequest, opts ...grpc.CallOption) (*QuerySSIFeeResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) QuerySSIFee(ctx context.Context, in *QuerySSIFeeRequest, opts ...grpc.CallOption) (*QuerySSIFeeResponse, error) { - out := new(QuerySSIFeeResponse) - err := c.cc.Invoke(ctx, "/hypersignprotocol.hidnode.identityfee.Query/QuerySSIFee", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Get the list of fixed fees for every x/ssi module transactions - QuerySSIFee(context.Context, *QuerySSIFeeRequest) (*QuerySSIFeeResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) QuerySSIFee(ctx context.Context, req *QuerySSIFeeRequest) (*QuerySSIFeeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QuerySSIFee not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_QuerySSIFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QuerySSIFeeRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QuerySSIFee(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/hypersignprotocol.hidnode.identityfee.Query/QuerySSIFee", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QuerySSIFee(ctx, req.(*QuerySSIFeeRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "hypersignprotocol.hidnode.identityfee.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "QuerySSIFee", - Handler: _Query_QuerySSIFee_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "identityfee/v1/query.proto", -} - -func (m *QuerySSIFeeRequest) 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 *QuerySSIFeeRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QuerySSIFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QuerySSIFeeResponse) 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 *QuerySSIFeeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QuerySSIFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.RegisterCredentialStatusFee != nil { - { - size, err := m.RegisterCredentialStatusFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - if m.CreateSchemaFee != nil { - { - size, err := m.CreateSchemaFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.DeactivateDidFee != nil { - { - size, err := m.DeactivateDidFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.UpdateDidFee != nil { - { - size, err := m.UpdateDidFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.CreateDidFee != nil { - { - size, err := m.CreateDidFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QuerySSIFeeRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QuerySSIFeeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CreateDidFee != nil { - l = m.CreateDidFee.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.UpdateDidFee != nil { - l = m.UpdateDidFee.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.DeactivateDidFee != nil { - l = m.DeactivateDidFee.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.CreateSchemaFee != nil { - l = m.CreateSchemaFee.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.RegisterCredentialStatusFee != nil { - l = m.RegisterCredentialStatusFee.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QuerySSIFeeRequest) 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 ErrIntOverflowQuery - } - 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: QuerySSIFeeRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QuerySSIFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QuerySSIFeeResponse) 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 ErrIntOverflowQuery - } - 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: QuerySSIFeeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QuerySSIFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateDidFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CreateDidFee == nil { - m.CreateDidFee = &types.Coin{} - } - if err := m.CreateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdateDidFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.UpdateDidFee == nil { - m.UpdateDidFee = &types.Coin{} - } - if err := m.UpdateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeactivateDidFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DeactivateDidFee == nil { - m.DeactivateDidFee = &types.Coin{} - } - if err := m.DeactivateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateSchemaFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CreateSchemaFee == nil { - m.CreateSchemaFee = &types.Coin{} - } - if err := m.CreateSchemaFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RegisterCredentialStatusFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RegisterCredentialStatusFee == nil { - m.RegisterCredentialStatusFee = &types.Coin{} - } - if err := m.RegisterCredentialStatusFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipQuery(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, ErrIntOverflowQuery - } - 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, ErrIntOverflowQuery - } - 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, ErrIntOverflowQuery - } - 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, ErrInvalidLengthQuery - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupQuery - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthQuery - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/identityfee/types/query.pb.gw.go b/x/identityfee/types/query.pb.gw.go deleted file mode 100644 index e395f5b..0000000 --- a/x/identityfee/types/query.pb.gw.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: identityfee/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_QuerySSIFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QuerySSIFeeRequest - var metadata runtime.ServerMetadata - - msg, err := client.QuerySSIFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QuerySSIFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QuerySSIFeeRequest - var metadata runtime.ServerMetadata - - msg, err := server.QuerySSIFee(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_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_QuerySSIFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"hypersign-protocol", "hidnode", "identityfee"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_QuerySSIFee_0 = runtime.ForwardResponseMessage -) diff --git a/x/identityfee/ante/decorators.go b/x/ssi/ante/decorators.go similarity index 80% rename from x/identityfee/ante/decorators.go rename to x/ssi/ante/decorators.go index def5930..7473149 100644 --- a/x/identityfee/ante/decorators.go +++ b/x/ssi/ante/decorators.go @@ -6,26 +6,25 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/types" - identityfeetypes "github.com/hypersign-protocol/hid-node/x/identityfee/types" ssitypes "github.com/hypersign-protocol/hid-node/x/ssi/types" ) type DeductFeeDecorator struct { - ak AccountKeeper - bankKeeper BankKeeper - feegrantKeeper FeegrantKeeper - identityFeeKeeper IdentityFeeKeeper + ak AccountKeeper + bankKeeper BankKeeper + feegrantKeeper FeegrantKeeper + ssiKeeper SsiKeeper } // ModifiedFeeDecorator extends NewDeductFeeDecorator by making all x/ssi module related transactions incur fixed fee cost. // Fixed fee is seperate for each x/ssi module transactions and are updated through Governance based proposals. Please refer // HIP-9 to know more: https://github.com/hypersign-protocol/HIPs/blob/main/HIPs/hip-9.md -func NewDeductFeeDecorator(ak AccountKeeper, bk BankKeeper, fk FeegrantKeeper, ifk IdentityFeeKeeper) DeductFeeDecorator { +func NewDeductFeeDecorator(ak AccountKeeper, bk BankKeeper, fk FeegrantKeeper, ifk SsiKeeper) DeductFeeDecorator { return DeductFeeDecorator{ - ak: ak, - bankKeeper: bk, - feegrantKeeper: fk, - identityFeeKeeper: ifk, + ak: ak, + bankKeeper: bk, + feegrantKeeper: fk, + ssiKeeper: ifk, } } @@ -72,19 +71,19 @@ func (mfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo for _, msg := range tx.GetMsgs() { switch msg.(type) { case *ssitypes.MsgCreateDID: - createDidFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyCreateDidFee) + createDidFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyCreateDidFee) fixedSSIFee = fixedSSIFee.Add(createDidFee) case *ssitypes.MsgUpdateDID: - updateDidFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyUpdateDidFee) + updateDidFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyUpdateDidFee) fixedSSIFee = fixedSSIFee.Add(updateDidFee) case *ssitypes.MsgDeactivateDID: - deactivateDidFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyDeactivateDidFee) + deactivateDidFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyDeactivateDidFee) fixedSSIFee = fixedSSIFee.Add(deactivateDidFee) case *ssitypes.MsgCreateSchema: - createSchemaFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyCreateSchemaFee) + createSchemaFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyCreateSchemaFee) fixedSSIFee = fixedSSIFee.Add(createSchemaFee) case *ssitypes.MsgRegisterCredentialStatus: - registerCredentialStatusFee := mfd.identityFeeKeeper.GetFeeParams(ctx, identityfeetypes.ParamStoreKeyRegisterCredentialStatusFee) + registerCredentialStatusFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyRegisterCredentialStatusFee) fixedSSIFee = fixedSSIFee.Add(registerCredentialStatusFee) } } @@ -94,7 +93,7 @@ func (mfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo if !fee.IsEqual(fixedSSIFee) { errMsg1 := "the transaction consists of x/ssi module based messages which incurs fixed cost. " errMsg2 := "The fee provided MUST BE equal to the required fees which is the sum of all fixed-fee x/ssi. " - errMsg3 := "To know about the fixed-fee cost of all x/ssi transactions, refer to the API endpoint /hypersign-protocol/hidnode/identityfee . " + errMsg3 := "To know about the fixed-fee cost of all x/ssi transactions, refer to the API endpoint /hypersign-protocol/hidnode/fixedfee . " return ctx, sdkerrors.Wrapf( sdkerrors.ErrInsufficientFee, @@ -156,46 +155,6 @@ func deductFees(bankKeeper BankKeeper, ctx sdk.Context, acc types.AccountI, fees return nil } -// isSSIMsgPresentInTx checks if there is any SSI message present in the transaction -func isSSIMsgPresentInTx(tx sdk.Tx) bool { - for _, msg := range tx.GetMsgs() { - if isSSIMsg(msg) { - return true - } - } - - return false -} - -// isNonSSIMsgPresentInTx checks if there is any non-SSI message present in the transaction -func isNonSSIMsgPresentInTx(tx sdk.Tx) bool { - for _, msg := range tx.GetMsgs() { - if !isSSIMsg(msg) { - return true - } - } - - return false -} - -// isSSIMsg checks if the message is of SSI type or not -func isSSIMsg(msg sdk.Msg) bool { - switch msg.(type) { - case *ssitypes.MsgCreateDID: - return true - case *ssitypes.MsgUpdateDID: - return true - case *ssitypes.MsgDeactivateDID: - return true - case *ssitypes.MsgCreateSchema: - return true - case *ssitypes.MsgRegisterCredentialStatus: - return true - default: - return false - } -} - // MempoolFeeDecorator will check if the transaction's fee is at least as large // as the local validator's minimum gasFee (defined in validator config). // If fee is too low, decorator returns error and tx is rejected from mempool. diff --git a/x/identityfee/ante/types.go b/x/ssi/ante/types.go similarity index 85% rename from x/identityfee/ante/types.go rename to x/ssi/ante/types.go index ef409cc..d322288 100644 --- a/x/identityfee/ante/types.go +++ b/x/ssi/ante/types.go @@ -20,6 +20,6 @@ type FeegrantKeeper interface { UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error } -type IdentityFeeKeeper interface { - GetFeeParams(ctx sdk.Context, identityfeeParamStoreKey []byte) sdk.Coin +type SsiKeeper interface { + GetFeeParams(ctx sdk.Context, ssiParamStoreKey []byte) sdk.Coin } diff --git a/x/ssi/ante/utils.go b/x/ssi/ante/utils.go new file mode 100644 index 0000000..4b589ec --- /dev/null +++ b/x/ssi/ante/utils.go @@ -0,0 +1,46 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + ssitypes "github.com/hypersign-protocol/hid-node/x/ssi/types" +) + +// isSSIMsg checks if the message is of SSI type or not +func isSSIMsg(msg sdk.Msg) bool { + switch msg.(type) { + case *ssitypes.MsgCreateDID: + return true + case *ssitypes.MsgUpdateDID: + return true + case *ssitypes.MsgDeactivateDID: + return true + case *ssitypes.MsgCreateSchema: + return true + case *ssitypes.MsgRegisterCredentialStatus: + return true + default: + return false + } +} + +// isSSIMsgPresentInTx checks if there is any SSI message present in the transaction +func isSSIMsgPresentInTx(tx sdk.Tx) bool { + for _, msg := range tx.GetMsgs() { + if isSSIMsg(msg) { + return true + } + } + + return false +} + +// isNonSSIMsgPresentInTx checks if there is any non-SSI message present in the transaction +func isNonSSIMsgPresentInTx(tx sdk.Tx) bool { + for _, msg := range tx.GetMsgs() { + if !isSSIMsg(msg) { + return true + } + } + + return false +} diff --git a/x/ssi/client/cli/query.go b/x/ssi/client/cli/query.go index 2b58142..5f5f017 100644 --- a/x/ssi/client/cli/query.go +++ b/x/ssi/client/cli/query.go @@ -22,6 +22,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdGetSchema()) cmd.AddCommand(CmdResolveDID()) cmd.AddCommand(CmdGetCredentialStatus()) + cmd.AddCommand(cmdListFees()) return cmd } diff --git a/x/ssi/client/cli/query_ssi.go b/x/ssi/client/cli/query_ssi.go index cc1ab64..0a4bea2 100644 --- a/x/ssi/client/cli/query_ssi.go +++ b/x/ssi/client/cli/query_ssi.go @@ -11,6 +11,31 @@ import ( var _ = strconv.Itoa(0) +func cmdListFees() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-fees", + Short: "List fee for all SSI based transactions", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QuerySSIFee(cmd.Context(), &types.QuerySSIFeeRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + func CmdGetSchema() *cobra.Command { cmd := &cobra.Command{ Use: "schema [schema-id]", diff --git a/x/ssi/genesis.go b/x/ssi/genesis.go index 5c7864c..dc09bec 100644 --- a/x/ssi/genesis.go +++ b/x/ssi/genesis.go @@ -10,6 +10,12 @@ import ( // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { k.SetChainNamespace(&ctx, genState.ChainNamespace) + + k.SetFeeParam(ctx, *genState.Params.CreateDidFee, types.ParamStoreKeyCreateDidFee) + k.SetFeeParam(ctx, *genState.Params.UpdateDidFee, types.ParamStoreKeyUpdateDidFee) + k.SetFeeParam(ctx, *genState.Params.DeactivateDidFee, types.ParamStoreKeyDeactivateDidFee) + k.SetFeeParam(ctx, *genState.Params.CreateSchemaFee, types.ParamStoreKeyCreateSchemaFee) + k.SetFeeParam(ctx, *genState.Params.RegisterCredentialStatusFee, types.ParamStoreKeyRegisterCredentialStatusFee) } // ExportGenesis returns the ssi module's exported genesis. @@ -17,5 +23,17 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.ChainNamespace = k.GetChainNamespace(&ctx) + createDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyCreateDidFee) + updateDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyUpdateDidFee) + deactivateDidFee := k.GetFeeParams(ctx, types.ParamStoreKeyDeactivateDidFee) + createSchemaFee := k.GetFeeParams(ctx, types.ParamStoreKeyCreateSchemaFee) + registerCredentialStatusFee := k.GetFeeParams(ctx, types.ParamStoreKeyRegisterCredentialStatusFee) + + genesis.Params.CreateDidFee = &createDidFee + genesis.Params.UpdateDidFee = &updateDidFee + genesis.Params.DeactivateDidFee = &deactivateDidFee + genesis.Params.CreateSchemaFee = &createSchemaFee + genesis.Params.RegisterCredentialStatusFee = ®isterCredentialStatusFee + return genesis } diff --git a/x/identityfee/keeper/grpc_query.go b/x/ssi/keeper/grpc_query_fee.go similarity index 94% rename from x/identityfee/keeper/grpc_query.go rename to x/ssi/keeper/grpc_query_fee.go index 4ed0b43..4501bf7 100644 --- a/x/identityfee/keeper/grpc_query.go +++ b/x/ssi/keeper/grpc_query_fee.go @@ -4,7 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/hypersign-protocol/hid-node/x/identityfee/types" + "github.com/hypersign-protocol/hid-node/x/ssi/types" ) // QuerySSIFee fetches fees for all SSI based transactions diff --git a/x/ssi/keeper/keeper.go b/x/ssi/keeper/keeper.go index b31349d..c54d401 100644 --- a/x/ssi/keeper/keeper.go +++ b/x/ssi/keeper/keeper.go @@ -16,7 +16,7 @@ type ( cdc codec.BinaryCodec storeKey sdk.StoreKey memKey sdk.StoreKey - paramstore paramtypes.Subspace + paramSpace paramtypes.Subspace } ) @@ -30,7 +30,7 @@ func NewKeeper( cdc: cdc, storeKey: storeKey, memKey: memKey, - paramstore: ps, + paramSpace: ps, } } diff --git a/x/ssi/keeper/params.go b/x/ssi/keeper/params.go new file mode 100644 index 0000000..1a4d65c --- /dev/null +++ b/x/ssi/keeper/params.go @@ -0,0 +1,15 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetFeeParam(ctx sdk.Context, fee sdk.Coin, ssiParamStoreKey []byte) { + k.paramSpace.Set(ctx, ssiParamStoreKey, fee) +} + +func (k Keeper) GetFeeParams(ctx sdk.Context, ssiParamStoreKey []byte) sdk.Coin { + var fee sdk.Coin + k.paramSpace.Get(ctx, ssiParamStoreKey, &fee) + return fee +} diff --git a/x/ssi/types/genesis.go b/x/ssi/types/genesis.go index 114d25e..e0ea226 100644 --- a/x/ssi/types/genesis.go +++ b/x/ssi/types/genesis.go @@ -7,7 +7,10 @@ import ( // DefaultGenesis returns the default ssi genesis state func DefaultGenesis() *GenesisState { - return &GenesisState{} + return &GenesisState{ + ChainNamespace: "", + Params: DefaultParams(), + } } // Validate performs basic genesis state validation returning an error upon any diff --git a/x/ssi/types/genesis.pb.go b/x/ssi/types/genesis.pb.go index 90b85bd..eaa0604 100644 --- a/x/ssi/types/genesis.pb.go +++ b/x/ssi/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -25,7 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the ssi module's genesis state. type GenesisState struct { - ChainNamespace string `protobuf:"bytes,1,opt,name=chain_namespace,json=chainNamespace,proto3" json:"chain_namespace,omitempty"` + ChainNamespace string `protobuf:"bytes,1,opt,name=chain_namespace,json=chainNamespace,proto3" json:"chain_namespace,omitempty"` + Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,27 +70,124 @@ func (m *GenesisState) GetChainNamespace() string { return "" } +func (m *GenesisState) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + +// Param defines the ssi module's params. +type Params struct { + CreateDidFee *types.Coin `protobuf:"bytes,1,opt,name=create_did_fee,json=createDidFee,proto3" json:"create_did_fee,omitempty"` + UpdateDidFee *types.Coin `protobuf:"bytes,2,opt,name=update_did_fee,json=updateDidFee,proto3" json:"update_did_fee,omitempty"` + DeactivateDidFee *types.Coin `protobuf:"bytes,3,opt,name=deactivate_did_fee,json=deactivateDidFee,proto3" json:"deactivate_did_fee,omitempty"` + CreateSchemaFee *types.Coin `protobuf:"bytes,4,opt,name=create_schema_fee,json=createSchemaFee,proto3" json:"create_schema_fee,omitempty"` + RegisterCredentialStatusFee *types.Coin `protobuf:"bytes,5,opt,name=register_credential_status_fee,json=registerCredentialStatusFee,proto3" json:"register_credential_status_fee,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_3cbaf0a49767e32e, []int{1} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetCreateDidFee() *types.Coin { + if m != nil { + return m.CreateDidFee + } + return nil +} + +func (m *Params) GetUpdateDidFee() *types.Coin { + if m != nil { + return m.UpdateDidFee + } + return nil +} + +func (m *Params) GetDeactivateDidFee() *types.Coin { + if m != nil { + return m.DeactivateDidFee + } + return nil +} + +func (m *Params) GetCreateSchemaFee() *types.Coin { + if m != nil { + return m.CreateSchemaFee + } + return nil +} + +func (m *Params) GetRegisterCredentialStatusFee() *types.Coin { + if m != nil { + return m.RegisterCredentialStatusFee + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "hypersignprotocol.hidnode.ssi.GenesisState") + proto.RegisterType((*Params)(nil), "hypersignprotocol.hidnode.ssi.Params") } func init() { proto.RegisterFile("ssi/v1/genesis.proto", fileDescriptor_3cbaf0a49767e32e) } var fileDescriptor_3cbaf0a49767e32e = []byte{ - // 199 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x2e, 0xce, 0xd4, - 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x92, 0xcd, 0xa8, 0x2c, 0x48, 0x2d, 0x2a, 0xce, 0x4c, 0xcf, 0x03, 0xf3, 0x93, 0xf3, 0x73, - 0xf4, 0x32, 0x32, 0x53, 0xf2, 0xf2, 0x53, 0x52, 0xf5, 0x8a, 0x8b, 0x33, 0xa5, 0x44, 0xd2, 0xf3, - 0xd3, 0xf3, 0xc1, 0x32, 0xfa, 0x20, 0x16, 0x44, 0x93, 0x92, 0x39, 0x17, 0x8f, 0x3b, 0xc4, 0x94, - 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x75, 0x2e, 0xfe, 0xe4, 0x8c, 0xc4, 0xcc, 0xbc, 0xf8, 0xbc, - 0xc4, 0xdc, 0xd4, 0xe2, 0x82, 0xc4, 0xe4, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x3e, - 0xb0, 0xb0, 0x1f, 0x4c, 0xd4, 0xc9, 0xe7, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, - 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, - 0xa2, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xe1, 0x4e, 0xd2, - 0x85, 0xb9, 0x49, 0x3f, 0x23, 0x33, 0x45, 0x17, 0xe4, 0x28, 0xfd, 0x0a, 0x7d, 0x90, 0x37, 0x4a, - 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xd2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, - 0xc5, 0xd5, 0x29, 0xda, 0x00, 0x00, 0x00, + // 389 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x31, 0x8f, 0xd3, 0x30, + 0x14, 0xc7, 0x9b, 0x02, 0x95, 0xf0, 0x9d, 0xee, 0x20, 0xba, 0xe1, 0x38, 0x84, 0x75, 0xaa, 0x84, + 0xe8, 0x52, 0x5b, 0x2d, 0x33, 0x42, 0xa2, 0xd0, 0x2e, 0x08, 0xa1, 0x76, 0x63, 0x20, 0x72, 0xec, + 0x47, 0x62, 0xa9, 0xb1, 0xa3, 0x3c, 0x37, 0xa2, 0xdf, 0x82, 0x8f, 0xc5, 0xd8, 0x91, 0x11, 0xb5, + 0xdf, 0x82, 0x09, 0xc5, 0x4e, 0x4b, 0x27, 0xb2, 0x25, 0xef, 0xf9, 0xf7, 0x7b, 0x7f, 0xeb, 0x99, + 0xdc, 0x20, 0x6a, 0x5e, 0x4f, 0x78, 0x06, 0x06, 0x50, 0x23, 0x2b, 0x2b, 0xeb, 0x6c, 0xfc, 0x22, + 0xdf, 0x96, 0x50, 0xa1, 0xce, 0x8c, 0xff, 0x97, 0x76, 0xcd, 0x72, 0xad, 0x8c, 0x55, 0xc0, 0x10, + 0xf5, 0xdd, 0x4d, 0x66, 0x33, 0xeb, 0x3b, 0xbc, 0xf9, 0x0a, 0xd0, 0x1d, 0x95, 0x16, 0x0b, 0x8b, + 0x3c, 0x15, 0x08, 0xbc, 0x9e, 0xa4, 0xe0, 0xc4, 0x84, 0x4b, 0xab, 0x4d, 0xe8, 0x0f, 0x6b, 0x72, + 0xb9, 0x08, 0x53, 0x56, 0x4e, 0x38, 0x88, 0x5f, 0x91, 0x6b, 0x99, 0x0b, 0x6d, 0x12, 0x23, 0x0a, + 0xc0, 0x52, 0x48, 0xb8, 0x8d, 0xee, 0xa3, 0xd1, 0xe3, 0xe5, 0x95, 0x2f, 0x7f, 0x3a, 0x56, 0xe3, + 0x37, 0x64, 0x50, 0x8a, 0x4a, 0x14, 0x78, 0xdb, 0xbf, 0x8f, 0x46, 0x17, 0xd3, 0x97, 0xec, 0xbf, + 0xf1, 0xd8, 0x67, 0x7f, 0x78, 0xd9, 0x42, 0xc3, 0x3f, 0x7d, 0x32, 0x08, 0xa5, 0xf8, 0x2d, 0xb9, + 0x92, 0x15, 0x08, 0x07, 0x89, 0xd2, 0x2a, 0xf9, 0x06, 0x61, 0xe2, 0xc5, 0xf4, 0x19, 0x0b, 0xd9, + 0x59, 0x93, 0x9d, 0xb5, 0xd9, 0xd9, 0xcc, 0x6a, 0xb3, 0xbc, 0x0c, 0xc0, 0x7b, 0xad, 0xe6, 0x00, + 0x8d, 0x60, 0x53, 0xaa, 0x73, 0x41, 0xbf, 0x53, 0x10, 0x80, 0x56, 0xb0, 0x20, 0xb1, 0x02, 0x21, + 0x9d, 0xae, 0xcf, 0x25, 0x0f, 0xba, 0x24, 0x4f, 0xfe, 0x41, 0xad, 0xe8, 0x03, 0x79, 0xda, 0x5e, + 0x05, 0x65, 0x0e, 0x85, 0xf0, 0x9e, 0x87, 0x5d, 0x9e, 0xeb, 0xc0, 0xac, 0x3c, 0xd2, 0x68, 0xbe, + 0x12, 0x5a, 0x41, 0xa6, 0xd1, 0x41, 0x95, 0xc8, 0x0a, 0x14, 0x18, 0xa7, 0xc5, 0x3a, 0x41, 0x27, + 0xdc, 0x06, 0xbd, 0xf3, 0x51, 0x97, 0xf3, 0xf9, 0x51, 0x30, 0x3b, 0xf1, 0x2b, 0x8f, 0xcf, 0x01, + 0xde, 0x7d, 0xfc, 0xb9, 0xa7, 0xd1, 0x6e, 0x4f, 0xa3, 0xdf, 0x7b, 0x1a, 0xfd, 0x38, 0xd0, 0xde, + 0xee, 0x40, 0x7b, 0xbf, 0x0e, 0xb4, 0xf7, 0x65, 0x9a, 0x69, 0x97, 0x6f, 0x52, 0x26, 0x6d, 0xc1, + 0x4f, 0xfb, 0x1c, 0x1f, 0x17, 0xca, 0x73, 0xad, 0xc6, 0xcd, 0x46, 0xf9, 0x77, 0xde, 0x3c, 0x51, + 0xb7, 0x2d, 0x01, 0xd3, 0x81, 0x6f, 0xbf, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x20, 0x2e, + 0x64, 0xb6, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -111,6 +210,18 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } if len(m.ChainNamespace) > 0 { i -= len(m.ChainNamespace) copy(dAtA[i:], m.ChainNamespace) @@ -121,6 +232,89 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RegisterCredentialStatusFee != nil { + { + size, err := m.RegisterCredentialStatusFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.CreateSchemaFee != nil { + { + size, err := m.CreateSchemaFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.DeactivateDidFee != nil { + { + size, err := m.DeactivateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.UpdateDidFee != nil { + { + size, err := m.UpdateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.CreateDidFee != nil { + { + size, err := m.CreateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -142,6 +336,39 @@ func (m *GenesisState) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreateDidFee != nil { + l = m.CreateDidFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.UpdateDidFee != nil { + l = m.UpdateDidFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.DeactivateDidFee != nil { + l = m.DeactivateDidFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.CreateSchemaFee != nil { + l = m.CreateSchemaFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.RegisterCredentialStatusFee != nil { + l = m.RegisterCredentialStatusFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -212,6 +439,272 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.ChainNamespace = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Params) 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 ErrIntOverflowGenesis + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CreateDidFee == nil { + m.CreateDidFee = &types.Coin{} + } + if err := m.CreateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateDidFee == nil { + m.UpdateDidFee = &types.Coin{} + } + if err := m.UpdateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeactivateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DeactivateDidFee == nil { + m.DeactivateDidFee = &types.Coin{} + } + if err := m.DeactivateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateSchemaFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CreateSchemaFee == nil { + m.CreateSchemaFee = &types.Coin{} + } + if err := m.CreateSchemaFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RegisterCredentialStatusFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RegisterCredentialStatusFee == nil { + m.RegisterCredentialStatusFee = &types.Coin{} + } + if err := m.RegisterCredentialStatusFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/ssi/types/keys.go b/x/ssi/types/keys.go index 203d3d8..30c32cc 100644 --- a/x/ssi/types/keys.go +++ b/x/ssi/types/keys.go @@ -32,6 +32,16 @@ const ( BlockchainAccountIdStoreKey = "blockchainaddrstorekey" ) +// Fixed Fee Param Keys + +var ( + ParamStoreKeyCreateDidFee = []byte("CreateDidFee") + ParamStoreKeyUpdateDidFee = []byte("UpdateDidFee") + ParamStoreKeyDeactivateDidFee = []byte("DeactivateDidFee") + ParamStoreKeyCreateSchemaFee = []byte("CreateSchemaFee") + ParamStoreKeyRegisterCredentialStatusFee = []byte("RegisterCredentialStatusFee") +) + func KeyPrefix(p string) []byte { return []byte(p) } diff --git a/x/ssi/types/params.go b/x/ssi/types/params.go new file mode 100644 index 0000000..1c18eeb --- /dev/null +++ b/x/ssi/types/params.go @@ -0,0 +1,50 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +var ( + DefaultCreateDIDFee = sdk.NewInt64Coin("uhid", 4000) + DefaultUpdateDIDFee = sdk.NewInt64Coin("uhid", 1000) + DefaultDeactivateDIDFee = sdk.NewInt64Coin("uhid", 1000) + DefaultCreateSchemaFee = sdk.NewInt64Coin("uhid", 2000) + DefaultRegisterCredentialStatusFee = sdk.NewInt64Coin("uhid", 2000) +) + +func DefaultParams() *Params { + return &Params{ + CreateDidFee: &DefaultCreateDIDFee, + UpdateDidFee: &DefaultUpdateDIDFee, + DeactivateDidFee: &DefaultDeactivateDIDFee, + CreateSchemaFee: &DefaultCreateSchemaFee, + RegisterCredentialStatusFee: &DefaultRegisterCredentialStatusFee, + } +} + +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable( + paramtypes.NewParamSetPair(ParamStoreKeyCreateDidFee, sdk.Coin{}, validateFeeParams), + paramtypes.NewParamSetPair(ParamStoreKeyUpdateDidFee, sdk.Coin{}, validateFeeParams), + paramtypes.NewParamSetPair(ParamStoreKeyDeactivateDidFee, sdk.Coin{}, validateFeeParams), + paramtypes.NewParamSetPair(ParamStoreKeyCreateSchemaFee, sdk.Coin{}, validateFeeParams), + paramtypes.NewParamSetPair(ParamStoreKeyRegisterCredentialStatusFee, sdk.Coin{}, validateFeeParams), + ) +} + +func validateFeeParams(i interface{}) error { + v, ok := i.(sdk.Coin) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.Denom != "uhid" { + return fmt.Errorf("fee param denom must be 'uhid', got %v", v.Denom) + } + + return nil +} \ No newline at end of file diff --git a/x/ssi/types/query.pb.go b/x/ssi/types/query.pb.go index 0eb50b8..d0e6d47 100644 --- a/x/ssi/types/query.pb.go +++ b/x/ssi/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -30,6 +31,118 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type QuerySSIFeeRequest struct { +} + +func (m *QuerySSIFeeRequest) Reset() { *m = QuerySSIFeeRequest{} } +func (m *QuerySSIFeeRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySSIFeeRequest) ProtoMessage() {} +func (*QuerySSIFeeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0f525f26163d85f3, []int{0} +} +func (m *QuerySSIFeeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySSIFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySSIFeeRequest.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 *QuerySSIFeeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySSIFeeRequest.Merge(m, src) +} +func (m *QuerySSIFeeRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySSIFeeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySSIFeeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySSIFeeRequest proto.InternalMessageInfo + +type QuerySSIFeeResponse struct { + CreateDidFee *types.Coin `protobuf:"bytes,1,opt,name=create_did_fee,json=createDidFee,proto3" json:"create_did_fee,omitempty"` + UpdateDidFee *types.Coin `protobuf:"bytes,2,opt,name=update_did_fee,json=updateDidFee,proto3" json:"update_did_fee,omitempty"` + DeactivateDidFee *types.Coin `protobuf:"bytes,3,opt,name=deactivate_did_fee,json=deactivateDidFee,proto3" json:"deactivate_did_fee,omitempty"` + CreateSchemaFee *types.Coin `protobuf:"bytes,4,opt,name=create_schema_fee,json=createSchemaFee,proto3" json:"create_schema_fee,omitempty"` + RegisterCredentialStatusFee *types.Coin `protobuf:"bytes,5,opt,name=register_credential_status_fee,json=registerCredentialStatusFee,proto3" json:"register_credential_status_fee,omitempty"` +} + +func (m *QuerySSIFeeResponse) Reset() { *m = QuerySSIFeeResponse{} } +func (m *QuerySSIFeeResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySSIFeeResponse) ProtoMessage() {} +func (*QuerySSIFeeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0f525f26163d85f3, []int{1} +} +func (m *QuerySSIFeeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySSIFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySSIFeeResponse.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 *QuerySSIFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySSIFeeResponse.Merge(m, src) +} +func (m *QuerySSIFeeResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySSIFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySSIFeeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySSIFeeResponse proto.InternalMessageInfo + +func (m *QuerySSIFeeResponse) GetCreateDidFee() *types.Coin { + if m != nil { + return m.CreateDidFee + } + return nil +} + +func (m *QuerySSIFeeResponse) GetUpdateDidFee() *types.Coin { + if m != nil { + return m.UpdateDidFee + } + return nil +} + +func (m *QuerySSIFeeResponse) GetDeactivateDidFee() *types.Coin { + if m != nil { + return m.DeactivateDidFee + } + return nil +} + +func (m *QuerySSIFeeResponse) GetCreateSchemaFee() *types.Coin { + if m != nil { + return m.CreateSchemaFee + } + return nil +} + +func (m *QuerySSIFeeResponse) GetRegisterCredentialStatusFee() *types.Coin { + if m != nil { + return m.RegisterCredentialStatusFee + } + return nil +} + type QuerySchemaRequest struct { SchemaId string `protobuf:"bytes,1,opt,name=schemaId,proto3" json:"schemaId,omitempty"` } @@ -38,7 +151,7 @@ func (m *QuerySchemaRequest) Reset() { *m = QuerySchemaRequest{} } func (m *QuerySchemaRequest) String() string { return proto.CompactTextString(m) } func (*QuerySchemaRequest) ProtoMessage() {} func (*QuerySchemaRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{0} + return fileDescriptor_0f525f26163d85f3, []int{2} } func (m *QuerySchemaRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -82,7 +195,7 @@ func (m *QuerySchemaResponse) Reset() { *m = QuerySchemaResponse{} } func (m *QuerySchemaResponse) String() string { return proto.CompactTextString(m) } func (*QuerySchemaResponse) ProtoMessage() {} func (*QuerySchemaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{1} + return fileDescriptor_0f525f26163d85f3, []int{3} } func (m *QuerySchemaResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -126,7 +239,7 @@ func (m *QuerySchemasRequest) Reset() { *m = QuerySchemasRequest{} } func (m *QuerySchemasRequest) String() string { return proto.CompactTextString(m) } func (*QuerySchemasRequest) ProtoMessage() {} func (*QuerySchemasRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{2} + return fileDescriptor_0f525f26163d85f3, []int{4} } func (m *QuerySchemasRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -171,7 +284,7 @@ func (m *QuerySchemasResponse) Reset() { *m = QuerySchemasResponse{} } func (m *QuerySchemasResponse) String() string { return proto.CompactTextString(m) } func (*QuerySchemasResponse) ProtoMessage() {} func (*QuerySchemasResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{3} + return fileDescriptor_0f525f26163d85f3, []int{5} } func (m *QuerySchemasResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -222,7 +335,7 @@ func (m *QueryCredentialRequest) Reset() { *m = QueryCredentialRequest{} func (m *QueryCredentialRequest) String() string { return proto.CompactTextString(m) } func (*QueryCredentialRequest) ProtoMessage() {} func (*QueryCredentialRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{4} + return fileDescriptor_0f525f26163d85f3, []int{6} } func (m *QueryCredentialRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -266,7 +379,7 @@ func (m *QueryCredentialResponse) Reset() { *m = QueryCredentialResponse func (m *QueryCredentialResponse) String() string { return proto.CompactTextString(m) } func (*QueryCredentialResponse) ProtoMessage() {} func (*QueryCredentialResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{5} + return fileDescriptor_0f525f26163d85f3, []int{7} } func (m *QueryCredentialResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -310,7 +423,7 @@ func (m *QueryCredentialsRequest) Reset() { *m = QueryCredentialsRequest func (m *QueryCredentialsRequest) String() string { return proto.CompactTextString(m) } func (*QueryCredentialsRequest) ProtoMessage() {} func (*QueryCredentialsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{6} + return fileDescriptor_0f525f26163d85f3, []int{8} } func (m *QueryCredentialsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -355,7 +468,7 @@ func (m *QueryCredentialsResponse) Reset() { *m = QueryCredentialsRespon func (m *QueryCredentialsResponse) String() string { return proto.CompactTextString(m) } func (*QueryCredentialsResponse) ProtoMessage() {} func (*QueryCredentialsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{7} + return fileDescriptor_0f525f26163d85f3, []int{9} } func (m *QueryCredentialsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -406,7 +519,7 @@ func (m *QueryDidDocumentRequest) Reset() { *m = QueryDidDocumentRequest func (m *QueryDidDocumentRequest) String() string { return proto.CompactTextString(m) } func (*QueryDidDocumentRequest) ProtoMessage() {} func (*QueryDidDocumentRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{8} + return fileDescriptor_0f525f26163d85f3, []int{10} } func (m *QueryDidDocumentRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -451,7 +564,7 @@ func (m *QueryDidDocumentResponse) Reset() { *m = QueryDidDocumentRespon func (m *QueryDidDocumentResponse) String() string { return proto.CompactTextString(m) } func (*QueryDidDocumentResponse) ProtoMessage() {} func (*QueryDidDocumentResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{9} + return fileDescriptor_0f525f26163d85f3, []int{11} } func (m *QueryDidDocumentResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -503,7 +616,7 @@ func (m *QueryDidDocumentsRequest) Reset() { *m = QueryDidDocumentsReque func (m *QueryDidDocumentsRequest) String() string { return proto.CompactTextString(m) } func (*QueryDidDocumentsRequest) ProtoMessage() {} func (*QueryDidDocumentsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{10} + return fileDescriptor_0f525f26163d85f3, []int{12} } func (m *QueryDidDocumentsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -555,7 +668,7 @@ func (m *QueryDidDocumentsResponse) Reset() { *m = QueryDidDocumentsResp func (m *QueryDidDocumentsResponse) String() string { return proto.CompactTextString(m) } func (*QueryDidDocumentsResponse) ProtoMessage() {} func (*QueryDidDocumentsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0f525f26163d85f3, []int{11} + return fileDescriptor_0f525f26163d85f3, []int{13} } func (m *QueryDidDocumentsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -599,6 +712,8 @@ func (m *QueryDidDocumentsResponse) GetDidDocList() []*QueryDidDocumentResponse } func init() { + proto.RegisterType((*QuerySSIFeeRequest)(nil), "hypersignprotocol.hidnode.ssi.QuerySSIFeeRequest") + proto.RegisterType((*QuerySSIFeeResponse)(nil), "hypersignprotocol.hidnode.ssi.QuerySSIFeeResponse") proto.RegisterType((*QuerySchemaRequest)(nil), "hypersignprotocol.hidnode.ssi.QuerySchemaRequest") proto.RegisterType((*QuerySchemaResponse)(nil), "hypersignprotocol.hidnode.ssi.QuerySchemaResponse") proto.RegisterType((*QuerySchemasRequest)(nil), "hypersignprotocol.hidnode.ssi.QuerySchemasRequest") @@ -616,57 +731,67 @@ func init() { func init() { proto.RegisterFile("ssi/v1/query.proto", fileDescriptor_0f525f26163d85f3) } var fileDescriptor_0f525f26163d85f3 = []byte{ - // 786 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x41, 0x6f, 0x13, 0x39, - 0x14, 0xee, 0x64, 0xb7, 0x55, 0xf7, 0x65, 0x57, 0xdb, 0x75, 0xab, 0x36, 0x1b, 0xed, 0x46, 0xd5, - 0xec, 0xb6, 0xdb, 0x6d, 0xe9, 0x4c, 0x93, 0xa8, 0x05, 0x84, 0xb8, 0xd0, 0x80, 0x54, 0x51, 0x24, - 0x98, 0x22, 0x21, 0x90, 0x38, 0x38, 0xb1, 0x35, 0xb1, 0x94, 0x8c, 0xd3, 0xd8, 0xa9, 0x5a, 0x55, - 0xb9, 0x70, 0xe1, 0x8a, 0xc4, 0x8d, 0x3f, 0xc0, 0x91, 0x03, 0x07, 0x90, 0x10, 0x77, 0x4e, 0xa8, - 0x12, 0x17, 0x8e, 0xa8, 0xe5, 0x87, 0xa0, 0xd8, 0x9e, 0xc4, 0x69, 0x5a, 0x92, 0xa9, 0xb8, 0x8d, - 0x9f, 0xfd, 0x7d, 0xef, 0x7b, 0xdf, 0xf3, 0x3c, 0x03, 0x12, 0x82, 0xf9, 0x7b, 0x79, 0x7f, 0xb7, - 0x45, 0x9b, 0x07, 0x5e, 0xa3, 0xc9, 0x25, 0x47, 0x7f, 0x57, 0x0f, 0x1a, 0xb4, 0x29, 0x58, 0x18, - 0xa9, 0x75, 0x85, 0xd7, 0xbc, 0x2a, 0x23, 0x11, 0x27, 0xd4, 0x13, 0x82, 0x65, 0x67, 0x42, 0x1e, - 0x72, 0xb5, 0xe3, 0x77, 0xbe, 0x34, 0x28, 0xfb, 0x57, 0xc8, 0x79, 0x58, 0xa3, 0x3e, 0x6e, 0x30, - 0x1f, 0x47, 0x11, 0x97, 0x58, 0x32, 0x1e, 0x09, 0xb3, 0xbb, 0x5c, 0xe1, 0xa2, 0xce, 0x85, 0x5f, - 0xc6, 0x82, 0xea, 0x5c, 0xfe, 0x5e, 0xbe, 0x4c, 0x25, 0xce, 0xfb, 0x0d, 0x1c, 0xb2, 0x48, 0x1d, - 0x36, 0x67, 0xa7, 0x8d, 0x24, 0x51, 0xa9, 0xd2, 0x3a, 0x36, 0xc1, 0x29, 0x13, 0x24, 0x8c, 0x98, - 0xc8, 0x9c, 0x89, 0x54, 0x9a, 0x94, 0xd0, 0x48, 0x32, 0x5c, 0xd3, 0x1b, 0xee, 0x1a, 0xa0, 0x7b, - 0x9d, 0x0c, 0x3b, 0x0a, 0x1f, 0xd0, 0xdd, 0x16, 0x15, 0x12, 0x65, 0x61, 0x52, 0x13, 0x6e, 0x91, - 0x8c, 0x33, 0xef, 0x2c, 0xfd, 0x12, 0x74, 0xd7, 0xee, 0x7d, 0x98, 0xee, 0x43, 0x88, 0x06, 0x8f, - 0x04, 0x45, 0xd7, 0x61, 0x42, 0x1f, 0xc9, 0x38, 0xf3, 0x3f, 0x2d, 0xa5, 0x0b, 0x0b, 0xde, 0x77, - 0x8d, 0xf1, 0x0c, 0xdc, 0x80, 0xdc, 0xc7, 0x7d, 0xac, 0x22, 0x16, 0x72, 0x0b, 0xa0, 0x57, 0xb2, - 0x92, 0x92, 0x2e, 0x2c, 0x7a, 0xda, 0x1f, 0xaf, 0xe3, 0x8f, 0xa7, 0x7b, 0x61, 0xfc, 0xf1, 0xee, - 0xe2, 0x90, 0x1a, 0x6c, 0x60, 0x21, 0xdd, 0x36, 0xcc, 0xf4, 0xd3, 0x1b, 0xd5, 0x39, 0x00, 0xc9, - 0x25, 0xae, 0x6d, 0xf2, 0x56, 0x24, 0x15, 0xff, 0xcf, 0x81, 0x15, 0x41, 0x37, 0x01, 0xb4, 0xc0, - 0x6d, 0x26, 0x64, 0x26, 0x95, 0xa4, 0x32, 0x0b, 0xe8, 0xae, 0xc1, 0xac, 0x4a, 0xbf, 0xd9, 0xb5, - 0x3f, 0x2e, 0x70, 0x16, 0x26, 0x3a, 0x3d, 0xe9, 0xfa, 0x6c, 0x56, 0x2e, 0x81, 0xb9, 0x01, 0x84, - 0xd1, 0xbc, 0x05, 0xd0, 0x39, 0xb4, 0x23, 0xb1, 0x6c, 0x09, 0xe3, 0xc9, 0xff, 0x43, 0x34, 0x59, - 0x34, 0x16, 0xd8, 0xc5, 0x03, 0x59, 0x7e, 0xb8, 0xf3, 0x4f, 0x1d, 0xc8, 0x0c, 0xe6, 0x18, 0xd1, - 0xfe, 0xdb, 0x90, 0xee, 0xdd, 0x58, 0x61, 0xfc, 0x4f, 0x50, 0xab, 0x8d, 0x76, 0x7d, 0x53, 0x6c, - 0x89, 0x91, 0x12, 0xaf, 0xb4, 0xea, 0x34, 0x92, 0x71, 0xb1, 0x33, 0x30, 0x4e, 0x58, 0xaf, 0x09, - 0x7a, 0xe1, 0xbe, 0x8b, 0xa5, 0xf7, 0x21, 0x8c, 0xf4, 0x12, 0xa4, 0x49, 0x2f, 0x6c, 0x0c, 0x72, - 0x87, 0x48, 0x2b, 0x31, 0x12, 0xd8, 0x30, 0xf4, 0x10, 0xa6, 0xad, 0xe5, 0x1d, 0x2a, 0x31, 0xc1, - 0x12, 0x67, 0x52, 0x8a, 0xed, 0xbf, 0x21, 0x6c, 0xf1, 0xf1, 0xe0, 0x2c, 0x0e, 0x77, 0x7f, 0x50, - 0xbc, 0xb0, 0xea, 0xad, 0x74, 0x2d, 0x9f, 0x0c, 0xf4, 0xe2, 0x54, 0xcb, 0x53, 0x17, 0x6e, 0xf9, - 0x0b, 0x07, 0xfe, 0x3c, 0x23, 0xb5, 0x31, 0xee, 0x5f, 0xf8, 0x4d, 0x75, 0xb8, 0xc4, 0x88, 0xdd, - 0xf6, 0xfe, 0x20, 0x7a, 0x00, 0xa0, 0x8b, 0xb2, 0x7e, 0xbc, 0xcb, 0x43, 0xfc, 0x38, 0xaf, 0x57, - 0x81, 0x45, 0x55, 0xf8, 0x38, 0x09, 0xe3, 0xea, 0x20, 0x7a, 0xe5, 0x40, 0xda, 0x1a, 0x0a, 0x28, - 0x3f, 0x0a, 0x7d, 0xdf, 0x9c, 0xcc, 0x16, 0x92, 0x40, 0xb4, 0x18, 0xf7, 0xea, 0x93, 0x4f, 0x5f, - 0x9f, 0xa7, 0x8a, 0x28, 0xef, 0x77, 0xb1, 0xab, 0x31, 0xd8, 0x37, 0x60, 0xbf, 0x33, 0xae, 0xf5, - 0xfc, 0xf0, 0x0f, 0xe3, 0xc9, 0xdb, 0x46, 0x2f, 0x1d, 0xf8, 0xd5, 0x1e, 0x63, 0x28, 0x41, 0xfe, - 0xb8, 0xf7, 0xd9, 0x62, 0x22, 0x8c, 0x11, 0xed, 0x29, 0xd1, 0x4b, 0x68, 0x71, 0x34, 0xd1, 0xe8, - 0xad, 0x03, 0x53, 0xa7, 0xdb, 0x81, 0x36, 0x12, 0xf7, 0x4f, 0x2b, 0xbe, 0x68, 0xdf, 0xdd, 0xa2, - 0x52, 0xbd, 0x8a, 0x56, 0x86, 0xa9, 0x26, 0x8c, 0xf8, 0x87, 0xea, 0xa7, 0x6f, 0xa3, 0xd7, 0x0e, - 0xfc, 0x31, 0x70, 0x7b, 0x51, 0x52, 0x0d, 0x5d, 0xbb, 0xaf, 0x24, 0x07, 0x1a, 0xf5, 0x2b, 0x4a, - 0xfd, 0x02, 0xfa, 0x67, 0x04, 0xf5, 0xe8, 0xbd, 0x03, 0xbf, 0x9f, 0x1a, 0xb3, 0x68, 0x7d, 0x94, - 0xd4, 0x03, 0x4f, 0x52, 0x76, 0x23, 0x29, 0xcc, 0xe8, 0xbd, 0xa6, 0xf4, 0xae, 0xa3, 0xe2, 0x30, - 0xbd, 0xbd, 0xa1, 0xec, 0x1f, 0xea, 0xe7, 0xae, 0x8d, 0xde, 0xc4, 0x17, 0xc6, 0x7a, 0x26, 0x50, - 0x42, 0x25, 0x22, 0xd1, 0x85, 0x39, 0xe3, 0x3d, 0x72, 0x0b, 0xaa, 0x84, 0x4b, 0x68, 0x79, 0xf4, - 0x12, 0x6e, 0x6c, 0x7f, 0x38, 0xce, 0x39, 0x47, 0xc7, 0x39, 0xe7, 0xcb, 0x71, 0xce, 0x79, 0x76, - 0x92, 0x1b, 0x3b, 0x3a, 0xc9, 0x8d, 0x7d, 0x3e, 0xc9, 0x8d, 0x3d, 0x2a, 0x84, 0x4c, 0x56, 0x5b, - 0x65, 0xaf, 0xc2, 0xeb, 0xe7, 0xf0, 0xad, 0x2a, 0xc2, 0x7d, 0x45, 0x29, 0x0f, 0x1a, 0x54, 0x94, - 0x27, 0xd4, 0x76, 0xf1, 0x5b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, 0xd8, 0xb4, 0x97, 0x6b, 0x0a, - 0x00, 0x00, + // 955 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0x26, 0x4d, 0xd4, 0x3e, 0x17, 0x9a, 0x4e, 0xa2, 0x36, 0x35, 0x60, 0x55, 0x03, 0x2d, + 0x21, 0x25, 0xbb, 0xb1, 0xad, 0x16, 0x10, 0x42, 0x48, 0xc4, 0x0d, 0x8a, 0x28, 0x12, 0x6c, 0x90, + 0x10, 0x48, 0x10, 0x4d, 0x76, 0x26, 0x9b, 0x91, 0x92, 0x1d, 0xd7, 0x33, 0x8e, 0x12, 0x45, 0xb9, + 0x70, 0xe9, 0x15, 0x89, 0x1b, 0x7f, 0x00, 0x1c, 0x39, 0x70, 0x00, 0x09, 0x71, 0xe7, 0x58, 0x89, + 0x0b, 0x47, 0x94, 0xf0, 0x3f, 0x70, 0x45, 0x9e, 0x79, 0x6b, 0x8f, 0xe3, 0x94, 0xf5, 0x46, 0xbd, + 0x79, 0x7e, 0x7c, 0xdf, 0xfb, 0xde, 0xfb, 0x9e, 0xdf, 0x2c, 0x10, 0xad, 0x65, 0xb4, 0x5f, 0x8f, + 0x1e, 0x77, 0x45, 0xe7, 0x30, 0x6c, 0x77, 0x94, 0x51, 0xe4, 0x95, 0x9d, 0xc3, 0xb6, 0xe8, 0x68, + 0x99, 0x66, 0x76, 0x9d, 0xa8, 0xdd, 0x70, 0x47, 0xf2, 0x4c, 0x71, 0x11, 0x6a, 0x2d, 0xab, 0xf3, + 0xa9, 0x4a, 0x95, 0x3d, 0x89, 0x7a, 0xbf, 0x1c, 0xa8, 0xfa, 0x72, 0xaa, 0x54, 0xba, 0x2b, 0x22, + 0xd6, 0x96, 0x11, 0xcb, 0x32, 0x65, 0x98, 0x91, 0x2a, 0xd3, 0x78, 0xba, 0x94, 0x28, 0xbd, 0xa7, + 0x74, 0xb4, 0xc5, 0xb4, 0x70, 0xb1, 0xa2, 0xfd, 0xfa, 0x96, 0x30, 0xac, 0x1e, 0xb5, 0x59, 0x2a, + 0x33, 0x7b, 0x19, 0xef, 0xce, 0xa1, 0x24, 0x9d, 0xec, 0x88, 0x3d, 0x86, 0x9b, 0xb3, 0xb8, 0xc9, + 0x25, 0xc7, 0x9d, 0x9b, 0xb8, 0x93, 0x74, 0x04, 0x17, 0x99, 0x91, 0x6c, 0x17, 0x0f, 0x6a, 0x7e, + 0xac, 0x3c, 0x4a, 0xa2, 0x24, 0xf2, 0xd3, 0x79, 0x20, 0x9f, 0xf6, 0x14, 0x6c, 0x6c, 0xac, 0xaf, + 0x09, 0x11, 0x8b, 0xc7, 0x5d, 0xa1, 0x0d, 0x7d, 0x32, 0x05, 0x73, 0x43, 0xdb, 0xba, 0xad, 0x32, + 0x2d, 0xc8, 0xfb, 0xf0, 0x62, 0xd2, 0x11, 0xcc, 0x88, 0x4d, 0x2e, 0xf9, 0xe6, 0xb6, 0x10, 0x0b, + 0xc1, 0xed, 0x60, 0xb1, 0xd2, 0xb8, 0x15, 0xba, 0x30, 0x61, 0x2f, 0x4c, 0x88, 0x61, 0xc2, 0x55, + 0x25, 0xb3, 0xf8, 0xaa, 0x03, 0xb4, 0x24, 0x5f, 0x13, 0x96, 0xa0, 0xdb, 0xe6, 0x3e, 0xc1, 0x64, + 0x21, 0x81, 0x03, 0x20, 0xc1, 0x87, 0x40, 0xb8, 0x60, 0x89, 0x91, 0xfb, 0x3e, 0xc9, 0x54, 0x11, + 0xc9, 0xec, 0x00, 0x84, 0x44, 0x0f, 0xe1, 0x3a, 0xa6, 0xe2, 0x4a, 0x6b, 0x79, 0x2e, 0x15, 0xf1, + 0x5c, 0x73, 0x98, 0x0d, 0x0b, 0xe9, 0xd1, 0x7c, 0x0d, 0xb5, 0x8e, 0x48, 0xa5, 0x36, 0xa2, 0xb3, + 0x39, 0x28, 0xfe, 0xa6, 0x36, 0xcc, 0x74, 0xb5, 0xe5, 0x9c, 0x2e, 0xe2, 0x7c, 0x29, 0x27, 0x58, + 0xed, 0xe3, 0x37, 0x2c, 0x7c, 0x4d, 0x08, 0xba, 0x92, 0xfb, 0x63, 0x23, 0xa2, 0x3f, 0xa4, 0x0a, + 0x97, 0x9d, 0xea, 0x75, 0x6e, 0x1d, 0xb8, 0x12, 0xf7, 0xd7, 0xf4, 0xb3, 0xdc, 0x3a, 0x44, 0xa0, + 0x75, 0xef, 0xc1, 0x8c, 0xbb, 0xb2, 0x10, 0xdc, 0x9e, 0x5a, 0xac, 0x34, 0xee, 0x84, 0xff, 0xdb, + 0xd8, 0x21, 0xc2, 0x11, 0x44, 0xbf, 0x1a, 0x62, 0xd5, 0xb9, 0x90, 0x35, 0x80, 0x41, 0xcb, 0x62, + 0x33, 0xdc, 0x1d, 0x4a, 0xd5, 0xfd, 0x97, 0xf2, 0x84, 0x3f, 0x61, 0x69, 0xde, 0x64, 0xb1, 0x87, + 0xa4, 0xc7, 0x30, 0x3f, 0x4c, 0x8f, 0xaa, 0x6b, 0x00, 0x46, 0x19, 0xb6, 0xbb, 0xaa, 0xba, 0x99, + 0xb1, 0xfc, 0x97, 0x62, 0x6f, 0x87, 0x3c, 0x04, 0x70, 0x02, 0x1f, 0x49, 0x6d, 0x16, 0x26, 0xcb, + 0x64, 0xe6, 0x01, 0xe9, 0x0a, 0xdc, 0xb0, 0xe1, 0x07, 0x0e, 0xe4, 0x09, 0xde, 0x80, 0x99, 0x9e, + 0xad, 0xfd, 0x3a, 0xe3, 0x8a, 0x72, 0xb8, 0x39, 0x82, 0x40, 0xcd, 0xeb, 0x00, 0xbd, 0x4b, 0xce, + 0x43, 0xac, 0xc9, 0x1b, 0x05, 0x9a, 0x3c, 0x1a, 0x0f, 0x4c, 0xd9, 0x48, 0x94, 0xe7, 0x5e, 0xf9, + 0x27, 0x01, 0x2c, 0x8c, 0xc6, 0x18, 0xb3, 0xfc, 0x1f, 0x41, 0x65, 0xd0, 0xf4, 0x1a, 0xeb, 0x5f, + 0x22, 0x57, 0x1f, 0x4d, 0x23, 0x4c, 0xb6, 0x25, 0x79, 0x4b, 0x25, 0xdd, 0x3d, 0x91, 0x99, 0x3c, + 0xd9, 0x79, 0x98, 0xe6, 0x72, 0x60, 0x82, 0x5b, 0xd0, 0xdf, 0x72, 0xe9, 0x43, 0x08, 0x94, 0xde, + 0x82, 0x0a, 0x1f, 0x6c, 0x63, 0x81, 0x68, 0x81, 0xb4, 0x96, 0xe4, 0xb1, 0x0f, 0x23, 0x5f, 0xc0, + 0x9c, 0xb7, 0xfc, 0x58, 0x18, 0xc6, 0x99, 0x61, 0x38, 0xb4, 0x5e, 0x2f, 0x60, 0xcb, 0xaf, 0xc7, + 0xe7, 0x71, 0xd0, 0x83, 0x51, 0xf1, 0xda, 0xcb, 0x37, 0xe9, 0x97, 0xfc, 0x72, 0xec, 0x16, 0x67, + 0x2c, 0x9f, 0xbc, 0xb0, 0xe5, 0xdf, 0x07, 0x70, 0xeb, 0x9c, 0xd0, 0x58, 0xb8, 0xd7, 0xe0, 0x05, + 0xeb, 0x70, 0x4b, 0x72, 0xdf, 0xf6, 0xe1, 0x4d, 0xf2, 0x39, 0x80, 0x4b, 0xca, 0xfb, 0xe3, 0xbd, + 0x55, 0x50, 0x8f, 0x67, 0x79, 0x15, 0x7b, 0x54, 0x8d, 0x7f, 0xaf, 0xc0, 0xb4, 0xbd, 0x48, 0x7e, + 0x0a, 0xa0, 0xe2, 0x0d, 0x05, 0x52, 0x1f, 0x87, 0x7e, 0x68, 0x4e, 0x56, 0x1b, 0x65, 0x20, 0x4e, + 0x0c, 0x7d, 0xe7, 0x9b, 0x3f, 0xff, 0xf9, 0x6e, 0xb2, 0x49, 0xea, 0x51, 0x1f, 0xbb, 0x9c, 0x83, + 0x23, 0x04, 0x47, 0xbd, 0xe7, 0xd6, 0xcd, 0x8f, 0xe8, 0x28, 0x9f, 0xbc, 0xc7, 0xe4, 0xc7, 0x00, + 0xae, 0xfa, 0x63, 0x8c, 0x94, 0x88, 0x9f, 0x7b, 0x5f, 0x6d, 0x96, 0xc2, 0xa0, 0xe8, 0xd0, 0x8a, + 0x5e, 0x24, 0x77, 0xc7, 0x13, 0x4d, 0x7e, 0x0d, 0x60, 0xf6, 0xac, 0x1d, 0xe4, 0x41, 0x69, 0xff, + 0x9c, 0xe2, 0x8b, 0xfa, 0x4e, 0x9b, 0x56, 0xf5, 0x32, 0xb9, 0x57, 0xa4, 0x9a, 0x4b, 0x1e, 0x1d, + 0xd9, 0x3f, 0xfd, 0x31, 0xf9, 0x39, 0x80, 0xeb, 0x23, 0xdd, 0x4b, 0xca, 0x6a, 0xe8, 0x97, 0xfb, + 0xed, 0xf2, 0x40, 0x54, 0x7f, 0xcf, 0xaa, 0xbf, 0x43, 0x5e, 0x1d, 0x43, 0x3d, 0xf9, 0x3d, 0x80, + 0x6b, 0x67, 0xc6, 0x2c, 0xb9, 0x3f, 0x4e, 0xe8, 0x91, 0x27, 0xa9, 0xfa, 0xa0, 0x2c, 0x0c, 0xf5, + 0xbe, 0x6b, 0xf5, 0xde, 0x27, 0xcd, 0x22, 0xbd, 0x83, 0xa1, 0x1c, 0x1d, 0xb9, 0xe7, 0xee, 0x98, + 0xfc, 0x92, 0x37, 0x8c, 0xf7, 0x4c, 0x90, 0x92, 0x4a, 0x74, 0xa9, 0x86, 0x39, 0xe7, 0x3d, 0xa2, + 0x0d, 0x9b, 0xc2, 0x9b, 0x64, 0x69, 0xfc, 0x14, 0xc8, 0x0f, 0xfd, 0x31, 0x62, 0xbf, 0x65, 0xc7, + 0x1c, 0x23, 0xfe, 0xe7, 0xf0, 0x98, 0x63, 0x64, 0xe8, 0x53, 0x99, 0xae, 0x58, 0xa9, 0x4b, 0x64, + 0xb1, 0x48, 0xea, 0xb6, 0x3c, 0x10, 0x7c, 0x5b, 0x88, 0x0f, 0x1e, 0xfd, 0x71, 0x52, 0x0b, 0x9e, + 0x9e, 0xd4, 0x82, 0xbf, 0x4f, 0x6a, 0xc1, 0xb7, 0xa7, 0xb5, 0x89, 0xa7, 0xa7, 0xb5, 0x89, 0xbf, + 0x4e, 0x6b, 0x13, 0x5f, 0x36, 0x52, 0x69, 0x76, 0xba, 0x5b, 0x61, 0xa2, 0xf6, 0x9e, 0xc1, 0xb6, + 0x6c, 0xe9, 0x0e, 0x2c, 0xa1, 0x39, 0x6c, 0x0b, 0xbd, 0x35, 0x63, 0x8f, 0x9b, 0xff, 0x05, 0x00, + 0x00, 0xff, 0xff, 0x91, 0x3f, 0xa7, 0xfc, 0xd4, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -693,6 +818,8 @@ type QueryClient interface { QueryCredential(ctx context.Context, in *QueryCredentialRequest, opts ...grpc.CallOption) (*QueryCredentialResponse, error) // Get all the registed Credential Statuses QueryCredentials(ctx context.Context, in *QueryCredentialsRequest, opts ...grpc.CallOption) (*QueryCredentialsResponse, error) + // Get the list of fixed fees for every x/ssi module transactions + QuerySSIFee(ctx context.Context, in *QuerySSIFeeRequest, opts ...grpc.CallOption) (*QuerySSIFeeResponse, error) } type queryClient struct { @@ -757,6 +884,15 @@ func (c *queryClient) QueryCredentials(ctx context.Context, in *QueryCredentials return out, nil } +func (c *queryClient) QuerySSIFee(ctx context.Context, in *QuerySSIFeeRequest, opts ...grpc.CallOption) (*QuerySSIFeeResponse, error) { + out := new(QuerySSIFeeResponse) + err := c.cc.Invoke(ctx, "/hypersignprotocol.hidnode.ssi.Query/QuerySSIFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Get the Schema Document for a specified schema id @@ -771,6 +907,8 @@ type QueryServer interface { QueryCredential(context.Context, *QueryCredentialRequest) (*QueryCredentialResponse, error) // Get all the registed Credential Statuses QueryCredentials(context.Context, *QueryCredentialsRequest) (*QueryCredentialsResponse, error) + // Get the list of fixed fees for every x/ssi module transactions + QuerySSIFee(context.Context, *QuerySSIFeeRequest) (*QuerySSIFeeResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -795,6 +933,9 @@ func (*UnimplementedQueryServer) QueryCredential(ctx context.Context, req *Query func (*UnimplementedQueryServer) QueryCredentials(ctx context.Context, req *QueryCredentialsRequest) (*QueryCredentialsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryCredentials not implemented") } +func (*UnimplementedQueryServer) QuerySSIFee(ctx context.Context, req *QuerySSIFeeRequest) (*QuerySSIFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QuerySSIFee not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -908,6 +1049,24 @@ func _Query_QueryCredentials_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Query_QuerySSIFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySSIFeeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QuerySSIFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hypersignprotocol.hidnode.ssi.Query/QuerySSIFee", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QuerySSIFee(ctx, req.(*QuerySSIFeeRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "hypersignprotocol.hidnode.ssi.Query", HandlerType: (*QueryServer)(nil), @@ -936,11 +1095,121 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryCredentials", Handler: _Query_QueryCredentials_Handler, }, + { + MethodName: "QuerySSIFee", + Handler: _Query_QuerySSIFee_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ssi/v1/query.proto", } +func (m *QuerySSIFeeRequest) 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 *QuerySSIFeeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySSIFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QuerySSIFeeResponse) 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 *QuerySSIFeeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySSIFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RegisterCredentialStatusFee != nil { + { + size, err := m.RegisterCredentialStatusFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.CreateSchemaFee != nil { + { + size, err := m.CreateSchemaFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.DeactivateDidFee != nil { + { + size, err := m.DeactivateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.UpdateDidFee != nil { + { + size, err := m.UpdateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.CreateDidFee != nil { + { + size, err := m.CreateDidFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *QuerySchemaRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1402,6 +1671,44 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QuerySSIFeeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QuerySSIFeeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreateDidFee != nil { + l = m.CreateDidFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.UpdateDidFee != nil { + l = m.UpdateDidFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.DeactivateDidFee != nil { + l = m.DeactivateDidFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.CreateSchemaFee != nil { + l = m.CreateSchemaFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.RegisterCredentialStatusFee != nil { + l = m.RegisterCredentialStatusFee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QuerySchemaRequest) Size() (n int) { if m == nil { return 0 @@ -1588,6 +1895,286 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QuerySSIFeeRequest) 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 ErrIntOverflowQuery + } + 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: QuerySSIFeeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySSIFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySSIFeeResponse) 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 ErrIntOverflowQuery + } + 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: QuerySSIFeeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySSIFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CreateDidFee == nil { + m.CreateDidFee = &types.Coin{} + } + if err := m.CreateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateDidFee == nil { + m.UpdateDidFee = &types.Coin{} + } + if err := m.UpdateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeactivateDidFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DeactivateDidFee == nil { + m.DeactivateDidFee = &types.Coin{} + } + if err := m.DeactivateDidFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateSchemaFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CreateSchemaFee == nil { + m.CreateSchemaFee = &types.Coin{} + } + if err := m.CreateSchemaFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RegisterCredentialStatusFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RegisterCredentialStatusFee == nil { + m.RegisterCredentialStatusFee = &types.Coin{} + } + if err := m.RegisterCredentialStatusFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QuerySchemaRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/ssi/types/query.pb.gw.go b/x/ssi/types/query.pb.gw.go index 83f117b..6f93621 100644 --- a/x/ssi/types/query.pb.gw.go +++ b/x/ssi/types/query.pb.gw.go @@ -303,6 +303,24 @@ func local_request_Query_QueryCredentials_0(ctx context.Context, marshaler runti } +func request_Query_QuerySSIFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySSIFeeRequest + var metadata runtime.ServerMetadata + + msg, err := client.QuerySSIFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QuerySSIFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySSIFeeRequest + var metadata runtime.ServerMetadata + + msg, err := server.QuerySSIFee(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. @@ -447,6 +465,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -608,6 +649,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QuerySSIFee_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_QuerySSIFee_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_QuerySSIFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -623,6 +684,8 @@ var ( pattern_Query_QueryCredential_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"hypersign-protocol", "hidnode", "ssi", "credential", "credId"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryCredentials_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"hypersign-protocol", "hidnode", "ssi", "credential"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QuerySSIFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"hypersign-protocol", "hidnode", "ssi", "fixedfee"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -637,4 +700,6 @@ var ( forward_Query_QueryCredential_0 = runtime.ForwardResponseMessage forward_Query_QueryCredentials_0 = runtime.ForwardResponseMessage + + forward_Query_QuerySSIFee_0 = runtime.ForwardResponseMessage ) From e4d8ad11cb7277f18b313adda02253dd7959f285 Mon Sep 17 00:00:00 2001 From: Arnab Ghose Date: Sat, 12 Aug 2023 17:24:36 +0530 Subject: [PATCH 07/11] added check to meter ssi sub-messages present in authz MsgExec message --- app/ante.go | 4 +- x/ssi/ante/decorators.go | 176 +++++++++++++--------------- x/ssi/ante/fee.go | 36 ++++++ x/ssi/ante/filter.go | 40 +++++++ x/ssi/ante/filter_test.go | 104 ++++++++++++++++ x/ssi/ante/{types.go => keepers.go} | 0 x/ssi/ante/utils.go | 35 ++---- 7 files changed, 278 insertions(+), 117 deletions(-) create mode 100644 x/ssi/ante/fee.go create mode 100644 x/ssi/ante/filter.go create mode 100644 x/ssi/ante/filter_test.go rename x/ssi/ante/{types.go => keepers.go} (100%) diff --git a/app/ante.go b/app/ante.go index 0422b6d..a91da53 100644 --- a/app/ante.go +++ b/app/ante.go @@ -39,8 +39,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first ante.NewRejectExtensionOptionsDecorator(), - ssiante.NewSSITxDecorator(), - ssiante.NewMempoolFeeDecorator(), + ssiante.NewSSITxDecorator(), // SSITxDecorator MUST always be called before MempoolFeeDecorator + ssiante.NewMempoolFeeDecorator(), // MempoolFeeDecorator MUST always be called before DeductFeeDecorator ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.AccountKeeper), diff --git a/x/ssi/ante/decorators.go b/x/ssi/ante/decorators.go index 7473149..a8be82e 100644 --- a/x/ssi/ante/decorators.go +++ b/x/ssi/ante/decorators.go @@ -6,9 +6,81 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/types" - ssitypes "github.com/hypersign-protocol/hid-node/x/ssi/types" ) +// SSITxDecorator ensures that transactions containing SSI messages are combined with messages from other modules. +// This is due to the fixed fees associated with SSI messages, irrespective of message size +type SSITxDecorator struct{} + +func NewSSITxDecorator() SSITxDecorator { + return SSITxDecorator{} +} + +func (SSITxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + msgs := tx.GetMsgs() + ssiMsgs, nonSsiMsgs := filterMsgsIntoSSIAndNonSSI(msgs) + + if len(ssiMsgs) != 0 && len(nonSsiMsgs) != 0 { + return ctx, fmt.Errorf("combining SSI and non-SSI messages in a transaction is not allowed") + } + + return next(ctx, tx, simulate) +} + +// MempoolFeeDecorator will check if the transaction's fee is at least as large +// as the local validator's minimum gasFee (defined in validator config). +// If fee is too low, decorator returns error and tx is rejected from mempool. +// Note this only applies when ctx.CheckTx = true and transaction with only non-SSI messages +// If fee is high enough or not CheckTx or the transaction consists of only SSI messages, then call next AnteHandler +// CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator +type MempoolFeeDecorator struct{} + +func NewMempoolFeeDecorator() MempoolFeeDecorator { + return MempoolFeeDecorator{} +} + +func (mfd MempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") + } + + feeCoins := feeTx.GetFee() + gas := feeTx.GetGas() + + // Get list of non SSI messages + msgs := tx.GetMsgs() + _, nonSSIMsgs := filterMsgsIntoSSIAndNonSSI(msgs) + + // Ensure that the provided fees meet a minimum threshold for the validator, + // if this is a CheckTx. This is only for local mempool purposes, and thus + // is only ran on check tx. SSI messages incur fixed fee regardless of their size + // and hence any transaction consisting of only SSI messages should skip the following check + if ctx.IsCheckTx() && !simulate && (len(nonSSIMsgs) > 0) { + minGasPrices := ctx.MinGasPrices() + if !minGasPrices.IsZero() { + requiredFees := make(sdk.Coins, len(minGasPrices)) + + // Determine the required fees by multiplying each required minimum gas + // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). + glDec := sdk.NewDec(int64(gas)) + for i, gp := range minGasPrices { + fee := gp.Amount.Mul(glDec) + requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) + } + + if !feeCoins.IsAnyGTE(requiredFees) { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) + } + } + } + + return next(ctx, tx, simulate) +} + +// ModifiedFeeDecorator is modified version of Cosmos SDK's DeductFeeDecorator implementation which extends it and makes all x/ssi module +// related transactions incur fixed fee cost. Fixed fee is seperate for each x/ssi module transactions and are updated through Governance +// based proposals. Please refer HIP-9 to know more: https://github.com/hypersign-protocol/HIPs/blob/main/HIPs/hip-9.md type DeductFeeDecorator struct { ak AccountKeeper bankKeeper BankKeeper @@ -16,9 +88,6 @@ type DeductFeeDecorator struct { ssiKeeper SsiKeeper } -// ModifiedFeeDecorator extends NewDeductFeeDecorator by making all x/ssi module related transactions incur fixed fee cost. -// Fixed fee is seperate for each x/ssi module transactions and are updated through Governance based proposals. Please refer -// HIP-9 to know more: https://github.com/hypersign-protocol/HIPs/blob/main/HIPs/hip-9.md func NewDeductFeeDecorator(ak AccountKeeper, bk BankKeeper, fk FeegrantKeeper, ifk SsiKeeper) DeductFeeDecorator { return DeductFeeDecorator{ ak: ak, @@ -64,36 +133,22 @@ func (mfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", deductFeesFrom) } + // Filter SSI messages from Tx messages + ssiMsgs, _ := filterMsgsIntoSSIAndNonSSI(tx.GetMsgs()) + // If present, calculate the total fee of all fixed-cost x/ssi messages - if isSSIMsgPresentInTx(feeTx) { - var fixedSSIFee sdk.Coins = sdk.NewCoins(sdk.NewCoin("uhid", sdk.NewInt(0))) - - for _, msg := range tx.GetMsgs() { - switch msg.(type) { - case *ssitypes.MsgCreateDID: - createDidFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyCreateDidFee) - fixedSSIFee = fixedSSIFee.Add(createDidFee) - case *ssitypes.MsgUpdateDID: - updateDidFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyUpdateDidFee) - fixedSSIFee = fixedSSIFee.Add(updateDidFee) - case *ssitypes.MsgDeactivateDID: - deactivateDidFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyDeactivateDidFee) - fixedSSIFee = fixedSSIFee.Add(deactivateDidFee) - case *ssitypes.MsgCreateSchema: - createSchemaFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyCreateSchemaFee) - fixedSSIFee = fixedSSIFee.Add(createSchemaFee) - case *ssitypes.MsgRegisterCredentialStatus: - registerCredentialStatusFee := mfd.ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyRegisterCredentialStatusFee) - fixedSSIFee = fixedSSIFee.Add(registerCredentialStatusFee) - } + if len(ssiMsgs) > 0 { + fixedSSIFee, err := calculateSSIFeeFromMsgs(ctx, mfd.ssiKeeper, ssiMsgs) + if err != nil { + return ctx, err } // If there is atleast one x/ssi message, check if the fee provided meets the requirement for the fixedSSIFee by asserting if the former // is greater than or equal to the latter. If fixedSSIFee is Zero, go ahead with normal fee deduction if !fee.IsEqual(fixedSSIFee) { - errMsg1 := "the transaction consists of x/ssi module based messages which incurs fixed cost. " - errMsg2 := "The fee provided MUST BE equal to the required fees which is the sum of all fixed-fee x/ssi. " - errMsg3 := "To know about the fixed-fee cost of all x/ssi transactions, refer to the API endpoint /hypersign-protocol/hidnode/fixedfee . " + errMsg1 := "the transaction consists of x/ssi module based messages which incur fixed cost. " + errMsg2 := "The fee provided MUST BE equal to the sum of all fixed-fee x/ssi messages. " + errMsg3 := "To know about the fixed-fee cost of all x/ssi transactions, refer the API endpoint /hypersign-protocol/hidnode/fixedfee . " return ctx, sdkerrors.Wrapf( sdkerrors.ErrInsufficientFee, @@ -104,7 +159,7 @@ func (mfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } // Deduct fixed SSI fee - err := deductFees(mfd.bankKeeper, ctx, deductFeesFromAcc, fee) + err = deductFees(mfd.bankKeeper, ctx, deductFeesFromAcc, fee) if err != nil { return ctx, err } @@ -154,66 +209,3 @@ func deductFees(bankKeeper BankKeeper, ctx sdk.Context, acc types.AccountI, fees return nil } - -// MempoolFeeDecorator will check if the transaction's fee is at least as large -// as the local validator's minimum gasFee (defined in validator config). -// If fee is too low, decorator returns error and tx is rejected from mempool. -// Note this only applies when ctx.CheckTx = true and transaction with only non-SSI messages -// If fee is high enough or not CheckTx or the transaction consists of only SSI messages, then call next AnteHandler -// CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator -type MempoolFeeDecorator struct{} - -func NewMempoolFeeDecorator() MempoolFeeDecorator { - return MempoolFeeDecorator{} -} - -func (mfd MempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - feeTx, ok := tx.(sdk.FeeTx) - if !ok { - return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") - } - - feeCoins := feeTx.GetFee() - gas := feeTx.GetGas() - - // Ensure that the provided fees meet a minimum threshold for the validator, - // if this is a CheckTx. This is only for local mempool purposes, and thus - // is only ran on check tx. SSI messages incur fixed fee regardless of their size - // and hence any transaction consisting of only SSI messages should skip the following check - if ctx.IsCheckTx() && !simulate && !isSSIMsgPresentInTx(feeTx) { - minGasPrices := ctx.MinGasPrices() - if !minGasPrices.IsZero() { - requiredFees := make(sdk.Coins, len(minGasPrices)) - - // Determine the required fees by multiplying each required minimum gas - // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). - glDec := sdk.NewDec(int64(gas)) - for i, gp := range minGasPrices { - fee := gp.Amount.Mul(glDec) - requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) - } - - if !feeCoins.IsAnyGTE(requiredFees) { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) - } - } - } - - return next(ctx, tx, simulate) -} - -// SSITxDecorator ensures that any transaction which contains SSI messages should not have messages of other modules, since fees for -// SSI messages are fixed regardless of the size of message, they should not be mixed other module's messages. -type SSITxDecorator struct{} - -func NewSSITxDecorator() SSITxDecorator { - return SSITxDecorator{} -} - -func (ssifd SSITxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - if isNonSSIMsgPresentInTx(tx) && isSSIMsgPresentInTx(tx) { - return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "ssi transaction messages cannot be grouped with other module messages") - } - - return next(ctx, tx, simulate) -} diff --git a/x/ssi/ante/fee.go b/x/ssi/ante/fee.go new file mode 100644 index 0000000..7110086 --- /dev/null +++ b/x/ssi/ante/fee.go @@ -0,0 +1,36 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + ssitypes "github.com/hypersign-protocol/hid-node/x/ssi/types" +) + +// getFeeForSSIMsg returns fee for the input SSI message +func getFeeForSSIMsg(ctx sdk.Context, msg sdk.Msg, ssiKeeper SsiKeeper) sdk.Coin { + switch msg.(type) { + case *ssitypes.MsgCreateDID: + return ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyCreateDidFee) + case *ssitypes.MsgUpdateDID: + return ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyUpdateDidFee) + case *ssitypes.MsgDeactivateDID: + return ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyDeactivateDidFee) + case *ssitypes.MsgCreateSchema: + return ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyCreateSchemaFee) + case *ssitypes.MsgRegisterCredentialStatus: + return ssiKeeper.GetFeeParams(ctx, ssitypes.ParamStoreKeyRegisterCredentialStatusFee) + default: + return sdk.NewCoin("uhid", sdk.NewInt(0)) + } +} + +// calculateSSIFeeFromMsgs calculates the total SSI fixed fee from messages +func calculateSSIFeeFromMsgs(ctx sdk.Context, ssiKeeper SsiKeeper, msgs []SSIMsg) (sdk.Coins, error) { + var totalFee sdk.Coins = sdk.NewCoins(sdk.NewCoin("uhid", sdk.NewInt(0))) + + for _, msg := range msgs { + msgFee := getFeeForSSIMsg(ctx, msg, ssiKeeper) + totalFee = totalFee.Add(msgFee) + } + + return totalFee, nil +} diff --git a/x/ssi/ante/filter.go b/x/ssi/ante/filter.go new file mode 100644 index 0000000..e55a24b --- /dev/null +++ b/x/ssi/ante/filter.go @@ -0,0 +1,40 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" +) + +type SSIMsg sdk.Msg +type NonSSIMsg sdk.Msg + +// filterMsgsIntoSSIAndNonSSI filters transaction messages into SSI and non-SSI messages +func filterMsgsIntoSSIAndNonSSI(msgs []sdk.Msg) ([]SSIMsg, []NonSSIMsg) { + msgList := []sdk.Msg{} + for _, msg := range msgs { + // Append every sub-message of Authz's MsgExec to msgList + if isAuthzExecMsg(msg) { + subMsgs, err := msg.(*authz.MsgExec).GetMessages() + if err != nil { + panic(err) + } + msgList = append(msgList, subMsgs...) + } else { + msgList = append(msgList, msg) + } + } + + // Categorize messages into SSI and non-SSI + ssiMsgs := []SSIMsg{} + nonSsiMsgs := []NonSSIMsg{} + + for _, msg := range msgList { + if isSSIMsg(msg) { + ssiMsgs = append(ssiMsgs, msg) + } else { + nonSsiMsgs = append(nonSsiMsgs, msg) + } + } + + return ssiMsgs, nonSsiMsgs +} diff --git a/x/ssi/ante/filter_test.go b/x/ssi/ante/filter_test.go new file mode 100644 index 0000000..0acf9f2 --- /dev/null +++ b/x/ssi/ante/filter_test.go @@ -0,0 +1,104 @@ +package ante + +import ( + "testing" + + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + ssitypes "github.com/hypersign-protocol/hid-node/x/ssi/types" + "github.com/stretchr/testify/require" +) + +func TestFilterMsgsIntoSSIAndNonSSI(t *testing.T) { + t.Run("two SSI messages", func(t *testing.T) { + msgList := []sdk.Msg{ + &ssitypes.MsgCreateDID{}, + &ssitypes.MsgCreateSchema{}, + } + + ssiMsgs, nonSSImsgs := filterMsgsIntoSSIAndNonSSI(msgList) + + require.Equal(t, 2, len(ssiMsgs)) + require.Equal(t, 0, len(nonSSImsgs)) + }) + + t.Run("one SSI message and one non SSI message", func(t *testing.T) { + msgList := []sdk.Msg{ + &ssitypes.MsgCreateDID{}, + &authz.MsgGrant{}, + } + + ssiMsgs, nonSSImsgs := filterMsgsIntoSSIAndNonSSI(msgList) + + require.Equal(t, 1, len(ssiMsgs)) + require.Equal(t, 1, len(nonSSImsgs)) + }) + + t.Run("one SSI message and one AuthzExec message containing two SSI message", func(t *testing.T) { + msgList := []sdk.Msg{ + &ssitypes.MsgCreateDID{}, + &authz.MsgExec{ + Msgs: makeMsgsForAny( + &ssitypes.MsgCreateDID{}, + &ssitypes.MsgCreateSchema{}, + ), + }, + } + + ssiMsgs, nonSSImsgs := filterMsgsIntoSSIAndNonSSI(msgList) + + require.Equal(t, 3, len(ssiMsgs)) + require.Equal(t, 0, len(nonSSImsgs)) + }) + + t.Run("one SSI message and one AuthzExec message containing two non SSI message", func(t *testing.T) { + msgList := []sdk.Msg{ + &ssitypes.MsgCreateDID{}, + &authz.MsgExec{ + Msgs: makeMsgsForAny( + &banktypes.MsgSend{}, + &banktypes.MsgSend{}, + ), + }, + } + + ssiMsgs, nonSSImsgs := filterMsgsIntoSSIAndNonSSI(msgList) + + require.Equal(t, 1, len(ssiMsgs)) + require.Equal(t, 2, len(nonSSImsgs)) + }) + + t.Run("two non SSI message and one AuthzExec message containing two SSI messages", func(t *testing.T) { + msgList := []sdk.Msg{ + &banktypes.MsgSend{}, + &banktypes.MsgSend{}, + &authz.MsgExec{ + Msgs: makeMsgsForAny( + &ssitypes.MsgCreateDID{}, + &ssitypes.MsgCreateSchema{}, + ), + }, + } + + ssiMsgs, nonSSIMsgs := filterMsgsIntoSSIAndNonSSI(msgList) + + require.Equal(t, 2, len(ssiMsgs)) + require.Equal(t, 2, len(nonSSIMsgs)) + }) +} + +func makeMsgsForAny(msgs ...sdk.Msg) []*cdctypes.Any { + anyMsgs := []*cdctypes.Any{} + + for _, msg := range msgs { + anyMsg, err := cdctypes.NewAnyWithValue(msg) + if err != nil { + panic(err) + } + anyMsgs = append(anyMsgs, anyMsg) + } + + return anyMsgs +} diff --git a/x/ssi/ante/types.go b/x/ssi/ante/keepers.go similarity index 100% rename from x/ssi/ante/types.go rename to x/ssi/ante/keepers.go diff --git a/x/ssi/ante/utils.go b/x/ssi/ante/utils.go index 4b589ec..6320bd1 100644 --- a/x/ssi/ante/utils.go +++ b/x/ssi/ante/utils.go @@ -2,10 +2,21 @@ package ante import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" ssitypes "github.com/hypersign-protocol/hid-node/x/ssi/types" ) -// isSSIMsg checks if the message is of SSI type or not +// isAuthzExecMsg checks if the message is of authz.MsgExec type +func isAuthzExecMsg(msg sdk.Msg) bool { + switch msg.(type) { + case *authz.MsgExec: + return true + default: + return false + } +} + +// isSSIMsg checks if the message is of SSI type func isSSIMsg(msg sdk.Msg) bool { switch msg.(type) { case *ssitypes.MsgCreateDID: @@ -22,25 +33,3 @@ func isSSIMsg(msg sdk.Msg) bool { return false } } - -// isSSIMsgPresentInTx checks if there is any SSI message present in the transaction -func isSSIMsgPresentInTx(tx sdk.Tx) bool { - for _, msg := range tx.GetMsgs() { - if isSSIMsg(msg) { - return true - } - } - - return false -} - -// isNonSSIMsgPresentInTx checks if there is any non-SSI message present in the transaction -func isNonSSIMsgPresentInTx(tx sdk.Tx) bool { - for _, msg := range tx.GetMsgs() { - if !isSSIMsg(msg) { - return true - } - } - - return false -} From 89e82e7c356bd76a779ac6a7186292714999bda0 Mon Sep 17 00:00:00 2001 From: Arnab Ghose Date: Mon, 13 Nov 2023 09:55:06 +0530 Subject: [PATCH 08/11] feat: added support for JSON-LD signing for VC status --- client/docs/swagger-ui/swagger.yaml | 36 +++++- cmd/hid-noded/cmd/debug_extensions.go | 36 +++++- proto/ssi/v1/credential_status.proto | 16 +-- tests/e2e/ssi_tests/generate_doc.py | 12 +- tests/e2e/ssi_tests/utils.py | 3 +- x/ssi/keeper/msg_server.go | 10 +- x/ssi/ld-context/context.go | 160 +++++++++++++++----------- x/ssi/ld-context/normalize.go | 77 ++++++++----- x/ssi/ld-context/types.go | 135 +++++++++++++--------- x/ssi/types/credential_status.pb.go | 146 ++++++++++++++++------- x/ssi/types/ssi_types.go | 9 +- x/ssi/verification/client_spec.go | 54 +++++---- 12 files changed, 439 insertions(+), 255 deletions(-) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 4a60502..0232e63 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -28,6 +28,10 @@ paths: credentialStatusDocument: type: object properties: + context: + type: array + items: + type: string id: type: string revoked: @@ -40,7 +44,7 @@ paths: type: string issuanceDate: type: string - merkleRootHash: + credentialMerkleRootHash: type: string credentialStatusProof: type: object @@ -159,6 +163,10 @@ paths: credentialStatusDocument: type: object properties: + context: + type: array + items: + type: string id: type: string revoked: @@ -171,7 +179,7 @@ paths: type: string issuanceDate: type: string - merkleRootHash: + credentialMerkleRootHash: type: string credentialStatusProof: type: object @@ -24666,6 +24674,10 @@ definitions: hypersign.ssi.v1.CredentialStatusDocument: type: object properties: + context: + type: array + items: + type: string id: type: string revoked: @@ -24678,7 +24690,7 @@ definitions: type: string issuanceDate: type: string - merkleRootHash: + credentialMerkleRootHash: type: string hypersign.ssi.v1.CredentialStatusState: type: object @@ -24686,6 +24698,10 @@ definitions: credentialStatusDocument: type: object properties: + context: + type: array + items: + type: string id: type: string revoked: @@ -24698,7 +24714,7 @@ definitions: type: string issuanceDate: type: string - merkleRootHash: + credentialMerkleRootHash: type: string credentialStatusProof: type: object @@ -25023,6 +25039,10 @@ definitions: credentialStatusDocument: type: object properties: + context: + type: array + items: + type: string id: type: string revoked: @@ -25035,7 +25055,7 @@ definitions: type: string issuanceDate: type: string - merkleRootHash: + credentialMerkleRootHash: type: string credentialStatusProof: type: object @@ -25071,6 +25091,10 @@ definitions: credentialStatusDocument: type: object properties: + context: + type: array + items: + type: string id: type: string revoked: @@ -25083,7 +25107,7 @@ definitions: type: string issuanceDate: type: string - merkleRootHash: + credentialMerkleRootHash: type: string credentialStatusProof: type: object diff --git a/cmd/hid-noded/cmd/debug_extensions.go b/cmd/hid-noded/cmd/debug_extensions.go index fa1f487..88f2d2b 100644 --- a/cmd/hid-noded/cmd/debug_extensions.go +++ b/cmd/hid-noded/cmd/debug_extensions.go @@ -475,13 +475,13 @@ func signSchemaDocCmd() *cobra.Command { func signCredStatusDocCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "cred-status-doc [doc] [private-key] [signing-algo]", + Use: "cred-status-doc [doc] [private-key] [proof-object-without-signature]", Short: "Credential Status Document signature", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { argCredStatusDoc := args[0] argPrivateKey := args[1] - argSigningAlgo := args[2] + argProofObjectWithoutSignature := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -494,33 +494,59 @@ func signCredStatusDocCmd() *cobra.Command { if err != nil { return err } - credStatusDocBytes := credStatusDoc.GetSignBytes() + + // Unmarshal Proof Object + var credStatusDocProof types.DocumentProof + err = clientCtx.Codec.UnmarshalJSON([]byte(argProofObjectWithoutSignature), &credStatusDocProof) + if err != nil { + return err + } // Sign Credential Status Document var signature string - switch argSigningAlgo { + switch credStatusDocProof.Type { case types.Ed25519Signature2020: + credStatusDocBytes, err := ldcontext.Ed25519Signature2020Normalize(&credStatusDoc, &credStatusDocProof) + if err != nil { + return err + } + signature, err = hidnodecli.GetEd25519Signature2020(argPrivateKey, credStatusDocBytes) if err != nil { return err } case types.EcdsaSecp256k1Signature2019: + credStatusDocBytes, err := ldcontext.EcdsaSecp256k1Signature2019Normalize(&credStatusDoc, &credStatusDocProof) + if err != nil { + return err + } + signature, err = hidnodecli.GetEcdsaSecp256k1Signature2019(argPrivateKey, credStatusDocBytes) if err != nil { return err } case types.EcdsaSecp256k1RecoverySignature2020: + credStatusDocBytes, err := ldcontext.EcdsaSecp256k1RecoverySignature2020Normalize(&credStatusDoc, &credStatusDocProof) + if err != nil { + return err + } + signature, err = hidnodecli.GetEcdsaSecp256k1RecoverySignature2020(argPrivateKey, credStatusDocBytes) if err != nil { return err } case types.BbsBlsSignature2020: + credStatusDocBytes, err := ldcontext.BbsBlsSignature2020Normalize(&credStatusDoc, &credStatusDocProof) + if err != nil { + return err + } + signature, err = hidnodecli.GetBbsBlsSignature2020(argPrivateKey, credStatusDocBytes) if err != nil { return err } case types.BabyJubJubSignature2023: - signature, err = hidnodecli.GetBabyJubJubSignature2023(argPrivateKey, credStatusDocBytes) + signature, err = hidnodecli.GetBabyJubJubSignature2023(argPrivateKey, credStatusDoc.GetSignBytes()) if err != nil { return err } diff --git a/proto/ssi/v1/credential_status.proto b/proto/ssi/v1/credential_status.proto index 434aba1..139c5fb 100644 --- a/proto/ssi/v1/credential_status.proto +++ b/proto/ssi/v1/credential_status.proto @@ -2,17 +2,19 @@ syntax = "proto3"; package hypersign.ssi.v1; import "ssi/v1/proof.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/hypersign-protocol/hid-node/x/ssi/types"; message CredentialStatusDocument { - string id = 1; - bool revoked = 2; - bool suspended = 3; - string remarks = 4; - string issuer = 5; - string issuanceDate = 6; - string credentialMerkleRootHash = 7; + repeated string context = 1 [json_name = "@context", (gogoproto.jsontag) = "@context"]; + string id = 2; + bool revoked = 3; + bool suspended = 4; + string remarks = 5; + string issuer = 6; + string issuanceDate = 7; + string credentialMerkleRootHash = 8; } message CredentialStatusState { diff --git a/tests/e2e/ssi_tests/generate_doc.py b/tests/e2e/ssi_tests/generate_doc.py index 5e88eff..fb67d61 100644 --- a/tests/e2e/ssi_tests/generate_doc.py +++ b/tests/e2e/ssi_tests/generate_doc.py @@ -11,6 +11,7 @@ SECP256K1_RECOVERY_CONTEXT = "https://ns.did.ai/suites/secp256k1-2020/v1" SECP256K1_VER_KEY_2019_CONTEXT = "https://ns.did.ai/suites/secp256k1-2019/v1" BBS_CONTEXT = "https://ns.did.ai/suites/bls12381-2020/v1" +CREDENTIAL_STATUS_CONTEXT = "https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialStatus.jsonld" def generate_did_document(key_pair, algo="Ed25519Signature2020", bech32prefix="hid", is_uuid=False): base_document = { @@ -151,6 +152,7 @@ def generate_schema_document(key_pair, schema_author, vm, signature=None, algo=" def generate_cred_status_document(key_pair, cred_author, vm, signature=None, algo="Ed25519Signature2020", updated_credstatus_doc=None): base_cred_status_doc = { + "@context": [CREDENTIAL_STATUS_CONTEXT], "id": "", "issuer": "did:hid:devnet:z3861habXtUFLNuu6J7m5p8VPsoBMduYbYeUxfx9CnWZR", "issuanceDate": "2022-08-16T09:37:12Z", @@ -160,17 +162,21 @@ def generate_cred_status_document(key_pair, cred_author, vm, signature=None, alg proof_type = "" if algo == "Ed25519Signature2020": proof_type = "Ed25519Signature2020" + base_cred_status_doc["@context"].append(ED25519_CONTEXT) elif algo == "EcdsaSecp256k1Signature2019": proof_type = "EcdsaSecp256k1Signature2019" + base_cred_status_doc["@context"].append(SECP256K1_VER_KEY_2019_CONTEXT) elif algo == "EcdsaSecp256k1RecoverySignature2020": proof_type = "EcdsaSecp256k1RecoverySignature2020" + base_cred_status_doc["@context"].append(SECP256K1_RECOVERY_CONTEXT) elif algo == "BbsBlsSignature2020": proof_type = "BbsBlsSignature2020" + base_cred_status_doc["@context"].append(BBS_CONTEXT) elif algo == "BabyJubJubSignature2023": proof_type = "BabyJubJubSignature2023" else: raise Exception("Invalid signing algo: " + algo) - + base_cred_status_proof = { "type": proof_type, "created": "2022-08-16T09:37:12Z", @@ -187,11 +193,11 @@ def generate_cred_status_document(key_pair, cred_author, vm, signature=None, alg # Form Signature if not updated_credstatus_doc: if not signature: - signature = get_document_signature(base_cred_status_doc, "cred-status", key_pair, algo) + signature = get_document_signature(base_cred_status_doc, "cred-status", key_pair, algo, proofObj=base_cred_status_proof) base_cred_status_proof["proofValue"] = signature return base_cred_status_doc, base_cred_status_proof else: if not signature: - signature = get_document_signature(updated_credstatus_doc, "cred-status", key_pair, algo) + signature = get_document_signature(updated_credstatus_doc, "cred-status", key_pair, algo, proofObj=base_cred_status_proof) base_cred_status_proof["proofValue"] = signature return updated_credstatus_doc, base_cred_status_proof \ No newline at end of file diff --git a/tests/e2e/ssi_tests/utils.py b/tests/e2e/ssi_tests/utils.py index 2089502..bf6c590 100644 --- a/tests/e2e/ssi_tests/utils.py +++ b/tests/e2e/ssi_tests/utils.py @@ -123,8 +123,7 @@ def get_document_signature(doc: dict, doc_type: str, key_pair: dict, algo: str = else: raise Exception("Invalid value for doc_type param: " + doc_type) - if doc_type == "did": - print() + if doc_type == "did" or doc_type == "cred-status": cmd_string = f"hid-noded debug sign-ssi-doc {doc_cmd} '{json.dumps(doc)}' {private_key} '{json.dumps(proofObj)}'" else: cmd_string = f"hid-noded debug sign-ssi-doc {doc_cmd} '{json.dumps(doc)}' {private_key} {algo}" diff --git a/x/ssi/keeper/msg_server.go b/x/ssi/keeper/msg_server.go index 26f89bc..fbb022c 100644 --- a/x/ssi/keeper/msg_server.go +++ b/x/ssi/keeper/msg_server.go @@ -185,7 +185,7 @@ func (k msgServer) getControllerVmFromState(ctx sdk.Context, verificationMethodI } // VerifyDocumentProof verifies the proof of a SSI Document -func (k msgServer) VerifyDocumentProof(ctx sdk.Context, ssiMsg types.SsiMsg, inputDocProof types.SSIProofInterface) error { +func (k msgServer) VerifyDocumentProof(ctx sdk.Context, ssiMsg types.SsiMsg, inputDocProof *types.DocumentProof) error { // Get DID Document from State docProofVmId := inputDocProof.GetVerificationMethod() didId, _ := types.SplitDidUrl(docProofVmId) @@ -225,13 +225,7 @@ func (k msgServer) VerifyDocumentProof(ctx sdk.Context, ssiMsg types.SsiMsg, inp ) } - // Verify signature - documentProof := &types.DocumentProof{ - VerificationMethod: inputDocProof.GetVerificationMethod(), - ProofValue: inputDocProof.GetProofValue(), - ClientSpecType: inputDocProof.GetClientSpecType(), - } - err = verification.VerifyDocumentProofSignature(ssiMsg, docVm, documentProof) + err = verification.VerifyDocumentProofSignature(ssiMsg, docVm, inputDocProof) if err != nil { return err } diff --git a/x/ssi/ld-context/context.go b/x/ssi/ld-context/context.go index 6f2aaea..97eb1cb 100644 --- a/x/ssi/ld-context/context.go +++ b/x/ssi/ld-context/context.go @@ -7,6 +7,7 @@ const Secp256k1Recovery2020Context string = "https://ns.did.ai/suites/secp256k1- const BbsSignature2020Context string = "https://ns.did.ai/suites/bls12381-2020/v1" const Secp256k12019Context string = "https://ns.did.ai/suites/secp256k1-2019/v1" const X25519KeyAgreementKeyEIP5630Context string = "https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/X25519KeyAgreementKeyEIP5630.jsonld" +const CredentialStatusContext string = "https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialStatus.jsonld" // As hid-node is not supposed to perform any GET request, the complete Context body of their // respective Context urls has been maintained below. @@ -158,8 +159,8 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ }, }, X25519KeyAgreement2020Context: { - "id": "@id", - "type": "@type", + "id": "@id", + "type": "@type", "@protected": true, "X25519KeyAgreementKey2020": map[string]interface{}{ "@id": "https://w3id.org/security#X25519KeyAgreementKey2020", @@ -183,8 +184,8 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ }, }, Secp256k1Recovery2020Context: { - "id": "@id", - "type": "@type", + "id": "@id", + "type": "@type", "@protected": true, "EcdsaSecp256k1VerificationKey2020": map[string]interface{}{ "@id": "https://w3id.org/security#EcdsaSecp256k1VerificationKey2020", @@ -224,35 +225,35 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ }, "nonce": "https://w3id.org/security#nonce", "proofPurpose": map[string]interface{}{ - "@id": "https://w3id.org/security#proofPurpose", - "@type": "@vocab", + "@id": "https://w3id.org/security#proofPurpose", + "@type": "@vocab", "@context": map[string]interface{}{ "@protected": true, "id": "@id", "type": "@type", "assertionMethod": map[string]interface{}{ - "@id": "https://w3id.org/security#assertionMethod", - "@type": "@id", + "@id": "https://w3id.org/security#assertionMethod", + "@type": "@id", "@container": "@set", }, "authentication": map[string]interface{}{ - "@id": "https://w3id.org/security#authenticationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#authenticationMethod", + "@type": "@id", "@container": "@set", }, "capabilityInvocation": map[string]interface{}{ - "@id": "https://w3id.org/security#capabilityInvocationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#capabilityInvocationMethod", + "@type": "@id", "@container": "@set", }, "capabilityDelegation": map[string]interface{}{ - "@id": "https://w3id.org/security#capabilityDelegationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#capabilityDelegationMethod", + "@type": "@id", "@container": "@set", }, "keyAgreement": map[string]interface{}{ - "@id": "https://w3id.org/security#keyAgreementMethod", - "@type": "@id", + "@id": "https://w3id.org/security#keyAgreementMethod", + "@type": "@id", "@container": "@set", }, }, @@ -320,35 +321,35 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ }, "nonce": "https://w3id.org/security#nonce", "proofPurpose": map[string]interface{}{ - "@id": "https://w3id.org/security#proofPurpose", - "@type": "@vocab", + "@id": "https://w3id.org/security#proofPurpose", + "@type": "@vocab", "@context": map[string]interface{}{ "@protected": true, "id": "@id", "type": "@type", "assertionMethod": map[string]interface{}{ - "@id": "https://w3id.org/security#assertionMethod", - "@type": "@id", + "@id": "https://w3id.org/security#assertionMethod", + "@type": "@id", "@container": "@set", }, "authentication": map[string]interface{}{ - "@id": "https://w3id.org/security#authenticationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#authenticationMethod", + "@type": "@id", "@container": "@set", }, "capabilityInvocation": map[string]interface{}{ - "@id": "https://w3id.org/security#capabilityInvocationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#capabilityInvocationMethod", + "@type": "@id", "@container": "@set", }, "capabilityDelegation": map[string]interface{}{ - "@id": "https://w3id.org/security#capabilityDelegationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#capabilityDelegationMethod", + "@type": "@id", "@container": "@set", }, "keyAgreement": map[string]interface{}{ - "@id": "https://w3id.org/security#keyAgreementMethod", - "@type": "@id", + "@id": "https://w3id.org/security#keyAgreementMethod", + "@type": "@id", "@container": "@set", }, }, @@ -368,8 +369,8 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ "id": "@id", "type": "@type", "proof": map[string]interface{}{ - "@id": "https://w3id.org/security#proof", - "@type": "@id", + "@id": "https://w3id.org/security#proof", + "@type": "@id", "@container": "@graph", }, "BbsBlsSignature2020": map[string]interface{}{ @@ -384,25 +385,25 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ "@id": "http://purl.org/dc/terms/created", "@type": "http://www.w3.org/2001/XMLSchema#dateTime", }, - "domain": "https://w3id.org/security#domain", + "domain": "https://w3id.org/security#domain", "proofValue": "https://w3id.org/security#proofValue", - "nonce": "https://w3id.org/security#nonce", + "nonce": "https://w3id.org/security#nonce", "proofPurpose": map[string]interface{}{ - "@id": "https://w3id.org/security#proofPurpose", - "@type": "@vocab", + "@id": "https://w3id.org/security#proofPurpose", + "@type": "@vocab", "@context": map[string]interface{}{ "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "assertionMethod": map[string]interface{}{ - "@id": "https://w3id.org/security#assertionMethod", - "@type": "@id", + "@id": "https://w3id.org/security#assertionMethod", + "@type": "@id", "@container": "@set", }, "authentication": map[string]interface{}{ - "@id": "https://w3id.org/security#authenticationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#authenticationMethod", + "@type": "@id", "@container": "@set", }, }, @@ -428,8 +429,8 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ "domain": "https://w3id.org/security#domain", "nonce": "https://w3id.org/security#nonce", "proofPurpose": map[string]interface{}{ - "@id": "https://w3id.org/security#proofPurpose", - "@type": "@vocab", + "@id": "https://w3id.org/security#proofPurpose", + "@type": "@vocab", "@context": map[string]interface{}{ "@version": 1.1, "@protected": true, @@ -437,13 +438,13 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ "type": "@type", "sec": "https://w3id.org/security#", "assertionMethod": map[string]interface{}{ - "@id": "https://w3id.org/security#assertionMethod", - "@type": "@id", + "@id": "https://w3id.org/security#assertionMethod", + "@type": "@id", "@container": "@set", }, "authentication": map[string]interface{}{ - "@id": "https://w3id.org/security#authenticationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#authenticationMethod", + "@type": "@id", "@container": "@set", }, }, @@ -511,12 +512,12 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ }, }, Secp256k12019Context: { - "id": "@id", - "type": "@type", + "id": "@id", + "type": "@type", "@protected": true, "proof": map[string]interface{}{ - "@id": "https://w3id.org/security#proof", - "@type": "@id", + "@id": "https://w3id.org/security#proof", + "@type": "@id", "@container": "@graph", }, "EcdsaSecp256k1VerificationKey2019": map[string]interface{}{ @@ -567,35 +568,35 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ }, "nonce": "https://w3id.org/security#nonce", "proofPurpose": map[string]interface{}{ - "@id": "https://w3id.org/security#proofPurpose", - "@type": "@vocab", + "@id": "https://w3id.org/security#proofPurpose", + "@type": "@vocab", "@context": map[string]interface{}{ "@protected": true, "id": "@id", "type": "@type", "assertionMethod": map[string]interface{}{ - "@id": "https://w3id.org/security#assertionMethod", - "@type": "@id", + "@id": "https://w3id.org/security#assertionMethod", + "@type": "@id", "@container": "@set", }, "authentication": map[string]interface{}{ - "@id": "https://w3id.org/security#authenticationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#authenticationMethod", + "@type": "@id", "@container": "@set", }, "capabilityInvocation": map[string]interface{}{ - "@id": "https://w3id.org/security#capabilityInvocationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#capabilityInvocationMethod", + "@type": "@id", "@container": "@set", }, "capabilityDelegation": map[string]interface{}{ - "@id": "https://w3id.org/security#capabilityDelegationMethod", - "@type": "@id", + "@id": "https://w3id.org/security#capabilityDelegationMethod", + "@type": "@id", "@container": "@set", }, "keyAgreement": map[string]interface{}{ - "@id": "https://w3id.org/security#keyAgreementMethod", - "@type": "@id", + "@id": "https://w3id.org/security#keyAgreementMethod", + "@type": "@id", "@container": "@set", }, }, @@ -611,12 +612,12 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ }, }, X25519KeyAgreementKeyEIP5630Context: { - "id": "@id", - "type": "@type", + "id": "@id", + "type": "@type", "@protected": true, "proof": map[string]interface{}{ - "@id": "https://w3id.org/security#proof", - "@type": "@id", + "@id": "https://w3id.org/security#proof", + "@type": "@id", "@container": "@graph", }, "X25519KeyAgreementKeyEIP5630": map[string]interface{}{ @@ -644,4 +645,35 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ }, }, }, + CredentialStatusContext: { + "@protected": true, + "@version": 1.1, + "hypersign-vocab": "urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "id": "@id", + "revoked": map[string]interface{}{ + "@id": "hypersign-vocab:revoked", + "@type": "xsd:boolean", + }, + "suspended": map[string]interface{}{ + "@id": "hypersign-vocab:suspended", + "@type": "xsd:boolean", + }, + "remarks": map[string]interface{}{ + "@id": "hypersign-vocab:remarks", + "@type": "xsd:string", + }, + "issuer": map[string]interface{}{ + "@id": "hypersign-vocab:issuer", + "@type": "xsd:string", + }, + "issuanceDate": map[string]interface{}{ + "@id": "hypersign-vocab:issuanceDate", + "@type": "xsd:dateTime", + }, + "credentialMerkleRootHash": map[string]interface{}{ + "@id": "hypersign-vocab:credentialMerkleRootHash", + "@type": "xsd:string", + }, + }, } diff --git a/x/ssi/ld-context/normalize.go b/x/ssi/ld-context/normalize.go index 636cbc7..e938156 100644 --- a/x/ssi/ld-context/normalize.go +++ b/x/ssi/ld-context/normalize.go @@ -8,49 +8,70 @@ import ( // NormalizeByVerificationMethodType normalizes DID Document based on the input Verification // Method type -func NormalizeByVerificationMethodType(didDoc *types.DidDocument, vmType string, didDocumentProof *types.DocumentProof) ([]byte, error) { +func NormalizeByVerificationMethodType(ssiMsg types.SsiMsg, vmType string, didDocumentProof *types.DocumentProof) ([]byte, error) { switch vmType { case types.Ed25519VerificationKey2020: - didDocBytes, err := Ed25519Signature2020Normalize(didDoc, didDocumentProof) + msgBytes, err := Ed25519Signature2020Normalize(ssiMsg, didDocumentProof) if err != nil { return nil, err } - return didDocBytes, nil + return msgBytes, nil case types.EcdsaSecp256k1RecoveryMethod2020: - didDocBytes, err := EcdsaSecp256k1RecoverySignature2020Normalize(didDoc, didDocumentProof) + msgBytes, err := EcdsaSecp256k1RecoverySignature2020Normalize(ssiMsg, didDocumentProof) if err != nil { return nil, err } - return didDocBytes, nil + return msgBytes, nil case types.Bls12381G2Key2020: - didDocBytes, err := BbsBlsSignature2020Normalize(didDoc, didDocumentProof) + msgBytes, err := BbsBlsSignature2020Normalize(ssiMsg, didDocumentProof) if err != nil { return nil, err } - return didDocBytes, nil + return msgBytes, nil case types.EcdsaSecp256k1VerificationKey2019: - didDocBytes, err := EcdsaSecp256k1Signature2019Normalize(didDoc, didDocumentProof) + msgBytes, err := EcdsaSecp256k1Signature2019Normalize(ssiMsg, didDocumentProof) if err != nil { return nil, err } - return didDocBytes, nil + return msgBytes, nil default: - return didDoc.GetSignBytes(), nil + return ssiMsg.GetSignBytes(), nil } } -// normalizeDocumentWithProof normalizes the DidDocument along with Document Proof +// normalizeDocumentWithProof normalizes the SSI document along with Document Proof // Read more: https://w3c.github.io/vc-di-eddsa/#representation-ed25519signature2020 -func normalizeDocumentWithProof(didDoc *types.DidDocument, didDocProof *types.DocumentProof) ([]byte, error) { - jsonLdDid := NewJsonLdDid(didDoc) - canonizedDidDocument, err := jsonLdDid.NormalizeWithURDNA2015() - if err != nil { - return nil, err +func normalizeDocumentWithProof(msg types.SsiMsg, docProof *types.DocumentProof) ([]byte, error) { + // Normalize Document + var canonizedDocument string + var context []string + + switch doc := msg.(type) { + case *types.DidDocument: + var err error + jsonLdDidDocument := NewJsonLdDidDocument(doc) + canonizedDocument, err = normalizeWithURDNA2015(jsonLdDidDocument) + if err != nil { + return nil, err + } + context = doc.Context + case *types.CredentialStatusDocument: + var err error + jsonLdCredentialStatus := NewJsonLdCredentialStatus(doc) + canonizedDocument, err = normalizeWithURDNA2015(jsonLdCredentialStatus) + if err != nil { + return nil, err + } + context = doc.Context + case *types.CredentialSchemaDocument: + return doc.GetSignBytes(), nil } - canonizedDidDocumentHash := sha256.Sum256([]byte(canonizedDidDocument)) - jsonLdDocumentProof := NewJsonLdDocumentProof(didDocProof, didDoc.Context) - canonizedDocumentProof, err := jsonLdDocumentProof.NormalizeWithURDNA2015() + canonizedDocumentHash := sha256.Sum256([]byte(canonizedDocument)) + + // Normalize Document Proof + jsonLdDocumentProof := NewJsonLdDocumentProof(docProof, context) + canonizedDocumentProof, err := normalizeWithURDNA2015(jsonLdDocumentProof) if err != nil { return nil, err } @@ -59,34 +80,34 @@ func normalizeDocumentWithProof(didDoc *types.DidDocument, didDocProof *types.Do var finalNormalizedHash []byte = []byte{} // NOTE: The order is: ProofHash + DocumentHash finalNormalizedHash = append(finalNormalizedHash, canonizedDocumentProofHash[:]...) - finalNormalizedHash = append(finalNormalizedHash, canonizedDidDocumentHash[:]...) + finalNormalizedHash = append(finalNormalizedHash, canonizedDocumentHash[:]...) return finalNormalizedHash, nil } // Ed25519Signature2020Normalize normalizes DID Document in accordance with // EdDSA Cryptosuite v2020 (https://www.w3.org/community/reports/credentials/CG-FINAL-di-eddsa-2020-20220724/) -func Ed25519Signature2020Normalize(didDoc *types.DidDocument, didDocProof *types.DocumentProof) ([]byte, error) { - return normalizeDocumentWithProof(didDoc, didDocProof) +func Ed25519Signature2020Normalize(ssiMsg types.SsiMsg, didDocProof *types.DocumentProof) ([]byte, error) { + return normalizeDocumentWithProof(ssiMsg, didDocProof) } // EcdsaSecp256k1RecoverySignature2020Normalize normalizes DID Document in accordance with // the Identity Foundation draft on EcdsaSecp256k1RecoverySignature2020 // Read more: https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/ -func EcdsaSecp256k1RecoverySignature2020Normalize(didDoc *types.DidDocument, didDocProof *types.DocumentProof) ([]byte, error) { - return normalizeDocumentWithProof(didDoc, didDocProof) +func EcdsaSecp256k1RecoverySignature2020Normalize(ssiMsg types.SsiMsg, didDocProof *types.DocumentProof) ([]byte, error) { + return normalizeDocumentWithProof(ssiMsg, didDocProof) } // BbsBlsSignature2020Normalize normalizes the DID Document for the // BbsBlsSignature2020 signature type // Read more: https://identity.foundation/bbs-signature/draft-irtf-cfrg-bbs-signatures.html -func BbsBlsSignature2020Normalize(didDoc *types.DidDocument, didDocProof *types.DocumentProof) ([]byte, error) { - return normalizeDocumentWithProof(didDoc, didDocProof) +func BbsBlsSignature2020Normalize(ssiMsg types.SsiMsg, didDocProof *types.DocumentProof) ([]byte, error) { + return normalizeDocumentWithProof(ssiMsg, didDocProof) } // EcdsaSecp256k1Signature2019Normalize normalizes the DID Document for the // EcdsaSecp256k1Signature2019 signature type // Read more: https://w3c-ccg.github.io/lds-ecdsa-secp256k1-2019/ -func EcdsaSecp256k1Signature2019Normalize(didDoc *types.DidDocument, didDocProof *types.DocumentProof) ([]byte, error) { - return normalizeDocumentWithProof(didDoc, didDocProof) +func EcdsaSecp256k1Signature2019Normalize(ssiMsg types.SsiMsg, didDocProof *types.DocumentProof) ([]byte, error) { + return normalizeDocumentWithProof(ssiMsg, didDocProof) } diff --git a/x/ssi/ld-context/types.go b/x/ssi/ld-context/types.go index 4a75944..3dbcac7 100644 --- a/x/ssi/ld-context/types.go +++ b/x/ssi/ld-context/types.go @@ -10,10 +10,14 @@ import ( type contextObject map[string]interface{} +type JsonLdDocument interface { + GetContext() []contextObject +} + // It is a similar to `Did` struct, with the exception that the `context` attribute is of type // `contextObject` instead of `[]string`, which is meant for accomodating Context JSON body // having arbritrary attributes. It should be used for performing Canonization. -type JsonLdDid struct { +type JsonLdDidDocument struct { Context []contextObject `json:"@context,omitempty"` Id string `json:"id,omitempty"` Controller []string `json:"controller,omitempty"` @@ -27,13 +31,17 @@ type JsonLdDid struct { Service []*types.Service `json:"service,omitempty"` } -// NewJsonLdDid returns a new JsonLdDid struct from input Did -func NewJsonLdDid(didDoc *types.DidDocument) *JsonLdDid { +func (doc *JsonLdDidDocument) GetContext() []contextObject { + return doc.Context +} + +// NewJsonLdDidDocument returns a new JsonLdDid struct from input Did +func NewJsonLdDidDocument(didDoc *types.DidDocument) *JsonLdDidDocument { if len(didDoc.Context) == 0 { panic("atleast one context url must be provided for DID Document for Canonization") } - var jsonLdDoc *JsonLdDid = &JsonLdDid{} + var jsonLdDoc *JsonLdDidDocument = &JsonLdDidDocument{} for _, url := range didDoc.Context { contextObj, ok := ContextUrlMap[url] @@ -57,44 +65,52 @@ func NewJsonLdDid(didDoc *types.DidDocument) *JsonLdDid { return jsonLdDoc } -// Convert JsonLdDid to interface -func jsonLdDidToInterface(jsonLd *JsonLdDid) interface{} { - var intf interface{} +// It is a similar to `Did` struct, with the exception that the `context` attribute is of type +// `contextObject` instead of `[]string`, which is meant for accomodating Context JSON body +// having arbritrary attributes. It should be used for performing Canonization. +type JsonLdCredentialStatus struct { + Context []contextObject `json:"@context,omitempty"` + Id string `json:"id,omitempty"` + Revoked bool `json:"revoked,omitempty"` + Suspended bool `json:"suspended,omitempty"` + Remarks string `json:"remarks,omitempty"` + Issuer string `json:"issuer,omitempty"` + IssuanceDate string `json:"issuanceDate,omitempty"` + CredentialMerkleRootHash string `json:"credentialMerkleRootHash,omitempty"` +} - jsonLdBytes, err := json.Marshal(jsonLd) - if err != nil { - panic(err) - } +func (doc *JsonLdCredentialStatus) GetContext() []contextObject { + return doc.Context +} - err = json.Unmarshal(jsonLdBytes, &intf) - if err != nil { - panic(err) +// NewJsonLdCredentialStatus returns a new JsonLdCredentialStatus struct from input Credential Status +func NewJsonLdCredentialStatus(credStatusDoc *types.CredentialStatusDocument) *JsonLdCredentialStatus { + if len(credStatusDoc.Context) == 0 { + panic("atleast one context url must be provided in the Credential Status Document for Canonization") } - return intf -} + var jsonLdCredentialStatus *JsonLdCredentialStatus = &JsonLdCredentialStatus{} -// NormalizeWithURDNA2015 performs RDF Canonization upon JsonLdDid using URDNA2015 -// algorithm and returns the canonized document in string -func (jsonLd *JsonLdDid) NormalizeWithURDNA2015() (string, error) { - proc := ld.NewJsonLdProcessor() - options := ld.NewJsonLdOptions("") - options.Algorithm = ld.AlgorithmURDNA2015 - options.Format = "application/n-quads" - - normalisedJsonLdDid, err := proc.Normalize(jsonLdDidToInterface(jsonLd), options) - if err != nil { - return "", fmt.Errorf("unable to Normalize DID Document: %v", err.Error()) + for _, url := range credStatusDoc.Context { + contextObj, ok := ContextUrlMap[url] + if !ok { + panic(fmt.Sprintf("invalid or unsupported context url: %v", url)) + } + jsonLdCredentialStatus.Context = append(jsonLdCredentialStatus.Context, contextObj) } - canonizedDocString := normalisedJsonLdDid.(string) - if canonizedDocString == "" { - return "", fmt.Errorf("normalization yield empty RDF string for did document: %v", jsonLd.Id) - } - return canonizedDocString, nil + jsonLdCredentialStatus.Id = credStatusDoc.Id + jsonLdCredentialStatus.Revoked = credStatusDoc.Revoked + jsonLdCredentialStatus.Remarks = credStatusDoc.Remarks + jsonLdCredentialStatus.Suspended = credStatusDoc.Suspended + jsonLdCredentialStatus.Issuer = credStatusDoc.Issuer + jsonLdCredentialStatus.IssuanceDate = credStatusDoc.IssuanceDate + jsonLdCredentialStatus.CredentialMerkleRootHash = credStatusDoc.CredentialMerkleRootHash + + return jsonLdCredentialStatus } -// ------------------------- +// Document Proof type JsonLdDocumentProof struct { Context []contextObject `json:"@context,omitempty"` @@ -104,7 +120,11 @@ type JsonLdDocumentProof struct { ProofPurpose string `json:"proofPurpose,omitempty"` } -func NewJsonLdDocumentProof(didDocProof *types.DocumentProof, didContexts []string) *JsonLdDocumentProof { +func (doc *JsonLdDocumentProof) GetContext() []contextObject { + return doc.Context +} + +func NewJsonLdDocumentProof(didDocProof *types.DocumentProof, didContexts []string) *JsonLdDocumentProof { if len(didContexts) == 0 { panic("atleast one context url must be provided for DID Document for Canonization") } @@ -127,8 +147,33 @@ func NewJsonLdDocumentProof(didDocProof *types.DocumentProof, didContexts []stri return jsonLdDoc } +// normalizeWithURDNA2015 performs RDF Canonization upon JsonLdDid using URDNA2015 +// algorithm and returns the canonized document in string +func normalizeWithURDNA2015(jsonLdDocument JsonLdDocument) (string, error) { + return normalize(ld.AlgorithmURDNA2015, jsonLdDocument) +} + +func normalize(algorithm string, jsonLdDocument JsonLdDocument) (string, error) { + proc := ld.NewJsonLdProcessor() + options := ld.NewJsonLdOptions("") + options.Algorithm = algorithm // ld.AlgorithmURDNA2015 + options.Format = "application/n-quads" + + normalisedJsonLd, err := proc.Normalize(jsonLdDocToInterface(jsonLdDocument), options) + if err != nil { + return "", fmt.Errorf("unable to Normalize DID Document: %v", err.Error()) + } + + canonizedDocString := normalisedJsonLd.(string) + if canonizedDocString == "" { + return "", fmt.Errorf("normalization of JSON-LD document yielded empty RDF string") + } + + return canonizedDocString, nil +} + // Convert JsonLdDid to interface -func jsonLdDocumentProofToInterface(jsonLd *JsonLdDocumentProof) interface{} { +func jsonLdDocToInterface(jsonLd any) interface{} { var intf interface{} jsonLdBytes, err := json.Marshal(jsonLd) @@ -143,23 +188,3 @@ func jsonLdDocumentProofToInterface(jsonLd *JsonLdDocumentProof) interface{} { return intf } - -// NormalizeWithURDNA2015 performs RDF Canonization upon JsonLdDid using URDNA2015 -// algorithm and returns the canonized document in string -func (jsonLd *JsonLdDocumentProof) NormalizeWithURDNA2015() (string, error) { - proc := ld.NewJsonLdProcessor() - options := ld.NewJsonLdOptions("") - options.Algorithm = ld.AlgorithmURDNA2015 - options.Format = "application/n-quads" - - normalisedJsonLdDocumentProof, err := proc.Normalize(jsonLdDocumentProofToInterface(jsonLd), options) - if err != nil { - return "", fmt.Errorf("unable to Normalize Document Proof: %v", err.Error()) - } - - canonizedDocString := normalisedJsonLdDocumentProof.(string) - if canonizedDocString == "" { - return "", fmt.Errorf("normalization yield empty RDF string for proof") - } - return canonizedDocString, nil -} diff --git a/x/ssi/types/credential_status.pb.go b/x/ssi/types/credential_status.pb.go index b5fba7d..be8345c 100644 --- a/x/ssi/types/credential_status.pb.go +++ b/x/ssi/types/credential_status.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -23,13 +24,14 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type CredentialStatusDocument struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Revoked bool `protobuf:"varint,2,opt,name=revoked,proto3" json:"revoked,omitempty"` - Suspended bool `protobuf:"varint,3,opt,name=suspended,proto3" json:"suspended,omitempty"` - Remarks string `protobuf:"bytes,4,opt,name=remarks,proto3" json:"remarks,omitempty"` - Issuer string `protobuf:"bytes,5,opt,name=issuer,proto3" json:"issuer,omitempty"` - IssuanceDate string `protobuf:"bytes,6,opt,name=issuanceDate,proto3" json:"issuanceDate,omitempty"` - CredentialMerkleRootHash string `protobuf:"bytes,7,opt,name=credentialMerkleRootHash,proto3" json:"credentialMerkleRootHash,omitempty"` + Context []string `protobuf:"bytes,1,rep,name=context,json=@context,proto3" json:"@context"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + Revoked bool `protobuf:"varint,3,opt,name=revoked,proto3" json:"revoked,omitempty"` + Suspended bool `protobuf:"varint,4,opt,name=suspended,proto3" json:"suspended,omitempty"` + Remarks string `protobuf:"bytes,5,opt,name=remarks,proto3" json:"remarks,omitempty"` + Issuer string `protobuf:"bytes,6,opt,name=issuer,proto3" json:"issuer,omitempty"` + IssuanceDate string `protobuf:"bytes,7,opt,name=issuanceDate,proto3" json:"issuanceDate,omitempty"` + CredentialMerkleRootHash string `protobuf:"bytes,8,opt,name=credentialMerkleRootHash,proto3" json:"credentialMerkleRootHash,omitempty"` } func (m *CredentialStatusDocument) Reset() { *m = CredentialStatusDocument{} } @@ -65,6 +67,13 @@ func (m *CredentialStatusDocument) XXX_DiscardUnknown() { var xxx_messageInfo_CredentialStatusDocument proto.InternalMessageInfo +func (m *CredentialStatusDocument) GetContext() []string { + if m != nil { + return m.Context + } + return nil +} + func (m *CredentialStatusDocument) GetId() string { if m != nil { return m.Id @@ -174,30 +183,32 @@ func init() { func init() { proto.RegisterFile("ssi/v1/credential_status.proto", fileDescriptor_9807097035021c62) } var fileDescriptor_9807097035021c62 = []byte{ - // 353 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xcd, 0x4e, 0x3a, 0x31, - 0x10, 0xa7, 0xfc, 0xff, 0x82, 0x14, 0x63, 0x4c, 0x13, 0x4c, 0x63, 0xcc, 0x4a, 0x38, 0x11, 0x13, - 0x76, 0x03, 0xde, 0x3c, 0x2a, 0x07, 0x0f, 0x9a, 0x98, 0x35, 0x5e, 0xbc, 0x98, 0x65, 0x3b, 0xb0, - 0x0d, 0xb0, 0xdd, 0x74, 0xba, 0x44, 0xde, 0xc2, 0xc7, 0xf2, 0xc8, 0xc9, 0x78, 0x34, 0xf0, 0x0a, - 0x3e, 0x80, 0xd9, 0xf2, 0x25, 0x28, 0x97, 0xa6, 0x33, 0xbf, 0x8f, 0x66, 0x7e, 0x1d, 0xea, 0x20, - 0x4a, 0x6f, 0xd4, 0xf4, 0x42, 0x0d, 0x02, 0x62, 0x23, 0x83, 0xc1, 0x33, 0x9a, 0xc0, 0xa4, 0xe8, - 0x26, 0x5a, 0x19, 0xc5, 0x8e, 0xa2, 0x71, 0x02, 0x1a, 0x65, 0x2f, 0x76, 0x11, 0xa5, 0x3b, 0x6a, - 0x9e, 0xb0, 0x85, 0x22, 0xd1, 0x4a, 0x75, 0xe7, 0xac, 0xda, 0x17, 0xa1, 0xfc, 0x7a, 0xe5, 0xf0, - 0x60, 0x0d, 0xda, 0x2a, 0x4c, 0x87, 0x10, 0x1b, 0x76, 0x48, 0xf3, 0x52, 0x70, 0x52, 0x25, 0xf5, - 0x92, 0x9f, 0x97, 0x82, 0x71, 0x5a, 0xd4, 0x30, 0x52, 0x7d, 0x10, 0x3c, 0x5f, 0x25, 0xf5, 0x7d, - 0x7f, 0x59, 0xb2, 0x53, 0x5a, 0xc2, 0x14, 0x13, 0x88, 0x05, 0x08, 0xfe, 0xcf, 0x62, 0xeb, 0xc6, - 0x5c, 0x37, 0x0c, 0x74, 0x1f, 0xf9, 0x7f, 0x6b, 0xb6, 0x2c, 0xd9, 0x31, 0x2d, 0x48, 0xc4, 0x14, - 0x34, 0xdf, 0xb3, 0xc0, 0xa2, 0x62, 0x35, 0x7a, 0x90, 0xdd, 0x82, 0x38, 0x84, 0x76, 0x60, 0x80, - 0x17, 0x2c, 0xba, 0xd1, 0x63, 0x97, 0x94, 0xaf, 0x67, 0xbf, 0x03, 0xdd, 0x1f, 0x80, 0xaf, 0x94, - 0xb9, 0x09, 0x30, 0xe2, 0x45, 0xcb, 0xdf, 0x89, 0xd7, 0xde, 0x09, 0xad, 0x6c, 0x8f, 0x9d, 0x9d, - 0xc0, 0xba, 0x3f, 0x5d, 0x37, 0xf3, 0xb0, 0x49, 0x94, 0x5b, 0xe7, 0xee, 0x76, 0xb2, 0xee, 0xae, - 0x04, 0xfd, 0x9d, 0x5e, 0xec, 0x91, 0x56, 0xb6, 0xb1, 0xfb, 0xec, 0x5f, 0x6c, 0xb2, 0xe5, 0xd6, - 0xd9, 0xef, 0x47, 0x96, 0x52, 0x4b, 0xf3, 0xff, 0x56, 0x5f, 0xdd, 0xbe, 0x4d, 0x1d, 0x32, 0x99, - 0x3a, 0xe4, 0x73, 0xea, 0x90, 0xd7, 0x99, 0x93, 0x9b, 0xcc, 0x9c, 0xdc, 0xc7, 0xcc, 0xc9, 0x3d, - 0xb5, 0x7a, 0xd2, 0x44, 0x69, 0xc7, 0x0d, 0xd5, 0xd0, 0x5b, 0x79, 0x37, 0xec, 0x16, 0x84, 0x6a, - 0xe0, 0x45, 0x52, 0x34, 0x62, 0x25, 0xc0, 0x7b, 0xf1, 0xb2, 0x35, 0x31, 0xe3, 0x04, 0xb0, 0x53, - 0xb0, 0xf0, 0xc5, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x00, 0x93, 0x35, 0x6c, 0x02, 0x00, - 0x00, + // 396 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xcd, 0xaa, 0xda, 0x40, + 0x18, 0x75, 0x62, 0xeb, 0xcf, 0x28, 0xa5, 0x0c, 0xb5, 0x0c, 0x52, 0x62, 0x70, 0xd3, 0x50, 0x30, + 0x41, 0xbb, 0xeb, 0xaa, 0x58, 0x17, 0x5d, 0xb4, 0x50, 0x52, 0xba, 0xe9, 0xa6, 0xc4, 0xcc, 0x67, + 0x32, 0xa8, 0x99, 0x30, 0x33, 0x11, 0x7d, 0x8b, 0xbe, 0x40, 0xdf, 0xa7, 0x4b, 0x57, 0xa5, 0xab, + 0xcb, 0x45, 0x77, 0xf7, 0x29, 0x2e, 0x19, 0xff, 0xae, 0xde, 0xeb, 0x26, 0x9c, 0xef, 0x9c, 0xef, + 0x9c, 0xc0, 0x99, 0x0f, 0xdb, 0x4a, 0x71, 0x7f, 0xd1, 0xf7, 0x23, 0x09, 0x0c, 0x52, 0xcd, 0xc3, + 0xd9, 0x2f, 0xa5, 0x43, 0x9d, 0x2b, 0x2f, 0x93, 0x42, 0x0b, 0xf2, 0x32, 0x59, 0x65, 0x20, 0x15, + 0x8f, 0x53, 0x4f, 0x29, 0xee, 0x2d, 0xfa, 0x6d, 0xb2, 0x77, 0x64, 0x52, 0x88, 0xc9, 0x6e, 0xab, + 0xfd, 0x2a, 0x16, 0xb1, 0x30, 0xd0, 0x2f, 0xd0, 0x8e, 0xed, 0xfe, 0xb1, 0x30, 0xfd, 0x74, 0xcc, + 0xfd, 0x6e, 0x62, 0x47, 0x22, 0xca, 0xe7, 0x90, 0x6a, 0xf2, 0x16, 0x57, 0x23, 0x91, 0x6a, 0x58, + 0x6a, 0x8a, 0x9c, 0xb2, 0x5b, 0x1f, 0x36, 0xef, 0x6e, 0x3a, 0xb5, 0x8f, 0x7b, 0x2e, 0x38, 0x22, + 0xf2, 0x02, 0x5b, 0x9c, 0x51, 0xcb, 0x41, 0x6e, 0x3d, 0xb0, 0x38, 0x23, 0x14, 0x57, 0x25, 0x2c, + 0xc4, 0x14, 0x18, 0x2d, 0x3b, 0xc8, 0xad, 0x05, 0x87, 0x91, 0xbc, 0xc1, 0x75, 0x95, 0xab, 0x0c, + 0x52, 0x06, 0x8c, 0x3e, 0x33, 0xda, 0x89, 0xd8, 0xf9, 0xe6, 0xa1, 0x9c, 0x2a, 0xfa, 0xdc, 0x84, + 0x1d, 0x46, 0xf2, 0x1a, 0x57, 0xb8, 0x52, 0x39, 0x48, 0x5a, 0x31, 0xc2, 0x7e, 0x22, 0x5d, 0xdc, + 0x2c, 0x50, 0x98, 0x46, 0x30, 0x0a, 0x35, 0xd0, 0xaa, 0x51, 0xcf, 0x38, 0xf2, 0x01, 0xd3, 0x53, + 0x75, 0x5f, 0x41, 0x4e, 0x67, 0x10, 0x08, 0xa1, 0x3f, 0x87, 0x2a, 0xa1, 0x35, 0xb3, 0x7f, 0x55, + 0xef, 0xfe, 0x43, 0xb8, 0x75, 0xd9, 0x4f, 0xf1, 0x05, 0x32, 0x79, 0x98, 0x7a, 0x5e, 0x1c, 0x45, + 0x0e, 0x72, 0x1b, 0x83, 0x77, 0xde, 0xe5, 0xc3, 0x78, 0xd7, 0xaa, 0x0e, 0xae, 0x66, 0x91, 0x1f, + 0xb8, 0x75, 0xa9, 0x7d, 0x2b, 0x9e, 0xd5, 0xd4, 0xdd, 0x18, 0x74, 0x1e, 0xff, 0xe4, 0x60, 0x35, + 0x6b, 0xc1, 0xd3, 0xee, 0xe1, 0x97, 0xbf, 0x1b, 0x1b, 0xad, 0x37, 0x36, 0xba, 0xdd, 0xd8, 0xe8, + 0xf7, 0xd6, 0x2e, 0xad, 0xb7, 0x76, 0xe9, 0xff, 0xd6, 0x2e, 0xfd, 0x1c, 0xc4, 0x5c, 0x27, 0xf9, + 0xd8, 0x8b, 0xc4, 0xdc, 0x3f, 0x66, 0xf7, 0xcc, 0xb9, 0x44, 0x62, 0xe6, 0x27, 0x9c, 0xf5, 0x52, + 0xc1, 0xc0, 0x5f, 0xfa, 0xc5, 0x95, 0xe9, 0x55, 0x06, 0x6a, 0x5c, 0x31, 0xf2, 0xfb, 0xfb, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xb5, 0x03, 0xc2, 0x4b, 0xab, 0x02, 0x00, 0x00, } func (m *CredentialStatusDocument) Marshal() (dAtA []byte, err error) { @@ -225,28 +236,28 @@ func (m *CredentialStatusDocument) MarshalToSizedBuffer(dAtA []byte) (int, error copy(dAtA[i:], m.CredentialMerkleRootHash) i = encodeVarintCredentialStatus(dAtA, i, uint64(len(m.CredentialMerkleRootHash))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 } if len(m.IssuanceDate) > 0 { i -= len(m.IssuanceDate) copy(dAtA[i:], m.IssuanceDate) i = encodeVarintCredentialStatus(dAtA, i, uint64(len(m.IssuanceDate))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } if len(m.Issuer) > 0 { i -= len(m.Issuer) copy(dAtA[i:], m.Issuer) i = encodeVarintCredentialStatus(dAtA, i, uint64(len(m.Issuer))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if len(m.Remarks) > 0 { i -= len(m.Remarks) copy(dAtA[i:], m.Remarks) i = encodeVarintCredentialStatus(dAtA, i, uint64(len(m.Remarks))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if m.Suspended { i-- @@ -256,7 +267,7 @@ func (m *CredentialStatusDocument) MarshalToSizedBuffer(dAtA []byte) (int, error dAtA[i] = 0 } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if m.Revoked { i-- @@ -266,14 +277,23 @@ func (m *CredentialStatusDocument) MarshalToSizedBuffer(dAtA []byte) (int, error dAtA[i] = 0 } i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 } if len(m.Id) > 0 { i -= len(m.Id) copy(dAtA[i:], m.Id) i = encodeVarintCredentialStatus(dAtA, i, uint64(len(m.Id))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if len(m.Context) > 0 { + for iNdEx := len(m.Context) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Context[iNdEx]) + copy(dAtA[i:], m.Context[iNdEx]) + i = encodeVarintCredentialStatus(dAtA, i, uint64(len(m.Context[iNdEx]))) + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } @@ -342,6 +362,12 @@ func (m *CredentialStatusDocument) Size() (n int) { } var l int _ = l + if len(m.Context) > 0 { + for _, s := range m.Context { + l = len(s) + n += 1 + l + sovCredentialStatus(uint64(l)) + } + } l = len(m.Id) if l > 0 { n += 1 + l + sovCredentialStatus(uint64(l)) @@ -424,6 +450,38 @@ func (m *CredentialStatusDocument) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentialStatus + } + 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 ErrInvalidLengthCredentialStatus + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCredentialStatus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Context = append(m.Context, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } @@ -455,7 +513,7 @@ func (m *CredentialStatusDocument) Unmarshal(dAtA []byte) error { } m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Revoked", wireType) } @@ -475,7 +533,7 @@ func (m *CredentialStatusDocument) Unmarshal(dAtA []byte) error { } } m.Revoked = bool(v != 0) - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Suspended", wireType) } @@ -495,7 +553,7 @@ func (m *CredentialStatusDocument) Unmarshal(dAtA []byte) error { } } m.Suspended = bool(v != 0) - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Remarks", wireType) } @@ -527,7 +585,7 @@ func (m *CredentialStatusDocument) Unmarshal(dAtA []byte) error { } m.Remarks = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Issuer", wireType) } @@ -559,7 +617,7 @@ func (m *CredentialStatusDocument) Unmarshal(dAtA []byte) error { } m.Issuer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field IssuanceDate", wireType) } @@ -591,7 +649,7 @@ func (m *CredentialStatusDocument) Unmarshal(dAtA []byte) error { } m.IssuanceDate = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CredentialMerkleRootHash", wireType) } diff --git a/x/ssi/types/ssi_types.go b/x/ssi/types/ssi_types.go index 6ca2a7c..613ed46 100644 --- a/x/ssi/types/ssi_types.go +++ b/x/ssi/types/ssi_types.go @@ -11,6 +11,7 @@ import ( type ( SsiMsg interface { proto.Message + GetId() string GetSignBytes() []byte } @@ -87,14 +88,6 @@ type ( } ) -// Handle Proof Struct of SSI Docs -type SSIProofInterface interface { - GetProofValue() string - GetType() string - GetVerificationMethod() string - GetClientSpecType() ClientSpecType -} - // CAIP-10 Blockchain Account Id type BlockchainId struct { CAIP10Prefix string diff --git a/x/ssi/verification/client_spec.go b/x/ssi/verification/client_spec.go index c565ca2..daa8b47 100644 --- a/x/ssi/verification/client_spec.go +++ b/x/ssi/verification/client_spec.go @@ -56,43 +56,47 @@ func getPersonalSignSpecDocBytes(ssiMsg types.SsiMsg) ([]byte, error) { func getDocBytesByClientSpec(ssiMsg types.SsiMsg, extendedVm *types.ExtendedVerificationMethod) ([]byte, error) { switch extendedVm.Proof.ClientSpecType { case types.CLIENT_SPEC_TYPE_NONE: - if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) > 0 { - return ldcontext.NormalizeByVerificationMethodType(didDoc, extendedVm.Type, extendedVm.Proof) + if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) == 0 { + return ssiMsg.GetSignBytes(), nil } - return ssiMsg.GetSignBytes(), nil + + return ldcontext.NormalizeByVerificationMethodType(ssiMsg, extendedVm.Type, extendedVm.Proof) case types.CLIENT_SPEC_TYPE_COSMOS_ADR036: signerAddress, err := getBlockchainAddress(extendedVm.BlockchainAccountId) if err != nil { return nil, err } - if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) > 0 { - canonizedDidDocHash, err := ldcontext.EcdsaSecp256k1Signature2019Normalize(didDoc, extendedVm.Proof) - if err != nil { - return nil, err - } + if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) == 0 { + return getCosmosADR036SignDocBytes(ssiMsg.GetSignBytes(), signerAddress) + } - return getCosmosADR036SignDocBytes(canonizedDidDocHash, signerAddress) + canonizedDidDocHash, err := ldcontext.EcdsaSecp256k1Signature2019Normalize(ssiMsg, extendedVm.Proof) + if err != nil { + return nil, err } - return getCosmosADR036SignDocBytes(ssiMsg.GetSignBytes(), signerAddress) + + return getCosmosADR036SignDocBytes(canonizedDidDocHash, signerAddress) + case types.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN: - if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) > 0 { - canonizedDidDocHash, err := ldcontext.EcdsaSecp256k1RecoverySignature2020Normalize(didDoc, extendedVm.Proof) - if err != nil { - return nil, err - } + if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) == 0 { + return getPersonalSignSpecDocBytes(ssiMsg) + } - // TODO: This is temporary fix eth.personal.sign() client function, since it only signs JSON - // stringified document and hence the following struct was used to sign from the Client end. - return json.Marshal(struct { - DidId string `json:"didId"` - DidDocDigest string `json:"didDocDigest"` - }{ - DidId: didDoc.Id, - DidDocDigest: hex.EncodeToString(canonizedDidDocHash), - }) + canonizedDidDocHash, err := ldcontext.EcdsaSecp256k1RecoverySignature2020Normalize(ssiMsg, extendedVm.Proof) + if err != nil { + return nil, err } - return getPersonalSignSpecDocBytes(ssiMsg) + + // TODO: This is temporary fix eth.personal.sign() client function, since it only signs JSON + // stringified document and hence the following struct was used to sign from the Client end. + return json.Marshal(struct { + DidId string `json:"didId"` + DidDocDigest string `json:"didDocDigest"` + }{ + DidId: ssiMsg.GetId(), + DidDocDigest: hex.EncodeToString(canonizedDidDocHash), + }) default: return nil, fmt.Errorf("unsupported clientSpecType %v", extendedVm.Proof.ClientSpecType) } From 0c4abb15831a22b5d00350d388d659eb93dd3ec1 Mon Sep 17 00:00:00 2001 From: Arnab Ghose Date: Mon, 13 Nov 2023 12:52:43 +0530 Subject: [PATCH 09/11] feat: added JSON-LD signing support for credential schema --- cmd/hid-noded/cmd/debug_extensions.go | 49 ++++++-- proto/ssi/v1/credential_schema.proto | 16 +-- tests/e2e/ssi_tests/generate_doc.py | 10 +- tests/e2e/ssi_tests/utils.py | 5 +- x/ssi/ld-context/context.go | 46 ++++++++ x/ssi/ld-context/normalize.go | 53 ++++++++- x/ssi/ld-context/types.go | 69 ++++++------ x/ssi/types/credential_schema.pb.go | 154 ++++++++++++++++++-------- 8 files changed, 296 insertions(+), 106 deletions(-) diff --git a/cmd/hid-noded/cmd/debug_extensions.go b/cmd/hid-noded/cmd/debug_extensions.go index 88f2d2b..dcd73de 100644 --- a/cmd/hid-noded/cmd/debug_extensions.go +++ b/cmd/hid-noded/cmd/debug_extensions.go @@ -413,13 +413,13 @@ func signDidDocCmd() *cobra.Command { func signSchemaDocCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "schema-doc [doc] [private-key] [signing-algo]", + Use: "schema-doc [doc] [private-key] [proof-object-without-signature]", Short: "Schema Document signature", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { argSchemaDoc := args[0] argPrivateKey := args[1] - argSigningAlgo := args[2] + argProofObjectWithoutSignature := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -432,38 +432,67 @@ func signSchemaDocCmd() *cobra.Command { if err != nil { return err } - schemaDocBytes := schemaDoc.GetSignBytes() + + // Unmarshal Proof Object + var credSchemaDocProof types.DocumentProof + err = clientCtx.Codec.UnmarshalJSON([]byte(argProofObjectWithoutSignature), &credSchemaDocProof) + if err != nil { + return err + } // Sign Schema Document var signature string - switch argSigningAlgo { + switch credSchemaDocProof.Type { case types.Ed25519Signature2020: - signature, err = hidnodecli.GetEd25519Signature2020(argPrivateKey, schemaDocBytes) + credSchemaDocBytes, err := ldcontext.Ed25519Signature2020Normalize(&schemaDoc, &credSchemaDocProof) + if err != nil { + return err + } + + signature, err = hidnodecli.GetEd25519Signature2020(argPrivateKey, credSchemaDocBytes) if err != nil { return err } case types.EcdsaSecp256k1Signature2019: - signature, err = hidnodecli.GetEcdsaSecp256k1Signature2019(argPrivateKey, schemaDocBytes) + credSchemaDocBytes, err := ldcontext.EcdsaSecp256k1Signature2019Normalize(&schemaDoc, &credSchemaDocProof) + if err != nil { + return err + } + + signature, err = hidnodecli.GetEcdsaSecp256k1Signature2019(argPrivateKey, credSchemaDocBytes) if err != nil { return err } case types.EcdsaSecp256k1RecoverySignature2020: - signature, err = hidnodecli.GetEcdsaSecp256k1RecoverySignature2020(argPrivateKey, schemaDocBytes) + credSchemaDocBytes, err := ldcontext.EcdsaSecp256k1RecoverySignature2020Normalize(&schemaDoc, &credSchemaDocProof) + if err != nil { + return err + } + + signature, err = hidnodecli.GetEcdsaSecp256k1RecoverySignature2020(argPrivateKey, credSchemaDocBytes) if err != nil { return err } case types.BbsBlsSignature2020: - signature, err = hidnodecli.GetBbsBlsSignature2020(argPrivateKey, schemaDocBytes) + credSchemaDocBytes, err := ldcontext.BbsBlsSignature2020Normalize(&schemaDoc, &credSchemaDocProof) + if err != nil { + return err + } + + signature, err = hidnodecli.GetBbsBlsSignature2020(argPrivateKey, credSchemaDocBytes) if err != nil { return err } case types.BabyJubJubSignature2023: - signature, err = hidnodecli.GetBabyJubJubSignature2023(argPrivateKey, schemaDocBytes) + signature, err = hidnodecli.GetBabyJubJubSignature2023(argPrivateKey, schemaDoc.GetSignBytes()) if err != nil { return err } default: - panic("recieved unsupported signing-algo. Supported algorithms are: [Ed25519Signature2020, EcdsaSecp256k1Signature2019, EcdsaSecp256k1RecoverySignature2020, BbsBlsSignature2020, BabyJubJubSignature2023]") + panic(fmt.Sprintf( + "recieved unsupported signing-algo '%v'. Supported algorithms are: [Ed25519Signature2020, EcdsaSecp256k1Signature2019, EcdsaSecp256k1RecoverySignature2020, BbsBlsSignature2020, BabyJubJubSignature2023]", + credSchemaDocProof.Type, + )) } _, err = fmt.Fprintln(cmd.OutOrStdout(), signature) diff --git a/proto/ssi/v1/credential_schema.proto b/proto/ssi/v1/credential_schema.proto index a8fa062..fc2125c 100644 --- a/proto/ssi/v1/credential_schema.proto +++ b/proto/ssi/v1/credential_schema.proto @@ -2,17 +2,19 @@ syntax = "proto3"; package hypersign.ssi.v1; import "ssi/v1/proof.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/hypersign-protocol/hid-node/x/ssi/types"; message CredentialSchemaDocument { - string type = 1; - string modelVersion = 2; - string id = 3; - string name = 4; - string author = 5; - string authored = 6; - CredentialSchemaProperty schema = 7; + repeated string context = 1 [json_name = "@context", (gogoproto.jsontag) = "@context"]; + string type = 2; + string modelVersion = 3; + string id = 4; + string name = 5; + string author = 6; + string authored = 7; + CredentialSchemaProperty schema = 8; } message CredentialSchemaProperty { diff --git a/tests/e2e/ssi_tests/generate_doc.py b/tests/e2e/ssi_tests/generate_doc.py index fb67d61..c032107 100644 --- a/tests/e2e/ssi_tests/generate_doc.py +++ b/tests/e2e/ssi_tests/generate_doc.py @@ -12,6 +12,7 @@ SECP256K1_VER_KEY_2019_CONTEXT = "https://ns.did.ai/suites/secp256k1-2019/v1" BBS_CONTEXT = "https://ns.did.ai/suites/bls12381-2020/v1" CREDENTIAL_STATUS_CONTEXT = "https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialStatus.jsonld" +CREDENTIAL_SCHEMA_CONTEXT = "https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialSchema.jsonld" def generate_did_document(key_pair, algo="Ed25519Signature2020", bech32prefix="hid", is_uuid=False): base_document = { @@ -96,6 +97,7 @@ def generate_did_document(key_pair, algo="Ed25519Signature2020", bech32prefix="h def generate_schema_document(key_pair, schema_author, vm, signature=None, algo="Ed25519Signature2020", updated_schema=None): base_schema_doc = { + "@context": [CREDENTIAL_SCHEMA_CONTEXT], "type": "https://schema.org/Person", "modelVersion": "v1.0", "id": "", @@ -114,12 +116,16 @@ def generate_schema_document(key_pair, schema_author, vm, signature=None, algo=" proof_type = "" if algo == "Ed25519Signature2020": proof_type = "Ed25519Signature2020" + base_schema_doc["@context"].append(ED25519_CONTEXT) elif algo == "EcdsaSecp256k1Signature2019": proof_type = "EcdsaSecp256k1Signature2019" + base_schema_doc["@context"].append(SECP256K1_VER_KEY_2019_CONTEXT) elif algo == "EcdsaSecp256k1RecoverySignature2020": proof_type = "EcdsaSecp256k1RecoverySignature2020" + base_schema_doc["@context"].append(SECP256K1_RECOVERY_CONTEXT) elif algo == "BbsBlsSignature2020": proof_type = "BbsBlsSignature2020" + base_schema_doc["@context"].append(BBS_CONTEXT) elif algo == "BabyJubJubSignature2023": proof_type = "BabyJubJubSignature2023" else: @@ -141,12 +147,12 @@ def generate_schema_document(key_pair, schema_author, vm, signature=None, algo=" # Form Signature if not updated_schema: if not signature: - signature = get_document_signature(base_schema_doc, "schema", key_pair, algo) + signature = get_document_signature(base_schema_doc, "schema", key_pair, algo, proofObj=base_schema_proof) base_schema_proof["proofValue"] = signature return base_schema_doc, base_schema_proof else: if not signature: - signature = get_document_signature(updated_schema, "schema", key_pair, algo) + signature = get_document_signature(updated_schema, "schema", key_pair, algo, proofObj=base_schema_proof) base_schema_proof["proofValue"] = signature return updated_schema, base_schema_proof diff --git a/tests/e2e/ssi_tests/utils.py b/tests/e2e/ssi_tests/utils.py index bf6c590..f3c3f70 100644 --- a/tests/e2e/ssi_tests/utils.py +++ b/tests/e2e/ssi_tests/utils.py @@ -123,10 +123,7 @@ def get_document_signature(doc: dict, doc_type: str, key_pair: dict, algo: str = else: raise Exception("Invalid value for doc_type param: " + doc_type) - if doc_type == "did" or doc_type == "cred-status": - cmd_string = f"hid-noded debug sign-ssi-doc {doc_cmd} '{json.dumps(doc)}' {private_key} '{json.dumps(proofObj)}'" - else: - cmd_string = f"hid-noded debug sign-ssi-doc {doc_cmd} '{json.dumps(doc)}' {private_key} {algo}" + cmd_string = f"hid-noded debug sign-ssi-doc {doc_cmd} '{json.dumps(doc)}' {private_key} '{json.dumps(proofObj)}'" signature, _ = run_command(cmd_string) if signature == "": diff --git a/x/ssi/ld-context/context.go b/x/ssi/ld-context/context.go index 97eb1cb..560943a 100644 --- a/x/ssi/ld-context/context.go +++ b/x/ssi/ld-context/context.go @@ -8,6 +8,7 @@ const BbsSignature2020Context string = "https://ns.did.ai/suites/bls12381-2020/v const Secp256k12019Context string = "https://ns.did.ai/suites/secp256k1-2019/v1" const X25519KeyAgreementKeyEIP5630Context string = "https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/X25519KeyAgreementKeyEIP5630.jsonld" const CredentialStatusContext string = "https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialStatus.jsonld" +const CredentialSchemaContext string = "https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialSchema.jsonld" // As hid-node is not supposed to perform any GET request, the complete Context body of their // respective Context urls has been maintained below. @@ -676,4 +677,49 @@ var ContextUrlMap map[string]contextObject = map[string]contextObject{ "@type": "xsd:string", }, }, + CredentialSchemaContext: { + "@version": 1.1, + "hypersign-vocab": "urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "id": "@id", + "type": map[string]interface{}{ + "@id": "hypersign-vocab:type", + }, + "modelVersion": map[string]interface{}{ + "@id": "hypersign-vocab:modelVersion", + "@type": "xsd:string", + }, + "name": map[string]interface{}{ + "@id": "hypersign-vocab:name", + "@type": "xsd:string", + }, + "author": map[string]interface{}{ + "@id": "hypersign-vocab:author", + "@type": "xsd:string", + }, + "authored": map[string]interface{}{ + "@id": "hypersign-vocab:authored", + "@type": "xsd:dateTime", + }, + "schema": map[string]interface{}{ + "@id": "hypersign-vocab:schema", + "@type": "xsd:string", + }, + "additionalProperties": map[string]interface{}{ + "@id": "hypersign-vocab:additionalProperties", + "@type": "xsd:boolean", + }, + "description": map[string]interface{}{ + "@id": "hypersign-vocab:description", + "@type": "xsd:string", + }, + "properties": map[string]interface{}{ + "@id": "hypersign-vocab:properties", + "@type": "xsd:string", + }, + "required": map[string]interface{}{ + "@id": "hypersign-vocab:required", + "@container": "@set", + }, + }, } diff --git a/x/ssi/ld-context/normalize.go b/x/ssi/ld-context/normalize.go index e938156..f6a8df8 100644 --- a/x/ssi/ld-context/normalize.go +++ b/x/ssi/ld-context/normalize.go @@ -2,8 +2,11 @@ package ldcontext import ( "crypto/sha256" + "encoding/json" + "fmt" "github.com/hypersign-protocol/hid-node/x/ssi/types" + "github.com/piprate/json-gold/ld" ) // NormalizeByVerificationMethodType normalizes DID Document based on the input Verification @@ -64,7 +67,13 @@ func normalizeDocumentWithProof(msg types.SsiMsg, docProof *types.DocumentProof) } context = doc.Context case *types.CredentialSchemaDocument: - return doc.GetSignBytes(), nil + var err error + jsonLdCredentialSchema := NewJsonLdCredentialSchema(doc) + canonizedDocument, err = normalizeWithURDNA2015(jsonLdCredentialSchema) + if err != nil { + return nil, err + } + context = doc.Context } canonizedDocumentHash := sha256.Sum256([]byte(canonizedDocument)) @@ -85,6 +94,48 @@ func normalizeDocumentWithProof(msg types.SsiMsg, docProof *types.DocumentProof) return finalNormalizedHash, nil } +// normalizeWithURDNA2015 performs RDF Canonization upon JsonLdDid using URDNA2015 +// algorithm and returns the canonized document in string +func normalizeWithURDNA2015(jsonLdDocument JsonLdDocument) (string, error) { + return normalize(ld.AlgorithmURDNA2015, jsonLdDocument) +} + +func normalize(algorithm string, jsonLdDocument JsonLdDocument) (string, error) { + proc := ld.NewJsonLdProcessor() + options := ld.NewJsonLdOptions("") + options.Algorithm = algorithm // ld.AlgorithmURDNA2015 + options.Format = "application/n-quads" + + normalisedJsonLd, err := proc.Normalize(jsonLdDocToInterface(jsonLdDocument), options) + if err != nil { + return "", fmt.Errorf("unable to Normalize DID Document: %v", err.Error()) + } + + canonizedDocString := normalisedJsonLd.(string) + if canonizedDocString == "" { + return "", fmt.Errorf("normalization of JSON-LD document yielded empty RDF string") + } + + return canonizedDocString, nil +} + +// Convert JsonLdDid to interface +func jsonLdDocToInterface(jsonLd any) interface{} { + var intf interface{} + + jsonLdBytes, err := json.Marshal(jsonLd) + if err != nil { + panic(err) + } + + err = json.Unmarshal(jsonLdBytes, &intf) + if err != nil { + panic(err) + } + + return intf +} + // Ed25519Signature2020Normalize normalizes DID Document in accordance with // EdDSA Cryptosuite v2020 (https://www.w3.org/community/reports/credentials/CG-FINAL-di-eddsa-2020-20220724/) func Ed25519Signature2020Normalize(ssiMsg types.SsiMsg, didDocProof *types.DocumentProof) ([]byte, error) { diff --git a/x/ssi/ld-context/types.go b/x/ssi/ld-context/types.go index 3dbcac7..1eaa4f6 100644 --- a/x/ssi/ld-context/types.go +++ b/x/ssi/ld-context/types.go @@ -1,11 +1,9 @@ package ldcontext import ( - "encoding/json" "fmt" "github.com/hypersign-protocol/hid-node/x/ssi/types" - "github.com/piprate/json-gold/ld" ) type contextObject map[string]interface{} @@ -65,7 +63,7 @@ func NewJsonLdDidDocument(didDoc *types.DidDocument) *JsonLdDidDocument { return jsonLdDoc } -// It is a similar to `Did` struct, with the exception that the `context` attribute is of type +// It is a similar to `CredentialStatusDocument` struct, with the exception that the `context` attribute is of type // `contextObject` instead of `[]string`, which is meant for accomodating Context JSON body // having arbritrary attributes. It should be used for performing Canonization. type JsonLdCredentialStatus struct { @@ -147,44 +145,47 @@ func NewJsonLdDocumentProof(didDocProof *types.DocumentProof, didContexts []stri return jsonLdDoc } -// normalizeWithURDNA2015 performs RDF Canonization upon JsonLdDid using URDNA2015 -// algorithm and returns the canonized document in string -func normalizeWithURDNA2015(jsonLdDocument JsonLdDocument) (string, error) { - return normalize(ld.AlgorithmURDNA2015, jsonLdDocument) +// It is a similar to `CredentialSchemaDocument` struct, with the exception that the `context` attribute is of type +// `contextObject` instead of `[]string`, which is meant for accomodating Context JSON body +// having arbritrary attributes. It should be used for performing Canonization. +type JsonLdCredentialSchema struct { + Context []contextObject `json:"@context,omitempty"` + Type string `json:"type,omitempty"` + ModelVersion string `json:"modelVersion,omitempty"` + Id string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Author string `json:"author,omitempty"` + Authored string `json:"authored,omitempty"` + Schema *types.CredentialSchemaProperty `json:"schema,omitempty"` } -func normalize(algorithm string, jsonLdDocument JsonLdDocument) (string, error) { - proc := ld.NewJsonLdProcessor() - options := ld.NewJsonLdOptions("") - options.Algorithm = algorithm // ld.AlgorithmURDNA2015 - options.Format = "application/n-quads" - - normalisedJsonLd, err := proc.Normalize(jsonLdDocToInterface(jsonLdDocument), options) - if err != nil { - return "", fmt.Errorf("unable to Normalize DID Document: %v", err.Error()) - } +func (doc *JsonLdCredentialSchema) GetContext() []contextObject { + return doc.Context +} - canonizedDocString := normalisedJsonLd.(string) - if canonizedDocString == "" { - return "", fmt.Errorf("normalization of JSON-LD document yielded empty RDF string") +func NewJsonLdCredentialSchema(credSchema *types.CredentialSchemaDocument) *JsonLdCredentialSchema { + if len(credSchema.Context) == 0 { + panic("atleast one context url must be provided for DID Document for Canonization") } - return canonizedDocString, nil -} - -// Convert JsonLdDid to interface -func jsonLdDocToInterface(jsonLd any) interface{} { - var intf interface{} + var jsonLdDoc *JsonLdCredentialSchema = &JsonLdCredentialSchema{} - jsonLdBytes, err := json.Marshal(jsonLd) - if err != nil { - panic(err) + for _, url := range credSchema.Context { + contextObj, ok := ContextUrlMap[url] + if !ok { + panic(fmt.Sprintf("invalid or unsupported context url: %v", url)) + } + jsonLdDoc.Context = append(jsonLdDoc.Context, contextObj) } - err = json.Unmarshal(jsonLdBytes, &intf) - if err != nil { - panic(err) - } + jsonLdDoc.Type = credSchema.Type + jsonLdDoc.ModelVersion = credSchema.ModelVersion + jsonLdDoc.Id = credSchema.Id + jsonLdDoc.Name = credSchema.Name + jsonLdDoc.Author = credSchema.Author + jsonLdDoc.Authored = credSchema.Authored + jsonLdDoc.Schema = credSchema.Schema - return intf + return jsonLdDoc } + diff --git a/x/ssi/types/credential_schema.pb.go b/x/ssi/types/credential_schema.pb.go index 6d12c59..33ff5bc 100644 --- a/x/ssi/types/credential_schema.pb.go +++ b/x/ssi/types/credential_schema.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -23,13 +24,14 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type CredentialSchemaDocument struct { - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - ModelVersion string `protobuf:"bytes,2,opt,name=modelVersion,proto3" json:"modelVersion,omitempty"` - Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - Author string `protobuf:"bytes,5,opt,name=author,proto3" json:"author,omitempty"` - Authored string `protobuf:"bytes,6,opt,name=authored,proto3" json:"authored,omitempty"` - Schema *CredentialSchemaProperty `protobuf:"bytes,7,opt,name=schema,proto3" json:"schema,omitempty"` + Context []string `protobuf:"bytes,1,rep,name=context,json=@context,proto3" json:"@context"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + ModelVersion string `protobuf:"bytes,3,opt,name=modelVersion,proto3" json:"modelVersion,omitempty"` + Id string `protobuf:"bytes,4,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + Author string `protobuf:"bytes,6,opt,name=author,proto3" json:"author,omitempty"` + Authored string `protobuf:"bytes,7,opt,name=authored,proto3" json:"authored,omitempty"` + Schema *CredentialSchemaProperty `protobuf:"bytes,8,opt,name=schema,proto3" json:"schema,omitempty"` } func (m *CredentialSchemaDocument) Reset() { *m = CredentialSchemaDocument{} } @@ -65,6 +67,13 @@ func (m *CredentialSchemaDocument) XXX_DiscardUnknown() { var xxx_messageInfo_CredentialSchemaDocument proto.InternalMessageInfo +func (m *CredentialSchemaDocument) GetContext() []string { + if m != nil { + return m.Context + } + return nil +} + func (m *CredentialSchemaDocument) GetType() string { if m != nil { return m.Type @@ -259,34 +268,36 @@ func init() { func init() { proto.RegisterFile("ssi/v1/credential_schema.proto", fileDescriptor_9a5852fe559c17be) } var fileDescriptor_9a5852fe559c17be = []byte{ - // 419 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3d, 0x8f, 0xd3, 0x30, - 0x1c, 0xc6, 0xeb, 0xf6, 0x2e, 0x1c, 0x2e, 0x42, 0xc8, 0xe2, 0x90, 0x75, 0x83, 0x89, 0x32, 0x9d, - 0x90, 0x2e, 0xd1, 0x85, 0x6f, 0x70, 0x30, 0x32, 0x9c, 0x52, 0xc1, 0xc0, 0x82, 0x52, 0xdb, 0x6d, - 0x2c, 0x25, 0x71, 0xb0, 0x9d, 0x8a, 0x7e, 0x0b, 0x3e, 0x16, 0x63, 0x27, 0xd4, 0x11, 0xb5, 0x3b, - 0x9f, 0x01, 0xd9, 0x79, 0x69, 0xe9, 0x8b, 0x74, 0xdb, 0xff, 0xf5, 0xb1, 0x7f, 0x8f, 0x0d, 0x89, - 0xd6, 0x22, 0x5a, 0xdc, 0x47, 0x54, 0x71, 0xc6, 0x4b, 0x23, 0xd2, 0xfc, 0x9b, 0xa6, 0x19, 0x2f, - 0xd2, 0xb0, 0x52, 0xd2, 0x48, 0xf4, 0x2a, 0x5b, 0x56, 0x5c, 0x69, 0x31, 0x2f, 0x43, 0xad, 0x45, - 0xb8, 0xb8, 0xbf, 0x41, 0xed, 0x46, 0xa5, 0xa4, 0x9c, 0x35, 0x53, 0xc1, 0x5f, 0x00, 0xf1, 0x87, - 0x5e, 0x61, 0xe2, 0x04, 0x3e, 0x4a, 0x5a, 0x17, 0xbc, 0x34, 0x08, 0xc1, 0x0b, 0xb3, 0xac, 0x38, - 0x06, 0x3e, 0xb8, 0x7d, 0x9e, 0xb8, 0x18, 0x05, 0xf0, 0x45, 0x21, 0x19, 0xcf, 0xbf, 0x58, 0x6d, - 0x59, 0xe2, 0xa1, 0xeb, 0xfd, 0x57, 0x43, 0x2f, 0xe1, 0x50, 0x30, 0x3c, 0x72, 0x9d, 0xa1, 0x60, - 0x56, 0xa7, 0x4c, 0x0b, 0x8e, 0x2f, 0x1a, 0x1d, 0x1b, 0xa3, 0x37, 0xd0, 0x4b, 0x6b, 0x93, 0x49, - 0x85, 0x2f, 0x5d, 0xb5, 0xcd, 0xd0, 0x0d, 0xbc, 0x6a, 0x22, 0xce, 0xb0, 0xe7, 0x3a, 0x7d, 0x8e, - 0x1e, 0xa0, 0xd7, 0x20, 0xe2, 0x67, 0x3e, 0xb8, 0x1d, 0xc7, 0xef, 0xc2, 0x43, 0xc6, 0xf0, 0x90, - 0xe5, 0x51, 0xc9, 0x8a, 0x2b, 0xb3, 0x4c, 0xda, 0xcd, 0x60, 0x7d, 0x02, 0xb8, 0x1b, 0xb2, 0x97, - 0x6a, 0x0f, 0x68, 0x90, 0xdb, 0x0c, 0xf9, 0x70, 0xcc, 0xb8, 0xa6, 0x4a, 0x54, 0x66, 0xc7, 0xbc, - 0x5f, 0xea, 0xad, 0x1a, 0xed, 0x59, 0x45, 0x20, 0xac, 0x1a, 0x65, 0xc1, 0x75, 0x0b, 0xbf, 0x57, - 0xb1, 0xa8, 0x8a, 0x7f, 0xaf, 0x85, 0x45, 0xbd, 0xf4, 0x47, 0x16, 0xb5, 0xcb, 0x51, 0x0c, 0x5f, - 0xa7, 0x8c, 0x09, 0xab, 0x9d, 0xe6, 0x8f, 0x3b, 0x15, 0x6b, 0xc9, 0x55, 0x72, 0xb2, 0x17, 0xfc, - 0x06, 0xf0, 0xfa, 0x10, 0x6d, 0x62, 0x52, 0xc3, 0xd1, 0x0c, 0x62, 0x7a, 0xe6, 0x91, 0x1d, 0xe9, - 0x93, 0xac, 0xec, 0x36, 0x92, 0xb3, 0x5a, 0xe8, 0x33, 0xbc, 0xa6, 0xc7, 0xde, 0xca, 0x99, 0x73, - 0x6c, 0x1c, 0xbf, 0x3d, 0x3e, 0xa4, 0x5b, 0x75, 0x63, 0xc9, 0xe9, 0xed, 0x87, 0x4f, 0xbf, 0x36, - 0x04, 0xac, 0x36, 0x04, 0xfc, 0xd9, 0x10, 0xf0, 0x73, 0x4b, 0x06, 0xab, 0x2d, 0x19, 0xac, 0xb7, - 0x64, 0xf0, 0x35, 0x9e, 0x0b, 0x93, 0xd5, 0xd3, 0x90, 0xca, 0x22, 0xea, 0xb5, 0xef, 0xdc, 0xd7, - 0xa6, 0x32, 0x8f, 0x32, 0xc1, 0xee, 0x4a, 0xc9, 0x78, 0xf4, 0x23, 0xb2, 0x7f, 0xdf, 0xbe, 0x8a, - 0x9e, 0x7a, 0xae, 0xfd, 0xfe, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xae, 0x9f, 0xe4, 0xda, 0x41, - 0x03, 0x00, 0x00, + // 462 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xc1, 0x6e, 0x13, 0x31, + 0x10, 0x8d, 0x93, 0x36, 0x4d, 0x9d, 0x0a, 0x21, 0xab, 0x45, 0x56, 0x0e, 0x6e, 0x94, 0x0b, 0x11, + 0x52, 0x77, 0xd5, 0xf0, 0x03, 0x28, 0x70, 0xe4, 0x50, 0x6d, 0x05, 0x07, 0x2e, 0x68, 0x6b, 0x3b, + 0x59, 0x4b, 0xd9, 0x9d, 0xc5, 0xf6, 0x56, 0xcd, 0x5f, 0x70, 0xe3, 0x97, 0x38, 0xf6, 0x84, 0x7a, + 0x42, 0x28, 0xb9, 0xf1, 0x15, 0xc8, 0xf6, 0x66, 0x09, 0x49, 0x2b, 0x71, 0x7b, 0xf3, 0xc6, 0xf3, + 0x76, 0xde, 0xf3, 0x1a, 0x33, 0x63, 0x54, 0x7c, 0x7b, 0x19, 0x73, 0x2d, 0x85, 0x2c, 0xac, 0x4a, + 0x17, 0x9f, 0x0d, 0xcf, 0x64, 0x9e, 0x46, 0xa5, 0x06, 0x0b, 0xe4, 0x79, 0xb6, 0x2c, 0xa5, 0x36, + 0x6a, 0x5e, 0x44, 0xc6, 0xa8, 0xe8, 0xf6, 0x72, 0x40, 0xea, 0x89, 0x52, 0x03, 0xcc, 0xc2, 0xa9, + 0xc1, 0xe9, 0x1c, 0xe6, 0xe0, 0x61, 0xec, 0x50, 0x60, 0x47, 0xdf, 0xda, 0x98, 0xbe, 0x6d, 0x74, + 0xaf, 0xbd, 0xec, 0x3b, 0xe0, 0x55, 0x2e, 0x0b, 0x4b, 0x5e, 0xe2, 0x23, 0x0e, 0x85, 0x95, 0x77, + 0x96, 0xa2, 0x61, 0x67, 0x7c, 0x3c, 0x3d, 0xf9, 0xfd, 0xf3, 0xbc, 0xf7, 0xa6, 0xe6, 0x92, 0x06, + 0x11, 0x82, 0x0f, 0xec, 0xb2, 0x94, 0xb4, 0x3d, 0x44, 0xe3, 0xe3, 0xc4, 0x63, 0x32, 0xc2, 0x27, + 0x39, 0x08, 0xb9, 0xf8, 0xe8, 0x56, 0x83, 0x82, 0x76, 0x7c, 0xef, 0x1f, 0x8e, 0x3c, 0xc3, 0x6d, + 0x25, 0xe8, 0x81, 0xef, 0xb4, 0x95, 0x70, 0x3a, 0x45, 0x9a, 0x4b, 0x7a, 0x18, 0x74, 0x1c, 0x26, + 0x2f, 0x70, 0x37, 0xad, 0x6c, 0x06, 0x9a, 0x76, 0x3d, 0x5b, 0x57, 0x64, 0x80, 0x7b, 0x01, 0x49, + 0x41, 0x8f, 0x7c, 0xa7, 0xa9, 0xc9, 0x14, 0x77, 0x43, 0x42, 0xb4, 0x37, 0x44, 0xe3, 0xfe, 0xe4, + 0x55, 0xb4, 0x1b, 0x51, 0xb4, 0x6b, 0xfa, 0x4a, 0x43, 0x29, 0xb5, 0x5d, 0x26, 0xf5, 0xe4, 0xe8, + 0x01, 0xed, 0x27, 0xb3, 0x39, 0xe4, 0x96, 0xaa, 0x3f, 0x80, 0xc2, 0x52, 0xa1, 0x22, 0x43, 0xdc, + 0x17, 0xd2, 0x70, 0xad, 0x4a, 0xeb, 0x3c, 0x87, 0x3c, 0xb6, 0xa9, 0x26, 0xaa, 0xce, 0x56, 0x54, + 0x0c, 0xe3, 0x32, 0x28, 0x2b, 0x69, 0xea, 0x38, 0xb6, 0x18, 0x67, 0x55, 0xcb, 0x2f, 0x95, 0x72, + 0x56, 0x0f, 0xdd, 0x45, 0x24, 0x4d, 0x4d, 0x26, 0xf8, 0x34, 0x15, 0x42, 0x39, 0xed, 0x74, 0x71, + 0xf5, 0x57, 0xc5, 0x85, 0xd5, 0x4b, 0x1e, 0xed, 0x8d, 0x7e, 0x20, 0x7c, 0xb6, 0x6b, 0xed, 0xda, + 0xa6, 0x56, 0x92, 0x19, 0xa6, 0xfc, 0x89, 0xbf, 0xc1, 0x3b, 0xfd, 0xaf, 0x28, 0x37, 0x13, 0xc9, + 0x93, 0x5a, 0xe4, 0x03, 0x3e, 0xe3, 0xfb, 0xd9, 0xc2, 0xcc, 0x27, 0xd6, 0x9f, 0x9c, 0xef, 0x7f, + 0x64, 0x33, 0xea, 0x8f, 0x25, 0x8f, 0x4f, 0x4f, 0xdf, 0x7f, 0x5f, 0x31, 0x74, 0xbf, 0x62, 0xe8, + 0xd7, 0x8a, 0xa1, 0xaf, 0x6b, 0xd6, 0xba, 0x5f, 0xb3, 0xd6, 0xc3, 0x9a, 0xb5, 0x3e, 0x4d, 0xe6, + 0xca, 0x66, 0xd5, 0x4d, 0xc4, 0x21, 0x8f, 0x1b, 0xed, 0x0b, 0xff, 0x06, 0x38, 0x2c, 0xe2, 0x4c, + 0x89, 0x8b, 0x02, 0x84, 0x8c, 0xef, 0x62, 0xf7, 0x74, 0xdc, 0xad, 0x98, 0x9b, 0xae, 0x6f, 0xbf, + 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0x59, 0x50, 0xb4, 0x08, 0x80, 0x03, 0x00, 0x00, } func (m *CredentialSchemaDocument) Marshal() (dAtA []byte, err error) { @@ -319,49 +330,58 @@ func (m *CredentialSchemaDocument) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintCredentialSchema(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 } if len(m.Authored) > 0 { i -= len(m.Authored) copy(dAtA[i:], m.Authored) i = encodeVarintCredentialSchema(dAtA, i, uint64(len(m.Authored))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } if len(m.Author) > 0 { i -= len(m.Author) copy(dAtA[i:], m.Author) i = encodeVarintCredentialSchema(dAtA, i, uint64(len(m.Author))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) i = encodeVarintCredentialSchema(dAtA, i, uint64(len(m.Name))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.Id) > 0 { i -= len(m.Id) copy(dAtA[i:], m.Id) i = encodeVarintCredentialSchema(dAtA, i, uint64(len(m.Id))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if len(m.ModelVersion) > 0 { i -= len(m.ModelVersion) copy(dAtA[i:], m.ModelVersion) i = encodeVarintCredentialSchema(dAtA, i, uint64(len(m.ModelVersion))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(m.Type) > 0 { i -= len(m.Type) copy(dAtA[i:], m.Type) i = encodeVarintCredentialSchema(dAtA, i, uint64(len(m.Type))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if len(m.Context) > 0 { + for iNdEx := len(m.Context) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Context[iNdEx]) + copy(dAtA[i:], m.Context[iNdEx]) + i = encodeVarintCredentialSchema(dAtA, i, uint64(len(m.Context[iNdEx]))) + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } @@ -500,6 +520,12 @@ func (m *CredentialSchemaDocument) Size() (n int) { } var l int _ = l + if len(m.Context) > 0 { + for _, s := range m.Context { + l = len(s) + n += 1 + l + sovCredentialSchema(uint64(l)) + } + } l = len(m.Type) if l > 0 { n += 1 + l + sovCredentialSchema(uint64(l)) @@ -618,6 +644,38 @@ func (m *CredentialSchemaDocument) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentialSchema + } + 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 ErrInvalidLengthCredentialSchema + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCredentialSchema + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Context = append(m.Context, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } @@ -649,7 +707,7 @@ func (m *CredentialSchemaDocument) Unmarshal(dAtA []byte) error { } m.Type = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ModelVersion", wireType) } @@ -681,7 +739,7 @@ func (m *CredentialSchemaDocument) Unmarshal(dAtA []byte) error { } m.ModelVersion = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } @@ -713,7 +771,7 @@ func (m *CredentialSchemaDocument) Unmarshal(dAtA []byte) error { } m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } @@ -745,7 +803,7 @@ func (m *CredentialSchemaDocument) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Author", wireType) } @@ -777,7 +835,7 @@ func (m *CredentialSchemaDocument) Unmarshal(dAtA []byte) error { } m.Author = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Authored", wireType) } @@ -809,7 +867,7 @@ func (m *CredentialSchemaDocument) Unmarshal(dAtA []byte) error { } m.Authored = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) } From d10e2aeb18517e98521ffcb30f6a0953f08cc26d Mon Sep 17 00:00:00 2001 From: Arnab Ghose Date: Mon, 13 Nov 2023 17:43:06 +0530 Subject: [PATCH 10/11] modified clientSpec check to do JSON-singing only for BabyJubJubSignature2023 signed document --- x/ssi/verification/client_spec.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/ssi/verification/client_spec.go b/x/ssi/verification/client_spec.go index daa8b47..9ebaeab 100644 --- a/x/ssi/verification/client_spec.go +++ b/x/ssi/verification/client_spec.go @@ -56,7 +56,7 @@ func getPersonalSignSpecDocBytes(ssiMsg types.SsiMsg) ([]byte, error) { func getDocBytesByClientSpec(ssiMsg types.SsiMsg, extendedVm *types.ExtendedVerificationMethod) ([]byte, error) { switch extendedVm.Proof.ClientSpecType { case types.CLIENT_SPEC_TYPE_NONE: - if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) == 0 { + if extendedVm.Proof.Type == types.BabyJubJubSignature2023 { return ssiMsg.GetSignBytes(), nil } @@ -67,7 +67,7 @@ func getDocBytesByClientSpec(ssiMsg types.SsiMsg, extendedVm *types.ExtendedVeri return nil, err } - if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) == 0 { + if extendedVm.Proof.Type == types.BabyJubJubSignature2023 { return getCosmosADR036SignDocBytes(ssiMsg.GetSignBytes(), signerAddress) } @@ -79,7 +79,7 @@ func getDocBytesByClientSpec(ssiMsg types.SsiMsg, extendedVm *types.ExtendedVeri return getCosmosADR036SignDocBytes(canonizedDidDocHash, signerAddress) case types.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN: - if didDoc, ok := ssiMsg.(*types.DidDocument); ok && len(didDoc.Context) == 0 { + if extendedVm.Proof.Type == types.BabyJubJubSignature2023 { return getPersonalSignSpecDocBytes(ssiMsg) } From f3abe4f99b0d50001ff930e6643bc144dd7b152a Mon Sep 17 00:00:00 2001 From: Arnab Ghose Date: Tue, 14 Nov 2023 10:06:18 +0530 Subject: [PATCH 11/11] updated Swagger for Credential Schema --- client/docs/swagger-ui/swagger.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 0232e63..833295f 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -537,6 +537,10 @@ paths: credentialSchemaDocument: type: object properties: + context: + type: array + items: + type: string type: type: string modelVersion: @@ -685,6 +689,10 @@ paths: credentialSchemaDocument: type: object properties: + context: + type: array + items: + type: string type: type: string modelVersion: @@ -24570,6 +24578,10 @@ definitions: hypersign.ssi.v1.CredentialSchemaDocument: type: object properties: + context: + type: array + items: + type: string type: type: string modelVersion: @@ -24622,6 +24634,10 @@ definitions: credentialSchemaDocument: type: object properties: + context: + type: array + items: + type: string type: type: string modelVersion: @@ -24918,6 +24934,10 @@ definitions: credentialSchemaDocument: type: object properties: + context: + type: array + items: + type: string type: type: string modelVersion: @@ -24981,6 +25001,10 @@ definitions: credentialSchemaDocument: type: object properties: + context: + type: array + items: + type: string type: type: string modelVersion: