refactor app & modules
- makefile clean up - replace cosmos-sdk - upgrade cosmos-sdk to v1.0.0 - replace cometbft refactor cli + app init - rm crisis module - use custom address codec - app setup, depinject fixes - improve errors
This commit is contained in:
parent
52e8d322fa
commit
e5a085642c
4
Makefile
4
Makefile
@ -31,7 +31,7 @@ BUILDDIR ?= $(CURDIR)/build
|
|||||||
###########
|
###########
|
||||||
|
|
||||||
go.sum: go.mod
|
go.sum: go.mod
|
||||||
echo "Ensure dependencies have not been modified ..." >&2
|
@echo "Ensure dependencies have not been modified ..." >&2
|
||||||
go mod verify
|
go mod verify
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ build-linux:
|
|||||||
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build
|
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build
|
||||||
|
|
||||||
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
|
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
|
||||||
@echo "--> installing laconicd"
|
@echo "--> $@ing laconicd"
|
||||||
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...
|
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...
|
||||||
|
|
||||||
$(BUILDDIR)/:
|
$(BUILDDIR)/:
|
||||||
|
73
app/app.go
73
app/app.go
@ -6,13 +6,18 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
dbm "github.com/cosmos/cosmos-db"
|
corestore "cosmossdk.io/core/store"
|
||||||
|
|
||||||
"cosmossdk.io/core/appconfig"
|
|
||||||
"cosmossdk.io/depinject"
|
"cosmossdk.io/depinject"
|
||||||
|
"cosmossdk.io/depinject/appconfig"
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
storetypes "cosmossdk.io/store/types"
|
storetypes "cosmossdk.io/store/types"
|
||||||
|
|
||||||
|
bankkeeper "cosmossdk.io/x/bank/keeper"
|
||||||
|
consensuskeeper "cosmossdk.io/x/consensus/keeper"
|
||||||
|
distrkeeper "cosmossdk.io/x/distribution/keeper"
|
||||||
|
govkeeper "cosmossdk.io/x/gov/keeper"
|
||||||
|
slashingkeeper "cosmossdk.io/x/slashing/keeper"
|
||||||
|
stakingkeeper "cosmossdk.io/x/staking/keeper"
|
||||||
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
||||||
bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
||||||
onboardingkeeper "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
|
onboardingkeeper "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
|
||||||
@ -28,34 +33,23 @@ import (
|
|||||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
||||||
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
|
|
||||||
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
|
||||||
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
|
||||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
|
||||||
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
|
|
||||||
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
|
|
||||||
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
|
||||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
|
||||||
|
|
||||||
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/accounts" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/bank" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/consensus" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/distribution" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/gov" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/mint" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/protocolpool" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/slashing" // import for side-effects
|
||||||
|
_ "cosmossdk.io/x/staking" // import for side-effects
|
||||||
_ "git.vdb.to/cerc-io/laconicd/x/auction/module" // import for side-effects
|
_ "git.vdb.to/cerc-io/laconicd/x/auction/module" // import for side-effects
|
||||||
_ "git.vdb.to/cerc-io/laconicd/x/bond/module" // import for side-effects
|
_ "git.vdb.to/cerc-io/laconicd/x/bond/module" // import for side-effects
|
||||||
_ "git.vdb.to/cerc-io/laconicd/x/onboarding/module" // import for side-effects
|
_ "git.vdb.to/cerc-io/laconicd/x/onboarding/module" // import for side-effects
|
||||||
_ "git.vdb.to/cerc-io/laconicd/x/registry/module" // import for side-effects
|
_ "git.vdb.to/cerc-io/laconicd/x/registry/module" // import for side-effects
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/auth" // import for side-effects
|
_ "github.com/cosmos/cosmos-sdk/x/auth" // import for side-effects
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects
|
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/bank" // import for side-effects
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultNodeHome default home directories for the application daemon
|
// DefaultNodeHome default home directories for the application daemon
|
||||||
@ -74,7 +68,7 @@ var (
|
|||||||
// capabilities aren't needed for testing.
|
// capabilities aren't needed for testing.
|
||||||
type LaconicApp struct {
|
type LaconicApp struct {
|
||||||
*runtime.App
|
*runtime.App
|
||||||
legacyAmino *codec.LegacyAmino
|
// legacyAmino *codec.LegacyAmino
|
||||||
appCodec codec.Codec
|
appCodec codec.Codec
|
||||||
txConfig client.TxConfig
|
txConfig client.TxConfig
|
||||||
interfaceRegistry codectypes.InterfaceRegistry
|
interfaceRegistry codectypes.InterfaceRegistry
|
||||||
@ -86,7 +80,6 @@ type LaconicApp struct {
|
|||||||
SlashingKeeper slashingkeeper.Keeper
|
SlashingKeeper slashingkeeper.Keeper
|
||||||
DistrKeeper distrkeeper.Keeper
|
DistrKeeper distrkeeper.Keeper
|
||||||
GovKeeper *govkeeper.Keeper
|
GovKeeper *govkeeper.Keeper
|
||||||
CrisisKeeper *crisiskeeper.Keeper
|
|
||||||
ConsensusParamsKeeper consensuskeeper.Keeper
|
ConsensusParamsKeeper consensuskeeper.Keeper
|
||||||
|
|
||||||
// laconic keepers
|
// laconic keepers
|
||||||
@ -112,24 +105,13 @@ func init() {
|
|||||||
func AppConfig() depinject.Config {
|
func AppConfig() depinject.Config {
|
||||||
return depinject.Configs(
|
return depinject.Configs(
|
||||||
appconfig.LoadYAML(AppConfigYAML),
|
appconfig.LoadYAML(AppConfigYAML),
|
||||||
depinject.Supply(
|
|
||||||
// supply custom module basics
|
|
||||||
map[string]module.AppModuleBasic{
|
|
||||||
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
|
|
||||||
govtypes.ModuleName: gov.NewAppModuleBasic(
|
|
||||||
[]govclient.ProposalHandler{
|
|
||||||
paramsclient.ProposalHandler,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLaconicApp returns a reference to an initialized LaconicApp.
|
// NewLaconicApp returns a reference to an initialized LaconicApp.
|
||||||
func NewLaconicApp(
|
func NewLaconicApp(
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
db dbm.DB,
|
db corestore.KVStoreWithBatch,
|
||||||
traceStore io.Writer,
|
traceStore io.Writer,
|
||||||
loadLatest bool,
|
loadLatest bool,
|
||||||
appOpts servertypes.AppOptions,
|
appOpts servertypes.AppOptions,
|
||||||
@ -150,7 +132,7 @@ func NewLaconicApp(
|
|||||||
),
|
),
|
||||||
&appBuilder,
|
&appBuilder,
|
||||||
&app.appCodec,
|
&app.appCodec,
|
||||||
&app.legacyAmino,
|
// &app.legacyAmino,
|
||||||
&app.txConfig,
|
&app.txConfig,
|
||||||
&app.interfaceRegistry,
|
&app.interfaceRegistry,
|
||||||
&app.AccountKeeper,
|
&app.AccountKeeper,
|
||||||
@ -159,7 +141,6 @@ func NewLaconicApp(
|
|||||||
&app.SlashingKeeper,
|
&app.SlashingKeeper,
|
||||||
&app.DistrKeeper,
|
&app.DistrKeeper,
|
||||||
&app.GovKeeper,
|
&app.GovKeeper,
|
||||||
&app.CrisisKeeper,
|
|
||||||
&app.ConsensusParamsKeeper,
|
&app.ConsensusParamsKeeper,
|
||||||
&app.AuctionKeeper,
|
&app.AuctionKeeper,
|
||||||
&app.BondKeeper,
|
&app.BondKeeper,
|
||||||
@ -178,11 +159,11 @@ func NewLaconicApp(
|
|||||||
|
|
||||||
/**** Module Options ****/
|
/**** Module Options ****/
|
||||||
|
|
||||||
app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
|
|
||||||
|
|
||||||
// create the simulation manager and define the order of the modules for deterministic simulations
|
// create the simulation manager and define the order of the modules for deterministic simulations
|
||||||
// NOTE: this is not required apps that don't use the simulator for fuzz testing transactions
|
// NOTE: this is not required apps that don't use the simulator for fuzz testing transactions
|
||||||
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, make(map[string]module.AppModuleSimulation, 0))
|
app.sm = module.NewSimulationManagerFromAppModules(
|
||||||
|
app.ModuleManager.Modules,
|
||||||
|
make(map[string]module.AppModuleSimulation, 0))
|
||||||
app.sm.RegisterStoreDecoders()
|
app.sm.RegisterStoreDecoders()
|
||||||
|
|
||||||
if err := app.Load(loadLatest); err != nil {
|
if err := app.Load(loadLatest); err != nil {
|
||||||
@ -192,10 +173,10 @@ func NewLaconicApp(
|
|||||||
return app, nil
|
return app, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LegacyAmino returns LaconicApp's amino codec.
|
// // LegacyAmino returns LaconicApp's amino codec.
|
||||||
func (app *LaconicApp) LegacyAmino() *codec.LegacyAmino {
|
// func (app *LaconicApp) LegacyAmino() *codec.LegacyAmino {
|
||||||
return app.legacyAmino
|
// return app.legacyAmino
|
||||||
}
|
// }
|
||||||
|
|
||||||
// GetKey returns the KVStoreKey for the provided store key.
|
// GetKey returns the KVStoreKey for the provided store key.
|
||||||
func (app *LaconicApp) GetKey(storeKey string) *storetypes.KVStoreKey {
|
func (app *LaconicApp) GetKey(storeKey string) *storetypes.KVStoreKey {
|
||||||
|
32
app/app.yaml
32
app/app.yaml
@ -1,16 +1,30 @@
|
|||||||
modules:
|
modules:
|
||||||
- name: runtime
|
- name: runtime
|
||||||
config:
|
config:
|
||||||
"@type": cosmos.app.runtime.v1alpha1.Module
|
"@type": cosmos.app.runtime.v2.Module
|
||||||
app_name: LaconicApp
|
app_name: LaconicApp
|
||||||
# During begin block slashing happens after distr.BeginBlocker so that
|
# During begin block slashing happens after distr.BeginBlocker so that
|
||||||
# there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.
|
# there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.
|
||||||
# NOTE: staking module is required if HistoricalEntries param > 0
|
# NOTE: staking module is required if HistoricalEntries param > 0
|
||||||
begin_blockers: [distribution, slashing, staking]
|
begin_blockers: [distribution, protocolpool, slashing, staking]
|
||||||
end_blockers: [crisis, gov, staking, auction, registry]
|
end_blockers: [gov, staking, protocolpool, auction, registry]
|
||||||
# NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts.
|
# NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts.
|
||||||
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
|
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
|
||||||
init_genesis: [auth, bank, distribution, staking, slashing, gov, crisis, genutil, auction, bond, registry, onboarding]
|
init_genesis:
|
||||||
|
- consensus
|
||||||
|
- accounts
|
||||||
|
- auth
|
||||||
|
- bank
|
||||||
|
- distribution
|
||||||
|
- staking
|
||||||
|
- slashing
|
||||||
|
- gov
|
||||||
|
- genutil
|
||||||
|
- protocolpool
|
||||||
|
- auction
|
||||||
|
- bond
|
||||||
|
- registry
|
||||||
|
- onboarding
|
||||||
override_store_keys:
|
override_store_keys:
|
||||||
- module_name: auth
|
- module_name: auth
|
||||||
kv_store_key: acc
|
kv_store_key: acc
|
||||||
@ -27,6 +41,9 @@ modules:
|
|||||||
permissions: [burner, staking]
|
permissions: [burner, staking]
|
||||||
- account: gov
|
- account: gov
|
||||||
permissions: [burner]
|
permissions: [burner]
|
||||||
|
- account: protocolpool
|
||||||
|
- account: stream_acc
|
||||||
|
- account: protocolpool_distr
|
||||||
- account: auction
|
- account: auction
|
||||||
- account: auction_burn
|
- account: auction_burn
|
||||||
- account: bond
|
- account: bond
|
||||||
@ -59,9 +76,12 @@ modules:
|
|||||||
- name: gov
|
- name: gov
|
||||||
config:
|
config:
|
||||||
"@type": cosmos.gov.module.v1.Module
|
"@type": cosmos.gov.module.v1.Module
|
||||||
- name: crisis
|
- name: accounts
|
||||||
config:
|
config:
|
||||||
"@type": cosmos.crisis.module.v1.Module
|
"@type": cosmos.accounts.module.v1.Module
|
||||||
|
- name: protocolpool
|
||||||
|
config:
|
||||||
|
"@type": cosmos.protocolpool.module.v1.Module
|
||||||
- name: bond
|
- name: bond
|
||||||
config:
|
config:
|
||||||
"@type": cerc.bond.module.v1.Module
|
"@type": cerc.bond.module.v1.Module
|
||||||
|
@ -6,13 +6,17 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"cosmossdk.io/collections"
|
||||||
storetypes "cosmossdk.io/store/types"
|
storetypes "cosmossdk.io/store/types"
|
||||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
slashingtypes "cosmossdk.io/x/slashing/types"
|
||||||
|
"cosmossdk.io/x/staking"
|
||||||
|
stakingtypes "cosmossdk.io/x/staking/types"
|
||||||
|
tmproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||||
|
cmttypes "github.com/cometbft/cometbft/types"
|
||||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExportAppStateAndValidators exports the state of the application for a genesis file.
|
// ExportAppStateAndValidators exports the state of the application for a genesis file.
|
||||||
@ -32,7 +36,7 @@ func (app *LaconicApp) ExportAppStateAndValidators(
|
|||||||
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
|
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
genState, err := app.ModuleManager.ExportGenesis(ctx, app.appCodec)
|
genState, err := app.ModuleManager.ExportGenesis(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return servertypes.ExportedApp{}, fmt.Errorf("failed to export genesis state: %w", err)
|
return servertypes.ExportedApp{}, fmt.Errorf("failed to export genesis state: %w", err)
|
||||||
}
|
}
|
||||||
@ -43,9 +47,22 @@ func (app *LaconicApp) ExportAppStateAndValidators(
|
|||||||
}
|
}
|
||||||
|
|
||||||
validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
|
validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
|
||||||
|
if err != nil {
|
||||||
|
return servertypes.ExportedApp{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cmtvalidators := make([]cmttypes.GenesisValidator, len(validators))
|
||||||
|
for i := range validators {
|
||||||
|
cmtvalidators[i] = cmttypes.GenesisValidator{
|
||||||
|
Address: validators[i].Address.Bytes(),
|
||||||
|
PubKey: validators[i].PubKey,
|
||||||
|
Power: validators[i].Power,
|
||||||
|
Name: validators[i].Name,
|
||||||
|
}
|
||||||
|
}
|
||||||
return servertypes.ExportedApp{
|
return servertypes.ExportedApp{
|
||||||
AppState: appState,
|
AppState: appState,
|
||||||
Validators: validators,
|
Validators: cmtvalidators,
|
||||||
Height: height,
|
Height: height,
|
||||||
ConsensusParams: app.BaseApp.GetConsensusParams(ctx),
|
ConsensusParams: app.BaseApp.GetConsensusParams(ctx),
|
||||||
}, err
|
}, err
|
||||||
@ -61,10 +78,12 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
applyAllowedAddrs = true
|
applyAllowedAddrs = true
|
||||||
}
|
}
|
||||||
|
|
||||||
allowedAddrsMap := make(map[string]bool)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
valAddrCodec := utils.NewValAddressCodec()
|
||||||
|
|
||||||
|
allowedAddrsMap := make(map[string]bool)
|
||||||
for _, addr := range jailAllowedAddrs {
|
for _, addr := range jailAllowedAddrs {
|
||||||
_, err := sdk.ValAddressFromBech32(addr)
|
_, err := valAddrCodec.StringToBytes(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -74,7 +93,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
/* Handle fee distribution state. */
|
/* Handle fee distribution state. */
|
||||||
|
|
||||||
// withdraw all validator commission
|
// withdraw all validator commission
|
||||||
_ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
|
_ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val sdk.ValidatorI) (stop bool) {
|
||||||
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
|
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -91,12 +110,12 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, delegation := range dels {
|
for _, delegation := range dels {
|
||||||
valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress)
|
valAddr, err := valAddrCodec.StringToBytes(delegation.ValidatorAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress)
|
delAddr, err := addrCodec.StringToBytes(delegation.DelegatorAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -105,17 +124,17 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clear validator slash events
|
// clear validator slash events
|
||||||
app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx)
|
app.DistrKeeper.ValidatorSlashEvents.Clear(ctx, nil)
|
||||||
|
|
||||||
// clear validator historical rewards
|
// clear validator historical rewards
|
||||||
app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
|
app.DistrKeeper.ValidatorHistoricalRewards.Clear(ctx, nil)
|
||||||
|
|
||||||
// set context height to zero
|
// set context height to zero
|
||||||
height := ctx.BlockHeight()
|
height := ctx.BlockHeight()
|
||||||
ctx = ctx.WithBlockHeight(0)
|
ctx = ctx.WithBlockHeight(0)
|
||||||
|
|
||||||
// reinitialize all validators
|
// reinitialize all validators
|
||||||
_ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
|
_ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val sdk.ValidatorI) (stop bool) {
|
||||||
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
|
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -145,12 +164,12 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
|
|
||||||
// reinitialize all delegations
|
// reinitialize all delegations
|
||||||
for _, del := range dels {
|
for _, del := range dels {
|
||||||
valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress)
|
valAddr, err := valAddrCodec.StringToBytes(del.ValidatorAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress)
|
delAddr, err := addrCodec.StringToBytes(del.DelegatorAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -181,12 +200,14 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
})
|
})
|
||||||
|
|
||||||
// iterate through unbonding delegations, reset creation height
|
// iterate through unbonding delegations, reset creation height
|
||||||
_ = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
|
_ = app.StakingKeeper.UnbondingDelegations.Walk(
|
||||||
|
ctx, nil,
|
||||||
|
func(_ collections.Pair[[]byte, []byte], ubd stakingtypes.UnbondingDelegation) (stop bool, err error) {
|
||||||
for i := range ubd.Entries {
|
for i := range ubd.Entries {
|
||||||
ubd.Entries[i].CreationHeight = 0
|
ubd.Entries[i].CreationHeight = 0
|
||||||
}
|
}
|
||||||
_ = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
|
_ = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
|
||||||
return false
|
return false, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
// Iterate through validators by power descending, reset bond heights, and
|
// Iterate through validators by power descending, reset bond heights, and
|
||||||
@ -226,15 +247,15 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
/* Handle slashing state. */
|
/* Handle slashing state. */
|
||||||
|
|
||||||
// reset start height on signing infos
|
// reset start height on signing infos
|
||||||
err = app.SlashingKeeper.IterateValidatorSigningInfos(
|
err = app.SlashingKeeper.ValidatorSigningInfo.Walk(
|
||||||
ctx,
|
ctx, nil,
|
||||||
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
|
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool, err error) {
|
||||||
info.StartHeight = 0
|
info.StartHeight = 0
|
||||||
err = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
|
err = app.SlashingKeeper.ValidatorSigningInfo.Set(ctx, addr, info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return true, err
|
||||||
}
|
}
|
||||||
return false
|
return false, nil
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
package params
|
package params
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cosmossdk.io/errors"
|
|
||||||
"cosmossdk.io/math"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/address"
|
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -39,15 +34,16 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RegisterDenoms() {
|
func RegisterDenoms() {
|
||||||
err := sdk.RegisterDenom(CoinUnit, math.LegacyOneDec())
|
// TODO refactor
|
||||||
if err != nil {
|
// err := sdk.RegisterDenom(CoinUnit, math.LegacyOneDec())
|
||||||
panic(err)
|
// if err != nil {
|
||||||
}
|
// panic(err)
|
||||||
|
// }
|
||||||
|
|
||||||
err = sdk.RegisterDenom(BaseCoinUnit, math.LegacyNewDecWithPrec(1, LntExponent))
|
// err = sdk.RegisterDenom(BaseCoinUnit, math.LegacyNewDecWithPrec(1, LntExponent))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
panic(err)
|
// panic(err)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetAddressPrefixes() {
|
func SetAddressPrefixes() {
|
||||||
@ -55,22 +51,4 @@ func SetAddressPrefixes() {
|
|||||||
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
|
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
|
||||||
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
|
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
|
||||||
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
|
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
|
||||||
|
|
||||||
// This is copied from the cosmos sdk v0.43.0-beta1
|
|
||||||
// source: https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/types/address.go#L141
|
|
||||||
config.SetAddressVerifier(func(bytes []byte) error {
|
|
||||||
if len(bytes) == 0 {
|
|
||||||
return errors.Wrap(sdkerrors.ErrUnknownAddress, "addresses cannot be empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(bytes) > address.MaxAddrLen {
|
|
||||||
return errors.Wrapf(sdkerrors.ErrUnknownAddress, "address max length is %d, got %d", address.MaxAddrLen, len(bytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(bytes) != 20 && len(bytes) != 32 {
|
|
||||||
return errors.Wrapf(sdkerrors.ErrUnknownAddress, "address length must be 20 or 32 bytes, got %d", len(bytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
dbm "github.com/cosmos/cosmos-db"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
|
corestore "cosmossdk.io/core/store"
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
confixcmd "cosmossdk.io/tools/confix/cmd"
|
confixcmd "cosmossdk.io/tools/confix/cmd"
|
||||||
|
|
||||||
@ -18,50 +18,54 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
"github.com/cosmos/cosmos-sdk/client/pruning"
|
"github.com/cosmos/cosmos-sdk/client/pruning"
|
||||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/snapshot"
|
"github.com/cosmos/cosmos-sdk/client/snapshot"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||||
|
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/app"
|
"git.vdb.to/cerc-io/laconicd/app"
|
||||||
"git.vdb.to/cerc-io/laconicd/gql"
|
"git.vdb.to/cerc-io/laconicd/gql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initRootCmd(rootCmd *cobra.Command, txConfig client.TxConfig, basicManager module.BasicManager) {
|
func initRootCmd(rootCmd *cobra.Command, txConfig client.TxConfig, moduleManager moduleManager) {
|
||||||
cfg := sdk.GetConfig()
|
cfg := sdk.GetConfig()
|
||||||
cfg.Seal()
|
cfg.Seal()
|
||||||
|
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
genutilcli.InitCmd(basicManager, app.DefaultNodeHome),
|
genutilcli.InitCmd(moduleManager),
|
||||||
debug.Cmd(),
|
debug.Cmd(),
|
||||||
confixcmd.ConfigCommand(),
|
confixcmd.ConfigCommand(),
|
||||||
pruning.Cmd(newApp, app.DefaultNodeHome),
|
pruning.Cmd(newApp),
|
||||||
snapshot.Cmd(newApp),
|
snapshot.Cmd(newApp),
|
||||||
)
|
)
|
||||||
|
|
||||||
server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, func(startCmd *cobra.Command) {
|
server.AddCommands(rootCmd, newApp, server.StartCmdOptions[*app.LaconicApp]{
|
||||||
// Override start command to run the GQL server
|
PostSetup: func(
|
||||||
newStartCmd := server.StartCmdWithOptions(newApp, app.DefaultNodeHome, server.StartCmdOptions{
|
_ *app.LaconicApp,
|
||||||
PostSetup: func(svrCtx *server.Context, clientCtx client.Context, ctx context.Context, g *errgroup.Group) error {
|
svrCtx *server.Context,
|
||||||
|
clientCtx client.Context,
|
||||||
|
ctx context.Context,
|
||||||
|
g *errgroup.Group,
|
||||||
|
) error {
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
return gql.Server(ctx, clientCtx, svrCtx.Logger.With("module", "gql-server"))
|
return gql.Server(ctx, clientCtx, svrCtx.Logger.With("module", "gql-server"))
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
|
)
|
||||||
startCmd.RunE = newStartCmd.RunE
|
|
||||||
})
|
|
||||||
|
|
||||||
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
server.StatusCommand(),
|
server.StatusCommand(),
|
||||||
genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome),
|
genutilcli.Commands(
|
||||||
|
moduleManager.Modules()[genutiltypes.ModuleName].(genutil.AppModule),
|
||||||
|
moduleManager,
|
||||||
|
appExport),
|
||||||
queryCommand(),
|
queryCommand(),
|
||||||
txCommand(),
|
txCommand(),
|
||||||
keys.Commands(),
|
keys.Commands(),
|
||||||
@ -79,7 +83,6 @@ func queryCommand() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
rpc.ValidatorCommand(),
|
|
||||||
server.QueryBlockCmd(),
|
server.QueryBlockCmd(),
|
||||||
authcmd.QueryTxsByEventsCmd(),
|
authcmd.QueryTxsByEventsCmd(),
|
||||||
server.QueryBlocksCmd(),
|
server.QueryBlocksCmd(),
|
||||||
@ -115,20 +118,25 @@ func txCommand() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newApp is an appCreator
|
// newApp is an appCreator
|
||||||
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
|
func newApp(
|
||||||
|
logger log.Logger,
|
||||||
|
db corestore.KVStoreWithBatch,
|
||||||
|
traceStore io.Writer,
|
||||||
|
appOpts servertypes.AppOptions,
|
||||||
|
) *app.LaconicApp {
|
||||||
|
var _ = db
|
||||||
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
||||||
app, err := app.NewLaconicApp(logger, db, traceStore, true, appOpts, baseappOptions...)
|
app, err := app.NewLaconicApp(logger, db, traceStore, true, appOpts, baseappOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
// appExport creates a new app (optionally at a given height) and exports state.
|
// appExport creates a new app (optionally at a given height) and exports state.
|
||||||
func appExport(
|
func appExport(
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
db dbm.DB,
|
db corestore.KVStoreWithBatch,
|
||||||
traceStore io.Writer,
|
traceStore io.Writer,
|
||||||
height int64,
|
height int64,
|
||||||
forZeroHeight bool,
|
forZeroHeight bool,
|
||||||
|
@ -11,8 +11,10 @@ import (
|
|||||||
"cosmossdk.io/client/v2/autocli"
|
"cosmossdk.io/client/v2/autocli"
|
||||||
clientv2keyring "cosmossdk.io/client/v2/autocli/keyring"
|
clientv2keyring "cosmossdk.io/client/v2/autocli/keyring"
|
||||||
"cosmossdk.io/core/address"
|
"cosmossdk.io/core/address"
|
||||||
|
"cosmossdk.io/core/transaction"
|
||||||
"cosmossdk.io/depinject"
|
"cosmossdk.io/depinject"
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
|
runtime "cosmossdk.io/runtime/v2"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/config"
|
"github.com/cosmos/cosmos-sdk/client/config"
|
||||||
@ -22,7 +24,6 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||||
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||||
@ -30,33 +31,46 @@ import (
|
|||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/app"
|
"git.vdb.to/cerc-io/laconicd/app"
|
||||||
"git.vdb.to/cerc-io/laconicd/gql"
|
"git.vdb.to/cerc-io/laconicd/gql"
|
||||||
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const EnvPrefix = "LACONIC"
|
const EnvPrefix = "LACONIC"
|
||||||
|
|
||||||
|
type moduleManager = *runtime.MM[transaction.Tx]
|
||||||
|
|
||||||
// NewRootCmd creates a new root command for laconicd. It is called once in the
|
// NewRootCmd creates a new root command for laconicd. It is called once in the
|
||||||
// main function.
|
// main function.
|
||||||
func NewRootCmd() *cobra.Command {
|
func NewRootCmd() *cobra.Command {
|
||||||
var (
|
var (
|
||||||
txConfigOpts tx.ConfigOptions
|
txConfigOpts tx.ConfigOptions
|
||||||
autoCliOpts autocli.AppOptions
|
autoCliOpts autocli.AppOptions
|
||||||
moduleBasicManager module.BasicManager
|
moduleManager moduleManager
|
||||||
clientCtx client.Context
|
clientCtx client.Context
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := depinject.Inject(
|
if err := depinject.InjectDebug(
|
||||||
depinject.Configs(app.AppConfig(),
|
depinject.Debug(),
|
||||||
|
depinject.Configs(
|
||||||
|
app.AppConfig(),
|
||||||
depinject.Supply(
|
depinject.Supply(
|
||||||
log.NewNopLogger(),
|
log.NewNopLogger(),
|
||||||
|
utils.NewAddressCodec,
|
||||||
|
utils.NewValAddressCodec,
|
||||||
|
utils.NewConsAddressCodec,
|
||||||
),
|
),
|
||||||
|
runtime.DefaultServiceBindings(),
|
||||||
depinject.Provide(
|
depinject.Provide(
|
||||||
|
codec.ProvideInterfaceRegistry,
|
||||||
|
codec.ProvideAddressCodec,
|
||||||
|
codec.ProvideProtoCodec,
|
||||||
|
codec.ProvideLegacyAmino,
|
||||||
ProvideClientContext,
|
ProvideClientContext,
|
||||||
ProvideKeyring,
|
ProvideKeyring,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
&txConfigOpts,
|
&txConfigOpts,
|
||||||
&autoCliOpts,
|
&autoCliOpts,
|
||||||
&moduleBasicManager,
|
&moduleManager,
|
||||||
&clientCtx,
|
&clientCtx,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -86,7 +100,10 @@ func NewRootCmd() *cobra.Command {
|
|||||||
// This needs to go after ReadFromClientConfig, as that function ets the RPC client needed for SIGN_MODE_TEXTUAL.
|
// This needs to go after ReadFromClientConfig, as that function ets the RPC client needed for SIGN_MODE_TEXTUAL.
|
||||||
txConfigOpts.EnabledSignModes = append(txConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
|
txConfigOpts.EnabledSignModes = append(txConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
|
||||||
txConfigOpts.TextualCoinMetadataQueryFn = txmodule.NewGRPCCoinMetadataQueryFn(clientCtx)
|
txConfigOpts.TextualCoinMetadataQueryFn = txmodule.NewGRPCCoinMetadataQueryFn(clientCtx)
|
||||||
txConfigWithTextual, err := tx.NewTxConfigWithOptions(codec.NewProtoCodec(clientCtx.InterfaceRegistry), txConfigOpts)
|
txConfigWithTextual, err := tx.NewTxConfigWithOptions(
|
||||||
|
codec.NewProtoCodec(clientCtx.InterfaceRegistry),
|
||||||
|
txConfigOpts,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -104,6 +121,7 @@ func NewRootCmd() *cobra.Command {
|
|||||||
|
|
||||||
// overwrite the block timeout
|
// overwrite the block timeout
|
||||||
cmtCfg := cmtcfg.DefaultConfig()
|
cmtCfg := cmtcfg.DefaultConfig()
|
||||||
|
// TODO use FinalizeBlockResponse.next_block_delay
|
||||||
cmtCfg.Consensus.TimeoutCommit = 3 * time.Second
|
cmtCfg.Consensus.TimeoutCommit = 3 * time.Second
|
||||||
cmtCfg.LogLevel = "*:error,p2p:info,state:info,auction:info,bond:info,registry:info,gql-server:info" // better default logging
|
cmtCfg.LogLevel = "*:error,p2p:info,state:info,auction:info,bond:info,registry:info,gql-server:info" // better default logging
|
||||||
|
|
||||||
@ -111,7 +129,7 @@ func NewRootCmd() *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
initRootCmd(rootCmd, clientCtx.TxConfig, moduleBasicManager)
|
initRootCmd(rootCmd, clientCtx.TxConfig, moduleManager)
|
||||||
|
|
||||||
if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
|
if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -127,20 +145,31 @@ func ProvideClientContext(
|
|||||||
appCodec codec.Codec,
|
appCodec codec.Codec,
|
||||||
interfaceRegistry codectypes.InterfaceRegistry,
|
interfaceRegistry codectypes.InterfaceRegistry,
|
||||||
txConfig client.TxConfig,
|
txConfig client.TxConfig,
|
||||||
legacyAmino *codec.LegacyAmino,
|
// legacyAmino registry.AminoRegistrar,
|
||||||
|
addressCodec address.Codec,
|
||||||
|
validatorAddressCodec address.ValidatorAddressCodec,
|
||||||
|
consensusAddressCodec address.ConsensusAddressCodec,
|
||||||
) client.Context {
|
) client.Context {
|
||||||
|
var err error
|
||||||
|
|
||||||
clientCtx := client.Context{}.
|
clientCtx := client.Context{}.
|
||||||
WithCodec(appCodec).
|
WithCodec(appCodec).
|
||||||
WithInterfaceRegistry(interfaceRegistry).
|
WithInterfaceRegistry(interfaceRegistry).
|
||||||
WithTxConfig(txConfig).
|
WithTxConfig(txConfig).
|
||||||
WithLegacyAmino(legacyAmino).
|
// WithLegacyAmino(amino).
|
||||||
WithInput(os.Stdin).
|
WithInput(os.Stdin).
|
||||||
WithAccountRetriever(types.AccountRetriever{}).
|
WithAccountRetriever(types.AccountRetriever{}).
|
||||||
|
WithAddressCodec(addressCodec).
|
||||||
|
WithValidatorAddressCodec(validatorAddressCodec).
|
||||||
|
WithConsensusAddressCodec(consensusAddressCodec).
|
||||||
WithHomeDir(app.DefaultNodeHome).
|
WithHomeDir(app.DefaultNodeHome).
|
||||||
WithViper(EnvPrefix) // env variable prefix
|
WithViper(EnvPrefix) // env variable prefix
|
||||||
|
|
||||||
// Read the config again to overwrite the default values with the values from the config file
|
// Read the config to overwrite the default values with the values from the config file
|
||||||
clientCtx, _ = config.ReadFromClientConfig(clientCtx)
|
clientCtx, err = config.CreateClientConfig(clientCtx, "", nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Workaround: Unset clientCtx.HomeDir and clientCtx.KeyringDir from depinject clientCtx as they are given precedence over
|
// Workaround: Unset clientCtx.HomeDir and clientCtx.KeyringDir from depinject clientCtx as they are given precedence over
|
||||||
// the CLI args (--home flag) in some commands
|
// the CLI args (--home flag) in some commands
|
||||||
|
259
go.mod
259
go.mod
@ -1,8 +1,8 @@
|
|||||||
module git.vdb.to/cerc-io/laconicd
|
module git.vdb.to/cerc-io/laconicd
|
||||||
|
|
||||||
go 1.21
|
go 1.23.1
|
||||||
|
|
||||||
toolchain go1.21.0
|
toolchain go1.23.2
|
||||||
|
|
||||||
replace (
|
replace (
|
||||||
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
|
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
|
||||||
@ -13,23 +13,26 @@ replace (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cosmossdk.io/api v0.7.2
|
cosmossdk.io/api v0.7.6
|
||||||
cosmossdk.io/client/v2 v2.0.0-beta.1
|
cosmossdk.io/client/v2 v2.0.0-beta.1
|
||||||
cosmossdk.io/collections v0.4.0
|
cosmossdk.io/collections v0.4.0
|
||||||
cosmossdk.io/core v0.11.0
|
cosmossdk.io/core v1.0.0-alpha.4
|
||||||
cosmossdk.io/depinject v1.0.0-alpha.4
|
cosmossdk.io/depinject v1.0.0
|
||||||
cosmossdk.io/errors v1.0.1
|
cosmossdk.io/errors v1.0.1
|
||||||
cosmossdk.io/log v1.3.0
|
cosmossdk.io/log v1.4.1
|
||||||
cosmossdk.io/math v1.2.0
|
cosmossdk.io/math v1.3.0
|
||||||
cosmossdk.io/store v1.0.2
|
cosmossdk.io/runtime/v2 v2.0.0-00010101000000-000000000000
|
||||||
|
cosmossdk.io/server/v2 v2.0.0-20240718121635-a877e3e8048a
|
||||||
|
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
|
||||||
cosmossdk.io/tools/confix v0.1.0
|
cosmossdk.io/tools/confix v0.1.0
|
||||||
github.com/99designs/gqlgen v0.17.22
|
github.com/99designs/gqlgen v0.17.22
|
||||||
github.com/cometbft/cometbft v0.38.2
|
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f
|
||||||
github.com/cosmos/cosmos-db v1.0.0
|
github.com/cometbft/cometbft/api v1.0.0-rc.1
|
||||||
github.com/cosmos/cosmos-proto v1.0.0-beta.3
|
github.com/cosmos/cosmos-db v1.0.3-0.20240911104526-ddc3f09bfc22
|
||||||
github.com/cosmos/cosmos-sdk v0.50.3
|
github.com/cosmos/cosmos-proto v1.0.0-beta.5
|
||||||
|
github.com/cosmos/cosmos-sdk v1.0.0
|
||||||
github.com/cosmos/go-bip39 v1.0.0
|
github.com/cosmos/go-bip39 v1.0.0
|
||||||
github.com/cosmos/gogoproto v1.4.11
|
github.com/cosmos/gogoproto v1.7.0
|
||||||
github.com/deckarep/golang-set v1.8.0
|
github.com/deckarep/golang-set v1.8.0
|
||||||
github.com/ethereum/go-ethereum v1.14.5
|
github.com/ethereum/go-ethereum v1.14.5
|
||||||
github.com/gibson042/canonicaljson-go v1.0.3
|
github.com/gibson042/canonicaljson-go v1.0.3
|
||||||
@ -38,165 +41,235 @@ require (
|
|||||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0
|
github.com/grpc-ecosystem/grpc-gateway v1.16.0
|
||||||
github.com/ipfs/go-cid v0.4.1
|
github.com/ipfs/go-cid v0.4.1
|
||||||
github.com/ipld/go-ipld-prime v0.21.0
|
github.com/ipld/go-ipld-prime v0.21.0
|
||||||
github.com/rs/cors v1.8.3
|
github.com/rs/cors v1.11.1
|
||||||
github.com/spf13/cobra v1.8.0
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/spf13/viper v1.17.0
|
github.com/spf13/viper v1.19.0
|
||||||
github.com/statechannels/go-nitro v0.1.2
|
github.com/statechannels/go-nitro v0.1.2
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.9.0
|
||||||
github.com/vektah/gqlparser/v2 v2.5.11
|
github.com/vektah/gqlparser/v2 v2.5.11
|
||||||
golang.org/x/sync v0.7.0
|
golang.org/x/sync v0.8.0
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f
|
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
|
||||||
google.golang.org/grpc v1.60.1
|
google.golang.org/grpc v1.67.1
|
||||||
google.golang.org/protobuf v1.33.0
|
google.golang.org/protobuf v1.35.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cosmossdk.io/x/tx v0.13.0 // indirect
|
cosmossdk.io/x/accounts v1.0.0-alpha.4
|
||||||
filippo.io/edwards25519 v1.0.0 // indirect
|
cosmossdk.io/x/bank v1.0.0-alpha.4
|
||||||
|
cosmossdk.io/x/consensus v0.0.0-20241007000829-38662ecb209f
|
||||||
|
cosmossdk.io/x/distribution v0.0.0-20241007000829-38662ecb209f
|
||||||
|
cosmossdk.io/x/gov v1.0.0-alpha.4
|
||||||
|
cosmossdk.io/x/mint v0.0.0-20241004153623-489aaae40234
|
||||||
|
cosmossdk.io/x/params v0.0.0-20241007000829-38662ecb209f
|
||||||
|
cosmossdk.io/x/protocolpool v1.0.0-alpha.4
|
||||||
|
cosmossdk.io/x/slashing v0.0.0-20241007000829-38662ecb209f
|
||||||
|
cosmossdk.io/x/staking v1.0.0-alpha.4
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
|
||||||
|
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
|
||||||
|
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
|
||||||
|
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
|
||||||
|
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect
|
||||||
|
cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 // indirect
|
||||||
|
cosmossdk.io/server/v2/stf v0.0.0-00010101000000-000000000000 // indirect
|
||||||
|
cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 // indirect
|
||||||
|
cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 // indirect
|
||||||
|
cosmossdk.io/x/tx v0.13.3 // indirect
|
||||||
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||||
github.com/99designs/keyring v1.2.1 // indirect
|
github.com/99designs/keyring v1.2.2 // indirect
|
||||||
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
|
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
|
||||||
github.com/DataDog/zstd v1.5.5 // indirect
|
github.com/DataDog/zstd v1.5.5 // indirect
|
||||||
|
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||||
github.com/agnivade/levenshtein v1.1.1 // indirect
|
github.com/agnivade/levenshtein v1.1.1 // indirect
|
||||||
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
|
github.com/bgentry/speakeasy v0.2.0 // indirect
|
||||||
github.com/bits-and-blooms/bitset v1.10.0 // indirect
|
github.com/bits-and-blooms/bitset v1.10.0 // indirect
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
|
||||||
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
|
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
|
||||||
github.com/cespare/xxhash v1.1.0 // indirect
|
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/chzyer/readline v1.5.1 // indirect
|
github.com/chzyer/readline v1.5.1 // indirect
|
||||||
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
|
github.com/cockroachdb/errors v1.11.3 // indirect
|
||||||
github.com/cockroachdb/errors v1.11.1 // indirect
|
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
|
||||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
||||||
github.com/cockroachdb/pebble v1.1.0 // indirect
|
github.com/cockroachdb/pebble v1.1.2 // indirect
|
||||||
github.com/cockroachdb/redact v1.1.5 // indirect
|
github.com/cockroachdb/redact v1.1.5 // indirect
|
||||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
||||||
github.com/cometbft/cometbft-db v0.9.1 // indirect
|
github.com/cometbft/cometbft-db v1.0.1 // indirect
|
||||||
github.com/cosmos/btcutil v1.0.5 // indirect
|
github.com/cosmos/btcutil v1.0.5 // indirect
|
||||||
|
github.com/cosmos/crypto v0.1.2 // indirect
|
||||||
github.com/cosmos/gogogateway v1.2.0 // indirect
|
github.com/cosmos/gogogateway v1.2.0 // indirect
|
||||||
github.com/cosmos/iavl v1.0.0 // indirect
|
github.com/cosmos/iavl v1.3.0 // indirect
|
||||||
github.com/cosmos/ics23/go v0.10.0 // indirect
|
github.com/cosmos/ics23/go v0.11.0 // indirect
|
||||||
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
|
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
|
||||||
github.com/creachadair/atomicfile v0.3.1 // indirect
|
github.com/creachadair/atomicfile v0.3.5 // indirect
|
||||||
github.com/creachadair/tomledit v0.0.24 // indirect
|
github.com/creachadair/tomledit v0.0.26 // indirect
|
||||||
github.com/danieljoos/wincred v1.1.2 // indirect
|
github.com/danieljoos/wincred v1.2.1 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
|
||||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
|
github.com/dgraph-io/badger/v4 v4.3.0 // indirect
|
||||||
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
|
github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 // indirect
|
||||||
github.com/dgraph-io/ristretto v0.1.1 // indirect
|
|
||||||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
|
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
|
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
|
||||||
github.com/emicklei/dot v1.6.0 // indirect
|
github.com/emicklei/dot v1.6.2 // indirect
|
||||||
github.com/fatih/color v1.16.0 // indirect
|
github.com/fatih/color v1.17.0 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.2 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||||
github.com/getsentry/sentry-go v0.25.0 // indirect
|
github.com/getsentry/sentry-go v0.27.0 // indirect
|
||||||
github.com/go-kit/kit v0.12.0 // indirect
|
github.com/go-kit/kit v0.13.0 // indirect
|
||||||
github.com/go-kit/log v0.2.1 // indirect
|
github.com/go-kit/log v0.2.1 // indirect
|
||||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
||||||
github.com/gogo/googleapis v1.4.1 // indirect
|
github.com/gogo/googleapis v1.4.1 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/glog v1.2.0 // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
github.com/golang/mock v1.6.0 // indirect
|
github.com/golang/mock v1.6.0 // indirect
|
||||||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
|
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
|
||||||
github.com/google/btree v1.1.2 // indirect
|
github.com/google/btree v1.1.3 // indirect
|
||||||
|
github.com/google/flatbuffers v2.0.8+incompatible // indirect
|
||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/orderedcode v0.0.1 // indirect
|
github.com/google/orderedcode v0.0.1 // indirect
|
||||||
github.com/gorilla/handlers v1.5.1 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/gorilla/mux v1.8.0 // indirect
|
github.com/gorilla/handlers v1.5.2 // indirect
|
||||||
github.com/gorilla/websocket v1.5.0 // indirect
|
github.com/gorilla/mux v1.8.1 // indirect
|
||||||
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
|
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
|
||||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
||||||
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
github.com/hashicorp/go-hclog v1.6.3 // indirect
|
||||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||||
github.com/hashicorp/go-metrics v0.5.1 // indirect
|
github.com/hashicorp/go-metrics v0.5.3 // indirect
|
||||||
github.com/hashicorp/go-plugin v1.5.2 // indirect
|
github.com/hashicorp/go-plugin v1.6.1 // indirect
|
||||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||||
|
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||||
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
|
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
|
||||||
github.com/holiman/uint256 v1.2.4 // indirect
|
github.com/holiman/uint256 v1.2.4 // indirect
|
||||||
github.com/huandu/skiplist v1.2.0 // indirect
|
github.com/huandu/skiplist v1.2.1 // indirect
|
||||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||||
github.com/improbable-eng/grpc-web v0.15.0 // indirect
|
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||||
github.com/klauspost/compress v1.17.4 // indirect
|
github.com/klauspost/compress v1.17.9 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||||
github.com/kr/pretty v0.3.1 // indirect
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/lib/pq v1.10.7 // indirect
|
github.com/lib/pq v1.10.9 // indirect
|
||||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
github.com/linxGnu/grocksdb v1.9.3 // indirect
|
||||||
github.com/linxGnu/grocksdb v1.8.6 // indirect
|
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||||
github.com/magiconair/properties v1.8.7 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/manifoldco/promptui v0.9.0 // indirect
|
github.com/manifoldco/promptui v0.9.0 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||||
github.com/minio/highwayhash v1.0.2 // indirect
|
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||||
|
github.com/mdp/qrterminal/v3 v3.2.0 // indirect
|
||||||
|
github.com/minio/highwayhash v1.0.3 // indirect
|
||||||
github.com/minio/sha256-simd v1.0.1 // indirect
|
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||||
github.com/mtibben/percent v0.2.1 // indirect
|
github.com/mtibben/percent v0.2.1 // indirect
|
||||||
|
github.com/muesli/termenv v0.15.2 // indirect
|
||||||
github.com/multiformats/go-base32 v0.1.0 // indirect
|
github.com/multiformats/go-base32 v0.1.0 // indirect
|
||||||
github.com/multiformats/go-base36 v0.2.0 // indirect
|
github.com/multiformats/go-base36 v0.2.0 // indirect
|
||||||
github.com/multiformats/go-multibase v0.2.0 // indirect
|
github.com/multiformats/go-multibase v0.2.0 // indirect
|
||||||
github.com/multiformats/go-multihash v0.2.3 // indirect
|
github.com/multiformats/go-multihash v0.2.3 // indirect
|
||||||
github.com/multiformats/go-varint v0.0.7 // indirect
|
github.com/multiformats/go-varint v0.0.7 // indirect
|
||||||
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
|
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
|
||||||
github.com/oklog/run v1.1.0 // indirect
|
github.com/oklog/run v1.1.0 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||||
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
|
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||||
github.com/polydawn/refmt v0.89.0 // indirect
|
github.com/polydawn/refmt v0.89.0 // indirect
|
||||||
github.com/prometheus/client_golang v1.17.0 // indirect
|
github.com/prometheus/client_golang v1.20.5 // indirect
|
||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
github.com/prometheus/common v0.45.0 // indirect
|
github.com/prometheus/common v0.60.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.15.1 // indirect
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
github.com/rs/zerolog v1.31.0 // indirect
|
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||||
github.com/sagikazarmark/locafero v0.3.0 // indirect
|
github.com/rs/zerolog v1.33.0 // indirect
|
||||||
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||||
github.com/sasha-s/go-deadlock v0.3.1 // indirect
|
github.com/sasha-s/go-deadlock v0.3.5 // indirect
|
||||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
github.com/spf13/afero v1.10.0 // indirect
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
github.com/spf13/cast v1.5.1 // indirect
|
github.com/spf13/cast v1.7.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/subosito/gotenv v1.6.0 // indirect
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
|
github.com/supranational/blst v0.3.13 // indirect
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||||
github.com/tendermint/go-amino v0.16.0 // indirect
|
github.com/tendermint/go-amino v0.16.0 // indirect
|
||||||
github.com/tidwall/btree v1.7.0 // indirect
|
github.com/tidwall/btree v1.7.0 // indirect
|
||||||
github.com/zondax/hid v0.9.2 // indirect
|
github.com/zondax/hid v0.9.2 // indirect
|
||||||
github.com/zondax/ledger-go v0.14.3 // indirect
|
github.com/zondax/ledger-go v0.14.3 // indirect
|
||||||
go.etcd.io/bbolt v1.3.8 // indirect
|
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b // indirect
|
||||||
|
gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect
|
||||||
|
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
|
||||||
|
go.opencensus.io v0.24.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
golang.org/x/crypto v0.22.0 // indirect
|
golang.org/x/crypto v0.28.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
|
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
|
||||||
golang.org/x/net v0.24.0 // indirect
|
golang.org/x/net v0.29.0 // indirect
|
||||||
golang.org/x/sys v0.20.0 // indirect
|
golang.org/x/sys v0.26.0 // indirect
|
||||||
golang.org/x/term v0.19.0 // indirect
|
golang.org/x/term v0.25.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.19.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect
|
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
|
||||||
gotest.tools/v3 v3.5.1 // indirect
|
gotest.tools/v3 v3.5.1 // indirect
|
||||||
lukechampine.com/blake3 v1.2.1 // indirect
|
lukechampine.com/blake3 v1.2.1 // indirect
|
||||||
nhooyr.io/websocket v1.8.6 // indirect
|
|
||||||
pgregory.net/rapid v1.1.0 // indirect
|
pgregory.net/rapid v1.1.0 // indirect
|
||||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
rsc.io/qr v0.2.0 // indirect
|
||||||
|
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/statechannels/go-nitro v0.1.2 => github.com/cerc-io/go-nitro v0.1.3-ts-port-0.1.10
|
replace github.com/statechannels/go-nitro v0.1.2 => github.com/cerc-io/go-nitro v0.1.3-ts-port-0.1.10
|
||||||
|
|
||||||
|
// replace (
|
||||||
|
// cosmossdk.io/core v0.7.6 => github.com/roysc/cosmos-sdk/core v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/api v0.7.6 => github.com/roysc/cosmos-sdk/api v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/client/v2 => github.com/roysc/cosmos-sdk/client/v2 v2.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/store => github.com/roysc/cosmos-sdk/store v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/x/bank => github.com/roysc/cosmos-sdk/x/bank v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/x/mint => github.com/roysc/cosmos-sdk/x/mint v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/x/gov => github.com/roysc/cosmos-sdk/x/gov v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/x/staking => github.com/roysc/cosmos-sdk/x/staking v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/x/tx => github.com/roysc/cosmos-sdk/x/tx v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// cosmossdk.io/x/epochs => github.com/roysc/cosmos-sdk/x/epochs v0.0.0-20241001191620-a3729c1ad6ba
|
||||||
|
// github.com/cosmos/cosmos-sdk => github.com/roysc/cosmos-sdk v1.0.0-dev
|
||||||
|
// )
|
||||||
|
|
||||||
|
// dev
|
||||||
|
replace (
|
||||||
|
// cosmossdk.io/core => ../cosmos-sdk/core
|
||||||
|
cosmossdk.io/api => ../cosmos-sdk/api
|
||||||
|
cosmossdk.io/client/v2 => ../cosmos-sdk/client/v2
|
||||||
|
cosmossdk.io/runtime/v2 => ../cosmos-sdk/runtime/v2
|
||||||
|
cosmossdk.io/server/v2 => ../cosmos-sdk/server/v2
|
||||||
|
cosmossdk.io/server/v2/appmanager => ../cosmos-sdk/server/v2/appmanager
|
||||||
|
cosmossdk.io/server/v2/stf => ../cosmos-sdk/server/v2/stf
|
||||||
|
cosmossdk.io/store => ../cosmos-sdk/store
|
||||||
|
cosmossdk.io/store/v2 => ../cosmos-sdk/store/v2
|
||||||
|
cosmossdk.io/x/accounts => ../cosmos-sdk/x/accounts
|
||||||
|
cosmossdk.io/x/bank => ../cosmos-sdk/x/bank
|
||||||
|
cosmossdk.io/x/consensus => ../cosmos-sdk/x/consensus
|
||||||
|
cosmossdk.io/x/distribution => ../cosmos-sdk/x/distribution
|
||||||
|
cosmossdk.io/x/epochs => ../cosmos-sdk/x/epochs
|
||||||
|
cosmossdk.io/x/gov => ../cosmos-sdk/x/gov
|
||||||
|
cosmossdk.io/x/mint => ../cosmos-sdk/x/mint
|
||||||
|
cosmossdk.io/x/params => ../cosmos-sdk/x/params
|
||||||
|
cosmossdk.io/x/protocolpool => ../cosmos-sdk/x/protocolpool
|
||||||
|
cosmossdk.io/x/slashing => ../cosmos-sdk/x/slashing
|
||||||
|
cosmossdk.io/x/staking => ../cosmos-sdk/x/staking
|
||||||
|
cosmossdk.io/x/tx => ../cosmos-sdk/x/tx
|
||||||
|
github.com/cometbft/cometbft => ../cometbft
|
||||||
|
github.com/cosmos/cosmos-sdk => ../cosmos-sdk
|
||||||
|
)
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
types "github.com/cosmos/cosmos-sdk/types"
|
types "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/query"
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
banktypes "cosmossdk.io/x/bank/types"
|
||||||
|
|
||||||
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
|
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
@ -17,6 +16,7 @@ import (
|
|||||||
|
|
||||||
laconictestcli "git.vdb.to/cerc-io/laconicd/testutil/cli"
|
laconictestcli "git.vdb.to/cerc-io/laconicd/testutil/cli"
|
||||||
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
||||||
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
types "git.vdb.to/cerc-io/laconicd/x/auction"
|
types "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/auction/client/cli"
|
"git.vdb.to/cerc-io/laconicd/x/auction/client/cli"
|
||||||
)
|
)
|
||||||
@ -80,7 +80,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
|||||||
val.Address,
|
val.Address,
|
||||||
newAddr,
|
newAddr,
|
||||||
sdk.NewCoins(sdk.NewCoin(ets.cfg.BondDenom, math.NewInt(200000))),
|
sdk.NewCoins(sdk.NewCoin(ets.cfg.BondDenom, math.NewInt(200000))),
|
||||||
addresscodec.NewBech32Codec("laconic"),
|
utils.NewAddressCodec(),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
|
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
@ -15,6 +14,7 @@ import (
|
|||||||
|
|
||||||
laconictestcli "git.vdb.to/cerc-io/laconicd/testutil/cli"
|
laconictestcli "git.vdb.to/cerc-io/laconicd/testutil/cli"
|
||||||
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
||||||
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/bond/client/cli"
|
"git.vdb.to/cerc-io/laconicd/x/bond/client/cli"
|
||||||
)
|
)
|
||||||
@ -68,7 +68,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
|||||||
val.Address,
|
val.Address,
|
||||||
newAddr,
|
newAddr,
|
||||||
sdk.NewCoins(sdk.NewCoin(ets.cfg.BondDenom, math.NewInt(200000))),
|
sdk.NewCoins(sdk.NewCoin(ets.cfg.BondDenom, math.NewInt(200000))),
|
||||||
addresscodec.NewBech32Codec("laconic"),
|
utils.NewAddressCodec(),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||||
|
@ -6,16 +6,16 @@ import (
|
|||||||
|
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||||
|
"cosmossdk.io/x/bank"
|
||||||
|
"cosmossdk.io/x/staking"
|
||||||
dbm "github.com/cosmos/cosmos-db"
|
dbm "github.com/cosmos/cosmos-db"
|
||||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
|
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
|
||||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module/testutil"
|
"github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
|
||||||
|
|
||||||
laconicApp "git.vdb.to/cerc-io/laconicd/app"
|
laconicApp "git.vdb.to/cerc-io/laconicd/app"
|
||||||
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
||||||
@ -58,9 +58,10 @@ func NewTestNetworkFixture() network.TestFixture {
|
|||||||
AppConstructor: appCtr,
|
AppConstructor: appCtr,
|
||||||
GenesisState: app.DefaultGenesis(),
|
GenesisState: app.DefaultGenesis(),
|
||||||
EncodingConfig: testutil.MakeTestEncodingConfig(
|
EncodingConfig: testutil.MakeTestEncodingConfig(
|
||||||
auth.AppModuleBasic{},
|
codectestutil.CodecOptions{},
|
||||||
bank.AppModuleBasic{},
|
auth.AppModule{},
|
||||||
staking.AppModuleBasic{},
|
bank.AppModule{},
|
||||||
|
staking.AppModule{},
|
||||||
auctionmodule.AppModule{},
|
auctionmodule.AppModule{},
|
||||||
bondmodule.AppModule{},
|
bondmodule.AppModule{},
|
||||||
registrymodule.AppModule{},
|
registrymodule.AppModule{},
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
|
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
@ -17,6 +16,7 @@ import (
|
|||||||
|
|
||||||
laconictestcli "git.vdb.to/cerc-io/laconicd/testutil/cli"
|
laconictestcli "git.vdb.to/cerc-io/laconicd/testutil/cli"
|
||||||
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
||||||
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
bondcli "git.vdb.to/cerc-io/laconicd/x/bond/client/cli"
|
bondcli "git.vdb.to/cerc-io/laconicd/x/bond/client/cli"
|
||||||
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
@ -87,7 +87,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
|||||||
val.Address,
|
val.Address,
|
||||||
newAddr,
|
newAddr,
|
||||||
sdk.NewCoins(sdk.NewCoin(ets.cfg.BondDenom, math.NewInt(100000000))),
|
sdk.NewCoins(sdk.NewCoin(ets.cfg.BondDenom, math.NewInt(100000000))),
|
||||||
addresscodec.NewBech32Codec("laconic"),
|
utils.NewAddressCodec(),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||||
|
@ -6,8 +6,12 @@ import (
|
|||||||
"cosmossdk.io/core/appmodule"
|
"cosmossdk.io/core/appmodule"
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
storetypes "cosmossdk.io/store/types"
|
storetypes "cosmossdk.io/store/types"
|
||||||
cmtprototypes "github.com/cometbft/cometbft/proto/tendermint/types"
|
cmtprototypes "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||||
|
|
||||||
|
"cosmossdk.io/x/bank"
|
||||||
|
bankkeeper "cosmossdk.io/x/bank/keeper"
|
||||||
|
banktypes "cosmossdk.io/x/bank/types"
|
||||||
|
minttypes "cosmossdk.io/x/mint/types"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
|
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
|
||||||
"github.com/cosmos/cosmos-sdk/runtime"
|
"github.com/cosmos/cosmos-sdk/runtime"
|
||||||
@ -18,10 +22,6 @@ import (
|
|||||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
|
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
|
||||||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
||||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
|
||||||
|
|
||||||
auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
||||||
|
@ -30,6 +30,12 @@ import (
|
|||||||
"cosmossdk.io/math/unsafe"
|
"cosmossdk.io/math/unsafe"
|
||||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||||
|
|
||||||
|
_ "cosmossdk.io/x/bank" // import bank as a blank
|
||||||
|
banktypes "cosmossdk.io/x/bank/types"
|
||||||
|
_ "cosmossdk.io/x/consensus" // import consensus as a blank
|
||||||
|
_ "cosmossdk.io/x/params" // import params as a blank
|
||||||
|
_ "cosmossdk.io/x/staking" // import staking as a blank
|
||||||
|
stakingtypes "cosmossdk.io/x/staking/types"
|
||||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
@ -53,13 +59,7 @@ import (
|
|||||||
_ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank
|
_ "github.com/cosmos/cosmos-sdk/x/auth" // import auth as a blank
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank
|
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import auth tx config as a blank
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/bank" // import bank as a blank
|
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank
|
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// package-wide network lock to only allow one test network at a time
|
// package-wide network lock to only allow one test network at a time
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
|
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
|
||||||
servercmtlog "github.com/cosmos/cosmos-sdk/server/log"
|
servercmtlog "github.com/cosmos/cosmos-sdk/server/log"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
banktypes "cosmossdk.io/x/bank/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
)
|
)
|
||||||
|
50
utils/address.go
Normal file
50
utils/address.go
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"cosmossdk.io/core/address"
|
||||||
|
errorsmod "cosmossdk.io/errors"
|
||||||
|
|
||||||
|
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
|
||||||
|
_ "git.vdb.to/cerc-io/laconicd/app/params" // import for side-effects
|
||||||
|
)
|
||||||
|
|
||||||
|
type addressCodec struct {
|
||||||
|
bech32codec address.Codec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ac addressCodec) StringToBytes(text string) ([]byte, error) {
|
||||||
|
bz, err := ac.bech32codec.StringToBytes(text)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(bz) != 20 && len(bz) != 32 {
|
||||||
|
return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress,
|
||||||
|
"address length must be 20 or 32 bz, got %d", len(bz))
|
||||||
|
}
|
||||||
|
return bz, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ac addressCodec) BytesToString(bz []byte) (string, error) {
|
||||||
|
return ac.bech32codec.BytesToString(bz)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAddressCodec() address.Codec {
|
||||||
|
return addressCodec{
|
||||||
|
bech32codec: addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewValAddressCodec() address.ValidatorAddressCodec {
|
||||||
|
return addressCodec{
|
||||||
|
bech32codec: addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConsAddressCodec() address.ConsensusAddressCodec {
|
||||||
|
return addressCodec{
|
||||||
|
bech32codec: addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
|
||||||
|
}
|
||||||
|
}
|
@ -84,7 +84,7 @@ func GetCmdCommitBid() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save reveal file.
|
// Save reveal file.
|
||||||
err = os.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600)
|
err = os.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.FromName, commitHash), content, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package auction
|
package auction
|
||||||
|
|
||||||
import (
|
import (
|
||||||
types "github.com/cosmos/cosmos-sdk/codec/types"
|
"cosmossdk.io/core/registry"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterInterfaces registers the interfaces types with the interface registry.
|
// RegisterInterfaces registers the interfaces types with the interface registry.
|
||||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
func RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||||
&MsgCreateAuction{},
|
&MsgCreateAuction{},
|
||||||
&MsgCommitBid{},
|
&MsgCommitBid{},
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
"context"
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/x/auction"
|
"git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitGenesis initializes the module state from a genesis state.
|
// InitGenesis initializes the module state from a genesis state.
|
||||||
func (k *Keeper) InitGenesis(ctx sdk.Context, data *auction.GenesisState) error {
|
func (k *Keeper) InitGenesis(ctx context.Context, data *auction.GenesisState) error {
|
||||||
if err := k.Params.Set(ctx, data.Params); err != nil {
|
if err := k.Params.Set(ctx, data.Params); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *auction.GenesisState) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ExportGenesis exports the module state to a genesis state.
|
// ExportGenesis exports the module state to a genesis state.
|
||||||
func (k *Keeper) ExportGenesis(ctx sdk.Context) (*auction.GenesisState, error) {
|
func (k *Keeper) ExportGenesis(ctx context.Context) (*auction.GenesisState, error) {
|
||||||
params, err := k.Params.Get(ctx)
|
params, err := k.Params.Get(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@ -15,13 +16,13 @@ import (
|
|||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
"cosmossdk.io/math"
|
"cosmossdk.io/math"
|
||||||
|
|
||||||
|
bank "cosmossdk.io/x/bank/keeper"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
||||||
|
|
||||||
wnsUtils "git.vdb.to/cerc-io/laconicd/utils"
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -231,7 +232,7 @@ func (k Keeper) GetBids(ctx sdk.Context, id string) ([]*auctiontypes.Bid, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListAuctions - get all auctions.
|
// ListAuctions - get all auctions.
|
||||||
func (k Keeper) ListAuctions(ctx sdk.Context) ([]auctiontypes.Auction, error) {
|
func (k Keeper) ListAuctions(ctx context.Context) ([]auctiontypes.Auction, error) {
|
||||||
iter, err := k.Auctions.Iterate(ctx, nil)
|
iter, err := k.Auctions.Iterate(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -319,7 +320,7 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := utils.NewAddressCodec().StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -327,11 +328,11 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction
|
|||||||
// Generate auction Id.
|
// Generate auction Id.
|
||||||
account := k.accountKeeper.GetAccount(ctx, signerAddress)
|
account := k.accountKeeper.GetAccount(ctx, signerAddress)
|
||||||
if account == nil {
|
if account == nil {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "Account not found.")
|
return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, msg.Signer)
|
||||||
}
|
}
|
||||||
|
|
||||||
auctionId := auctiontypes.AuctionId{
|
auctionId := auctiontypes.AuctionId{
|
||||||
Address: signerAddress,
|
Address: sdk.AccAddress(signerAddress),
|
||||||
AccNum: account.GetAccountNumber(),
|
AccNum: account.GetAccountNumber(),
|
||||||
Sequence: account.GetSequence(),
|
Sequence: account.GetSequence(),
|
||||||
}.Generate()
|
}.Generate()
|
||||||
@ -354,7 +355,7 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction
|
|||||||
Id: auctionId,
|
Id: auctionId,
|
||||||
Kind: msg.Kind,
|
Kind: msg.Kind,
|
||||||
Status: auctiontypes.AuctionStatusCommitPhase,
|
Status: auctiontypes.AuctionStatusCommitPhase,
|
||||||
OwnerAddress: signerAddress.String(),
|
OwnerAddress: msg.Signer,
|
||||||
CreateTime: now,
|
CreateTime: now,
|
||||||
CommitsEndTime: commitsEndTime,
|
CommitsEndTime: commitsEndTime,
|
||||||
RevealsEndTime: revealsEndTime,
|
RevealsEndTime: revealsEndTime,
|
||||||
@ -390,7 +391,8 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg auctiontypes.MsgCommitBid) (*auct
|
|||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in commit phase.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in commit phase.")
|
||||||
}
|
}
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
signerAddress, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -403,14 +405,13 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg auctiontypes.MsgCommitBid) (*auct
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if an old bid already exists, if so, return old bids auction fee (update bid scenario).
|
// Check if an old bid already exists, if so, return old bids auction fee (update bid scenario).
|
||||||
bidder := signerAddress.String()
|
bidExists, err := k.HasBid(ctx, msg.AuctionId, msg.Signer)
|
||||||
bidExists, err := k.HasBid(ctx, msg.AuctionId, bidder)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if bidExists {
|
if bidExists {
|
||||||
oldBid, err := k.GetBid(ctx, msg.AuctionId, bidder)
|
oldBid, err := k.GetBid(ctx, msg.AuctionId, msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -425,7 +426,7 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg auctiontypes.MsgCommitBid) (*auct
|
|||||||
// Save new bid.
|
// Save new bid.
|
||||||
bid := auctiontypes.Bid{
|
bid := auctiontypes.Bid{
|
||||||
AuctionId: msg.AuctionId,
|
AuctionId: msg.AuctionId,
|
||||||
BidderAddress: bidder,
|
BidderAddress: msg.Signer,
|
||||||
Status: auctiontypes.BidStatusCommitted,
|
Status: auctiontypes.BidStatusCommitted,
|
||||||
CommitHash: msg.CommitHash,
|
CommitHash: msg.CommitHash,
|
||||||
CommitTime: ctx.BlockTime(),
|
CommitTime: ctx.BlockTime(),
|
||||||
@ -457,13 +458,13 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct
|
|||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in reveal phase.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in reveal phase.")
|
||||||
}
|
}
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
signerAddress, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
bidder := signerAddress.String()
|
bidExists, err := k.HasBid(ctx, msg.AuctionId, msg.Signer)
|
||||||
bidExists, err := k.HasBid(ctx, msg.AuctionId, bidder)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -472,7 +473,7 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct
|
|||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid not found.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid not found.")
|
||||||
}
|
}
|
||||||
|
|
||||||
bid, err := k.GetBid(ctx, msg.AuctionId, bidder)
|
bid, err := k.GetBid(ctx, msg.AuctionId, msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -486,7 +487,7 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct
|
|||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal string.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal string.")
|
||||||
}
|
}
|
||||||
|
|
||||||
cid, err := wnsUtils.CIDFromJSONBytes(revealBytes)
|
cid, err := utils.CIDFromJSONBytes(revealBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON.")
|
||||||
}
|
}
|
||||||
@ -501,26 +502,26 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct
|
|||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal JSON unmarshal error.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal JSON unmarshal error.")
|
||||||
}
|
}
|
||||||
|
|
||||||
chainId, err := wnsUtils.GetAttributeAsString(reveal, "chainId")
|
chainId, err := utils.GetAttributeAsString(reveal, "chainId")
|
||||||
if err != nil || chainId != ctx.ChainID() {
|
if err != nil || chainId != ctx.ChainID() {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal chainID.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal chainID.")
|
||||||
}
|
}
|
||||||
|
|
||||||
auctionId, err := wnsUtils.GetAttributeAsString(reveal, "auctionId")
|
auctionId, err := utils.GetAttributeAsString(reveal, "auctionId")
|
||||||
if err != nil || auctionId != msg.AuctionId {
|
if err != nil || auctionId != msg.AuctionId {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal auction Id.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal auction Id.")
|
||||||
}
|
}
|
||||||
|
|
||||||
bidderAddress, err := wnsUtils.GetAttributeAsString(reveal, "bidderAddress")
|
bidderAddress, err := utils.GetAttributeAsString(reveal, "bidderAddress")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid address.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid address.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if bidderAddress != signerAddress.String() {
|
if bidderAddress != msg.Signer {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal bid address mismatch.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal bid address mismatch.")
|
||||||
}
|
}
|
||||||
|
|
||||||
bidAmountStr, err := wnsUtils.GetAttributeAsString(reveal, "bidAmount")
|
bidAmountStr, err := utils.GetAttributeAsString(reveal, "bidAmount")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.")
|
||||||
}
|
}
|
||||||
@ -732,8 +733,10 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
|
||||||
for _, bid := range bids {
|
for _, bid := range bids {
|
||||||
bidderAddress, err := sdk.AccAddressFromBech32(bid.BidderAddress)
|
bidderAddress, err := addrCodec.StringToBytes(bid.BidderAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
k.Logger(ctx).Error(fmt.Sprintf("Invalid bidderAddress address. %v", err))
|
k.Logger(ctx).Error(fmt.Sprintf("Invalid bidderAddress address. %v", err))
|
||||||
panic("Invalid bidder address.")
|
panic("Invalid bidder address.")
|
||||||
@ -758,7 +761,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction
|
|||||||
|
|
||||||
// Process winner account (if nobody bids, there won't be a winner).
|
// Process winner account (if nobody bids, there won't be a winner).
|
||||||
if len(auction.WinnerAddresses) != 0 {
|
if len(auction.WinnerAddresses) != 0 {
|
||||||
winnerAddress, err := sdk.AccAddressFromBech32(auction.WinnerAddresses[0])
|
winnerAddress, err := addrCodec.StringToBytes(auction.WinnerAddresses[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
k.Logger(ctx).Error(fmt.Sprintf("Invalid winner address. %v", err))
|
k.Logger(ctx).Error(fmt.Sprintf("Invalid winner address. %v", err))
|
||||||
panic("Invalid winner address.")
|
panic("Invalid winner address.")
|
||||||
@ -868,8 +871,10 @@ func (k Keeper) pickProviderAuctionWinners(ctx sdk.Context, auction *auctiontype
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
|
||||||
for _, bid := range bids {
|
for _, bid := range bids {
|
||||||
bidderAddress, err := sdk.AccAddressFromBech32(bid.BidderAddress)
|
bidderAddress, err := addrCodec.StringToBytes(bid.BidderAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
k.Logger(ctx).Error(fmt.Sprintf("Invalid bidderAddress address. %v", err))
|
k.Logger(ctx).Error(fmt.Sprintf("Invalid bidderAddress address. %v", err))
|
||||||
panic("Invalid bidder address.")
|
panic("Invalid bidder address.")
|
||||||
@ -891,7 +896,7 @@ func (k Keeper) pickProviderAuctionWinners(ctx sdk.Context, auction *auctiontype
|
|||||||
totalAmountPaid := auction.WinningPrice.Amount.Mul(math.NewInt(int64(len(auction.WinnerAddresses))))
|
totalAmountPaid := auction.WinningPrice.Amount.Mul(math.NewInt(int64(len(auction.WinnerAddresses))))
|
||||||
creatorLeftOverAmount := sdk.NewCoin(auction.MaxPrice.Denom, totalLockedAmount.Sub(totalAmountPaid))
|
creatorLeftOverAmount := sdk.NewCoin(auction.MaxPrice.Denom, totalLockedAmount.Sub(totalAmountPaid))
|
||||||
|
|
||||||
ownerAccAddress, err := sdk.AccAddressFromBech32(auction.OwnerAddress)
|
ownerAccAddress, err := addrCodec.StringToBytes(auction.OwnerAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
k.Logger(ctx).Error(fmt.Sprintf("Invalid auction owner address. %v", err))
|
k.Logger(ctx).Error(fmt.Sprintf("Invalid auction owner address. %v", err))
|
||||||
panic("Invalid auction owner address.")
|
panic("Invalid auction owner address.")
|
||||||
@ -947,9 +952,11 @@ func (k Keeper) ReleaseFunds(ctx sdk.Context, msg auctiontypes.MsgReleaseFunds)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
|
||||||
// Process winner accounts.
|
// Process winner accounts.
|
||||||
for _, winnerAddress := range auction.WinnerAddresses {
|
for _, winnerAddress := range auction.WinnerAddresses {
|
||||||
winnerAccAddress, err := sdk.AccAddressFromBech32(winnerAddress)
|
winnerAccAddress, err := addrCodec.StringToBytes(winnerAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
k.Logger(ctx).Error(fmt.Sprintf("Invalid winner address. %v", err))
|
k.Logger(ctx).Error(fmt.Sprintf("Invalid winner address. %v", err))
|
||||||
panic("Invalid winner address.")
|
panic("Invalid winner address.")
|
||||||
|
@ -4,10 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
errorsmod "cosmossdk.io/errors"
|
errorsmod "cosmossdk.io/errors"
|
||||||
|
govtypes "cosmossdk.io/x/gov/types"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/utils"
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ auctiontypes.MsgServer = msgServer{}
|
var _ auctiontypes.MsgServer = msgServer{}
|
||||||
@ -25,7 +26,8 @@ func (ms msgServer) CreateAuction(c context.Context, msg *auctiontypes.MsgCreate
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -46,7 +48,7 @@ func (ms msgServer) CreateAuction(c context.Context, msg *auctiontypes.MsgCreate
|
|||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
sdk.EventTypeMessage,
|
sdk.EventTypeMessage,
|
||||||
sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory),
|
sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory),
|
||||||
sdk.NewAttribute(auctiontypes.AttributeKeySigner, signerAddress.String()),
|
sdk.NewAttribute(auctiontypes.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -64,7 +66,8 @@ func (ms msgServer) CommitBid(c context.Context, msg *auctiontypes.MsgCommitBid)
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -83,7 +86,7 @@ func (ms msgServer) CommitBid(c context.Context, msg *auctiontypes.MsgCommitBid)
|
|||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
sdk.EventTypeMessage,
|
sdk.EventTypeMessage,
|
||||||
sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory),
|
sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory),
|
||||||
sdk.NewAttribute(auctiontypes.AttributeKeySigner, signerAddress.String()),
|
sdk.NewAttribute(auctiontypes.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -101,7 +104,8 @@ func (ms msgServer) RevealBid(c context.Context, msg *auctiontypes.MsgRevealBid)
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -120,7 +124,7 @@ func (ms msgServer) RevealBid(c context.Context, msg *auctiontypes.MsgRevealBid)
|
|||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
sdk.EventTypeMessage,
|
sdk.EventTypeMessage,
|
||||||
sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory),
|
sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory),
|
||||||
sdk.NewAttribute(auctiontypes.AttributeKeySigner, signerAddress.String()),
|
sdk.NewAttribute(auctiontypes.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -157,7 +161,8 @@ func (ms msgServer) ReleaseFunds(c context.Context, msg *auctiontypes.MsgRelease
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -175,7 +180,7 @@ func (ms msgServer) ReleaseFunds(c context.Context, msg *auctiontypes.MsgRelease
|
|||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
sdk.EventTypeMessage,
|
sdk.EventTypeMessage,
|
||||||
sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory),
|
sdk.NewAttribute(sdk.AttributeKeyModule, auctiontypes.AttributeValueCategory),
|
||||||
sdk.NewAttribute(auctiontypes.AttributeKeySigner, signerAddress.String()),
|
sdk.NewAttribute(auctiontypes.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -4,12 +4,12 @@ import (
|
|||||||
"cosmossdk.io/core/appmodule"
|
"cosmossdk.io/core/appmodule"
|
||||||
"cosmossdk.io/core/store"
|
"cosmossdk.io/core/store"
|
||||||
"cosmossdk.io/depinject"
|
"cosmossdk.io/depinject"
|
||||||
|
"cosmossdk.io/depinject/appconfig"
|
||||||
|
bank "cosmossdk.io/x/bank/keeper"
|
||||||
|
govtypes "cosmossdk.io/x/gov/types"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
|
|
||||||
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/auction/module/v1"
|
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/auction/module/v1"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/auction"
|
"git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
@ -25,10 +25,10 @@ func (am AppModule) IsOnePerModuleType() {}
|
|||||||
func (am AppModule) IsAppModule() {}
|
func (am AppModule) IsAppModule() {}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
appmodule.Register(
|
appconfig.RegisterModule(
|
||||||
&modulev1.Module{},
|
&modulev1.Module{},
|
||||||
appmodule.Provide(ProvideModule),
|
appconfig.Provide(ProvideModule),
|
||||||
appmodule.Invoke(InvokeSetAuctionHooks),
|
appconfig.Invoke(InvokeSetAuctionHooks),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,15 +5,15 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"cosmossdk.io/core/appmodule"
|
"cosmossdk.io/client/v2/autocli"
|
||||||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
appmodule "cosmossdk.io/core/appmodule/v2"
|
||||||
"github.com/spf13/cobra"
|
"cosmossdk.io/core/registry"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/x/auction"
|
"git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/auction/client/cli"
|
"git.vdb.to/cerc-io/laconicd/x/auction/client/cli"
|
||||||
@ -21,13 +21,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ module.AppModuleBasic = AppModule{}
|
|
||||||
_ appmodule.AppModule = AppModule{}
|
_ appmodule.AppModule = AppModule{}
|
||||||
_ module.HasGenesis = AppModule{}
|
_ appmodule.HasGenesis = AppModule{}
|
||||||
_ module.HasServices = AppModule{}
|
_ appmodule.HasConsensusVersion = AppModule{}
|
||||||
_ module.HasConsensusVersion = AppModule{}
|
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||||
_ appmodule.HasEndBlocker = AppModule{}
|
_ appmodule.HasEndBlocker = AppModule{}
|
||||||
|
|
||||||
|
_ module.HasGRPCGateway = AppModule{}
|
||||||
|
_ module.HasServices = AppModule{}
|
||||||
_ module.HasInvariants = AppModule{}
|
_ module.HasInvariants = AppModule{}
|
||||||
|
// _ module.HasAminoCodec = AppModule{} // TODO
|
||||||
|
|
||||||
|
_ autocli.HasCustomTxCommand = AppModule{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConsensusVersion defines the current module consensus version
|
// ConsensusVersion defines the current module consensus version
|
||||||
@ -46,18 +51,12 @@ func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAppModuleBasic(m AppModule) module.AppModuleBasic {
|
// module.AppModule
|
||||||
return module.CoreAppModuleBasicAdaptor(m.Name(), m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// module.AppModuleBasic
|
|
||||||
|
|
||||||
// Name returns the auction module's name.
|
// Name returns the auction module's name.
|
||||||
func (AppModule) Name() string { return auction.ModuleName }
|
func (AppModule) Name() string { return auction.ModuleName }
|
||||||
|
|
||||||
// RegisterLegacyAminoCodec registers the auction module's types on the LegacyAmino codec.
|
// module.HasGRPCGateway
|
||||||
// New modules do not need to support Amino.
|
|
||||||
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
|
|
||||||
|
|
||||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the auction module.
|
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the auction module.
|
||||||
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
||||||
@ -66,25 +65,29 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appmodule.HasRegisterInterfaces
|
||||||
|
|
||||||
// RegisterInterfaces registers interfaces and implementations of the auction module.
|
// RegisterInterfaces registers interfaces and implementations of the auction module.
|
||||||
func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||||
auction.RegisterInterfaces(registry)
|
auction.RegisterInterfaces(registry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appmodule.HasConsensusVersion
|
||||||
|
|
||||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||||
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||||
|
|
||||||
// module.HasGenesis
|
// module.HasGenesis
|
||||||
|
|
||||||
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
||||||
func (AppModule) DefaultGenesis(jsonCodec codec.JSONCodec) json.RawMessage {
|
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||||
return jsonCodec.MustMarshalJSON(auction.DefaultGenesisState())
|
return am.cdc.MustMarshalJSON(auction.DefaultGenesisState())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateGenesis performs genesis state validation for the module.
|
// ValidateGenesis performs genesis state validation for the module.
|
||||||
func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error {
|
func (am AppModule) ValidateGenesis(message json.RawMessage) error {
|
||||||
var data auction.GenesisState
|
var data auction.GenesisState
|
||||||
if err := cdc.UnmarshalJSON(message, &data); err != nil {
|
if err := am.cdc.UnmarshalJSON(message, &data); err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", auction.ModuleName, err)
|
return fmt.Errorf("failed to unmarshal %s genesis state: %w", auction.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,24 +96,25 @@ func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingCo
|
|||||||
|
|
||||||
// InitGenesis performs genesis initialization for the auction module.
|
// InitGenesis performs genesis initialization for the auction module.
|
||||||
// It returns no validator updates.
|
// It returns no validator updates.
|
||||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) error {
|
||||||
var genesisState auction.GenesisState
|
var genesisState auction.GenesisState
|
||||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
am.cdc.MustUnmarshalJSON(data, &genesisState)
|
||||||
|
|
||||||
if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
|
if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
|
||||||
panic(fmt.Sprintf("failed to initialize %s genesis state: %v", auction.ModuleName, err))
|
return fmt.Errorf("failed to initialize %s genesis state: %w", auction.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
||||||
// module.
|
// module.
|
||||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
|
||||||
gs, err := am.keeper.ExportGenesis(ctx)
|
gs, err := am.keeper.ExportGenesis(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to export %s genesis state: %v", auction.ModuleName, err))
|
return nil, fmt.Errorf("failed to export %s genesis state: %w", auction.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cdc.MustMarshalJSON(gs)
|
return am.cdc.MustMarshalJSON(gs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// module.HasServices
|
// module.HasServices
|
||||||
@ -133,6 +137,8 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
|||||||
keeper.RegisterInvariants(ir, am.keeper)
|
keeper.RegisterInvariants(ir, am.keeper)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// autocli.HasCustomTxCommand
|
||||||
|
|
||||||
// Get the root tx command of this module
|
// Get the root tx command of this module
|
||||||
func (AppModule) GetTxCmd() *cobra.Command {
|
func (AppModule) GetTxCmd() *cobra.Command {
|
||||||
return cli.GetTxCmd()
|
return cli.GetTxCmd()
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package bond
|
package bond
|
||||||
|
|
||||||
import (
|
import (
|
||||||
types "github.com/cosmos/cosmos-sdk/codec/types"
|
"cosmossdk.io/core/registry"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterInterfaces registers the interfaces types with the interface registry.
|
// RegisterInterfaces registers the interfaces types with the interface registry.
|
||||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
func RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||||
&MsgCreateBond{},
|
&MsgCreateBond{},
|
||||||
&MsgRefillBond{},
|
&MsgRefillBond{},
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package bond
|
package bond
|
||||||
|
|
||||||
import (
|
import context "context"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// BondUsageKeeper keep track of bond usage in other modules.
|
// BondUsageKeeper keep track of bond usage in other modules.
|
||||||
// Used to, for example, prevent deletion of a bond that's in use.
|
// Used to, for example, prevent deletion of a bond that's in use.
|
||||||
type BondUsageKeeper interface {
|
type BondUsageKeeper interface {
|
||||||
ModuleName() string
|
ModuleName() string
|
||||||
UsesBond(ctx sdk.Context, bondId string) bool
|
UsesBond(ctx context.Context, bondId string) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// BondHooksWrapper is a wrapper for modules to inject BondUsageKeeper using depinject.
|
// BondHooksWrapper is a wrapper for modules to inject BondUsageKeeper using depinject.
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/x/bond"
|
"git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitGenesis initializes the module state from a genesis state.
|
// InitGenesis initializes the module state from a genesis state.
|
||||||
func (k *Keeper) InitGenesis(ctx sdk.Context, data *bond.GenesisState) error {
|
func (k *Keeper) InitGenesis(ctx context.Context, data *bond.GenesisState) error {
|
||||||
if err := k.Params.Set(ctx, data.Params); err != nil {
|
if err := k.Params.Set(ctx, data.Params); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -22,7 +23,7 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *bond.GenesisState) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ExportGenesis exports the module state to a genesis state.
|
// ExportGenesis exports the module state to a genesis state.
|
||||||
func (k *Keeper) ExportGenesis(ctx sdk.Context) (*bond.GenesisState, error) {
|
func (k *Keeper) ExportGenesis(ctx context.Context) (*bond.GenesisState, error) {
|
||||||
params, err := k.Params.Get(ctx)
|
params, err := k.Params.Get(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
@ -12,11 +13,11 @@ import (
|
|||||||
errorsmod "cosmossdk.io/errors"
|
errorsmod "cosmossdk.io/errors"
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
|
|
||||||
|
bank "cosmossdk.io/x/bank/keeper"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
||||||
|
|
||||||
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
)
|
)
|
||||||
@ -119,13 +120,14 @@ type BondId struct {
|
|||||||
// Generate creates the bond Id.
|
// Generate creates the bond Id.
|
||||||
func (bondId BondId) Generate() string {
|
func (bondId BondId) Generate() string {
|
||||||
hasher := sha256.New()
|
hasher := sha256.New()
|
||||||
|
// TODO use address.codec
|
||||||
str := fmt.Sprintf("%s:%d:%d", bondId.Address.String(), bondId.AccNum, bondId.Sequence)
|
str := fmt.Sprintf("%s:%d:%d", bondId.Address.String(), bondId.AccNum, bondId.Sequence)
|
||||||
hasher.Write([]byte(str))
|
hasher.Write([]byte(str))
|
||||||
return hex.EncodeToString(hasher.Sum(nil))
|
return hex.EncodeToString(hasher.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasBond - checks if a bond by the given Id exists.
|
// HasBond - checks if a bond by the given Id exists.
|
||||||
func (k Keeper) HasBond(ctx sdk.Context, id string) (bool, error) {
|
func (k Keeper) HasBond(ctx context.Context, id string) (bool, error) {
|
||||||
has, err := k.Bonds.Has(ctx, id)
|
has, err := k.Bonds.Has(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -135,17 +137,17 @@ func (k Keeper) HasBond(ctx sdk.Context, id string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SaveBond - saves a bond to the store.
|
// SaveBond - saves a bond to the store.
|
||||||
func (k Keeper) SaveBond(ctx sdk.Context, bond *bondtypes.Bond) error {
|
func (k Keeper) SaveBond(ctx context.Context, bond *bondtypes.Bond) error {
|
||||||
return k.Bonds.Set(ctx, bond.Id, *bond)
|
return k.Bonds.Set(ctx, bond.Id, *bond)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteBond - deletes the bond.
|
// DeleteBond - deletes the bond.
|
||||||
func (k Keeper) DeleteBond(ctx sdk.Context, bond bondtypes.Bond) error {
|
func (k Keeper) DeleteBond(ctx context.Context, bond bondtypes.Bond) error {
|
||||||
return k.Bonds.Remove(ctx, bond.Id)
|
return k.Bonds.Remove(ctx, bond.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListBonds - get all bonds.
|
// ListBonds - get all bonds.
|
||||||
func (k Keeper) ListBonds(ctx sdk.Context) ([]*bondtypes.Bond, error) {
|
func (k Keeper) ListBonds(ctx context.Context) ([]*bondtypes.Bond, error) {
|
||||||
var bonds []*bondtypes.Bond
|
var bonds []*bondtypes.Bond
|
||||||
|
|
||||||
iter, err := k.Bonds.Iterate(ctx, nil)
|
iter, err := k.Bonds.Iterate(ctx, nil)
|
||||||
@ -165,7 +167,7 @@ func (k Keeper) ListBonds(ctx sdk.Context) ([]*bondtypes.Bond, error) {
|
|||||||
return bonds, nil
|
return bonds, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) GetBondById(ctx sdk.Context, id string) (bondtypes.Bond, error) {
|
func (k Keeper) GetBondById(ctx context.Context, id string) (bondtypes.Bond, error) {
|
||||||
bond, err := k.Bonds.Get(ctx, id)
|
bond, err := k.Bonds.Get(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, collections.ErrNotFound) {
|
if errors.Is(err, collections.ErrNotFound) {
|
||||||
@ -177,7 +179,7 @@ func (k Keeper) GetBondById(ctx sdk.Context, id string) (bondtypes.Bond, error)
|
|||||||
return bond, nil
|
return bond, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) GetBondsByOwner(ctx sdk.Context, owner string) ([]bondtypes.Bond, error) {
|
func (k Keeper) GetBondsByOwner(ctx context.Context, owner string) ([]bondtypes.Bond, error) {
|
||||||
iter, err := k.Bonds.Indexes.Owner.MatchExact(ctx, owner)
|
iter, err := k.Bonds.Indexes.Owner.MatchExact(ctx, owner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []bondtypes.Bond{}, err
|
return []bondtypes.Bond{}, err
|
||||||
@ -187,7 +189,7 @@ func (k Keeper) GetBondsByOwner(ctx sdk.Context, owner string) ([]bondtypes.Bond
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetBondModuleBalances gets the bond module account(s) balances.
|
// GetBondModuleBalances gets the bond module account(s) balances.
|
||||||
func (k Keeper) GetBondModuleBalances(ctx sdk.Context) sdk.Coins {
|
func (k Keeper) GetBondModuleBalances(ctx context.Context) sdk.Coins {
|
||||||
moduleAddress := k.accountKeeper.GetModuleAddress(bondtypes.ModuleName)
|
moduleAddress := k.accountKeeper.GetModuleAddress(bondtypes.ModuleName)
|
||||||
balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress)
|
balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress)
|
||||||
|
|
||||||
@ -195,7 +197,7 @@ func (k Keeper) GetBondModuleBalances(ctx sdk.Context) sdk.Coins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateBond creates a new bond.
|
// CreateBond creates a new bond.
|
||||||
func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) {
|
func (k Keeper) CreateBond(ctx context.Context, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) {
|
||||||
// Check if account has funds.
|
// Check if account has funds.
|
||||||
for _, coin := range coins {
|
for _, coin := range coins {
|
||||||
balance := k.bankKeeper.HasBalance(ctx, ownerAddress, coin)
|
balance := k.bankKeeper.HasBalance(ctx, ownerAddress, coin)
|
||||||
@ -237,7 +239,7 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s
|
|||||||
return &bond, nil
|
return &bond, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) {
|
func (k Keeper) RefillBond(ctx context.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) {
|
||||||
if has, err := k.HasBond(ctx, id); !has {
|
if has, err := k.HasBond(ctx, id); !has {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -287,7 +289,7 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
|
|||||||
return &bond, nil
|
return &bond, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) {
|
func (k Keeper) WithdrawBond(ctx context.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) {
|
||||||
if has, err := k.HasBond(ctx, id); !has {
|
if has, err := k.HasBond(ctx, id); !has {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -325,7 +327,7 @@ func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAdd
|
|||||||
return &bond, nil
|
return &bond, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress) (*bondtypes.Bond, error) {
|
func (k Keeper) CancelBond(ctx context.Context, id string, ownerAddress sdk.AccAddress) (*bondtypes.Bond, error) {
|
||||||
if has, err := k.HasBond(ctx, id); !has {
|
if has, err := k.HasBond(ctx, id); !has {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -370,7 +372,7 @@ func (k Keeper) GetAuthority() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetParams gets the bond module's parameters.
|
// GetParams gets the bond module's parameters.
|
||||||
func (k Keeper) GetParams(ctx sdk.Context) (*bondtypes.Params, error) {
|
func (k Keeper) GetParams(ctx context.Context) (*bondtypes.Params, error) {
|
||||||
params, err := k.Params.Get(ctx)
|
params, err := k.Params.Get(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -380,11 +382,11 @@ func (k Keeper) GetParams(ctx sdk.Context) (*bondtypes.Params, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetParams sets the x/bond module parameters.
|
// SetParams sets the x/bond module parameters.
|
||||||
func (k Keeper) SetParams(ctx sdk.Context, params bondtypes.Params) error {
|
func (k Keeper) SetParams(ctx context.Context, params bondtypes.Params) error {
|
||||||
return k.Params.Set(ctx, params)
|
return k.Params.Set(ctx, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) getMaxBondAmount(ctx sdk.Context) (sdk.Coins, error) {
|
func (k Keeper) getMaxBondAmount(ctx context.Context) (sdk.Coins, error) {
|
||||||
params, err := k.GetParams(ctx)
|
params, err := k.GetParams(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -395,7 +397,7 @@ func (k Keeper) getMaxBondAmount(ctx sdk.Context) (sdk.Coins, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransferCoinsToModuleAccount moves funds from the bonds module account to another module account.
|
// TransferCoinsToModuleAccount moves funds from the bonds module account to another module account.
|
||||||
func (k Keeper) TransferCoinsToModuleAccount(ctx sdk.Context, id, moduleAccount string, coins sdk.Coins) error {
|
func (k Keeper) TransferCoinsToModuleAccount(ctx context.Context, id, moduleAccount string, coins sdk.Coins) error {
|
||||||
if has, err := k.HasBond(ctx, id); !has {
|
if has, err := k.HasBond(ctx, id); !has {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
errorsmod "cosmossdk.io/errors"
|
errorsmod "cosmossdk.io/errors"
|
||||||
|
govtypes "cosmossdk.io/x/gov/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/utils"
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/bond"
|
"git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
@ -30,7 +30,8 @@ func (ms msgServer) CreateBond(c context.Context, msg *bond.MsgCreateBond) (*bon
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
signerAddress, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -67,7 +68,8 @@ func (ms msgServer) RefillBond(c context.Context, msg *bond.MsgRefillBond) (*bon
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
signerAddress, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -105,7 +107,8 @@ func (ms msgServer) WithdrawBond(c context.Context, msg *bond.MsgWithdrawBond) (
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
signerAddress, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -143,7 +146,8 @@ func (ms msgServer) CancelBond(c context.Context, msg *bond.MsgCancelBond) (*bon
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
signerAddress, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,12 @@ import (
|
|||||||
"cosmossdk.io/core/appmodule"
|
"cosmossdk.io/core/appmodule"
|
||||||
"cosmossdk.io/core/store"
|
"cosmossdk.io/core/store"
|
||||||
"cosmossdk.io/depinject"
|
"cosmossdk.io/depinject"
|
||||||
|
"cosmossdk.io/depinject/appconfig"
|
||||||
|
bank "cosmossdk.io/x/bank/keeper"
|
||||||
|
govtypes "cosmossdk.io/x/gov/types"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
|
|
||||||
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/bond/module/v1"
|
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/bond/module/v1"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/bond"
|
"git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
@ -25,10 +25,10 @@ func (am AppModule) IsOnePerModuleType() {}
|
|||||||
func (am AppModule) IsAppModule() {}
|
func (am AppModule) IsAppModule() {}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
appmodule.Register(
|
appconfig.RegisterModule(
|
||||||
&modulev1.Module{},
|
&modulev1.Module{},
|
||||||
appmodule.Provide(ProvideModule),
|
appconfig.Provide(ProvideModule),
|
||||||
appmodule.Invoke(InvokeSetBondHooks),
|
appconfig.Invoke(InvokeSetBondHooks),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,26 +5,28 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"cosmossdk.io/core/appmodule"
|
appmodule "cosmossdk.io/core/appmodule/v2"
|
||||||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
"cosmossdk.io/core/registry"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/x/bond"
|
"git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
"git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ module.AppModuleBasic = AppModule{}
|
|
||||||
_ appmodule.AppModule = AppModule{}
|
_ appmodule.AppModule = AppModule{}
|
||||||
_ module.HasGenesis = AppModule{}
|
_ appmodule.HasGenesis = AppModule{}
|
||||||
|
_ appmodule.HasConsensusVersion = AppModule{}
|
||||||
|
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||||
|
|
||||||
|
_ module.HasGRPCGateway = AppModule{}
|
||||||
_ module.HasServices = AppModule{}
|
_ module.HasServices = AppModule{}
|
||||||
_ module.HasConsensusVersion = AppModule{}
|
|
||||||
_ module.HasInvariants = AppModule{}
|
_ module.HasInvariants = AppModule{}
|
||||||
|
// _ module.HasAminoCodec = AppModule{} // TODO
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConsensusVersion defines the current module consensus version
|
// ConsensusVersion defines the current module consensus version
|
||||||
@ -43,18 +45,12 @@ func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAppModuleBasic(m AppModule) module.AppModuleBasic {
|
// module.AppModule
|
||||||
return module.CoreAppModuleBasicAdaptor(m.Name(), m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// module.AppModuleBasic
|
|
||||||
|
|
||||||
// Name returns the bond module's name.
|
// Name returns the bond module's name.
|
||||||
func (AppModule) Name() string { return bond.ModuleName }
|
func (AppModule) Name() string { return bond.ModuleName }
|
||||||
|
|
||||||
// RegisterLegacyAminoCodec registers the bond module's types on the LegacyAmino codec.
|
// module.HasGRPCGateway
|
||||||
// New modules do not need to support Amino.
|
|
||||||
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
|
|
||||||
|
|
||||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bond module.
|
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bond module.
|
||||||
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
||||||
@ -63,25 +59,29 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appmodule.HasRegisterInterfaces
|
||||||
|
|
||||||
// RegisterInterfaces registers interfaces and implementations of the bond module.
|
// RegisterInterfaces registers interfaces and implementations of the bond module.
|
||||||
func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||||
bond.RegisterInterfaces(registry)
|
bond.RegisterInterfaces(registry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appmodule.HasConsensusVersion
|
||||||
|
|
||||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||||
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||||
|
|
||||||
// module.HasGenesis
|
// appmodule.HasGenesis
|
||||||
|
|
||||||
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
||||||
func (AppModule) DefaultGenesis(jsonCodec codec.JSONCodec) json.RawMessage {
|
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||||
return jsonCodec.MustMarshalJSON(bond.DefaultGenesisState())
|
return am.cdc.MustMarshalJSON(bond.DefaultGenesisState())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateGenesis performs genesis state validation for the module.
|
// ValidateGenesis performs genesis state validation for the module.
|
||||||
func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error {
|
func (am AppModule) ValidateGenesis(message json.RawMessage) error {
|
||||||
var data bond.GenesisState
|
var data bond.GenesisState
|
||||||
if err := cdc.UnmarshalJSON(message, &data); err != nil {
|
if err := am.cdc.UnmarshalJSON(message, &data); err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", bond.ModuleName, err)
|
return fmt.Errorf("failed to unmarshal %s genesis state: %w", bond.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,24 +90,25 @@ func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingCo
|
|||||||
|
|
||||||
// InitGenesis performs genesis initialization for the bond module.
|
// InitGenesis performs genesis initialization for the bond module.
|
||||||
// It returns no validator updates.
|
// It returns no validator updates.
|
||||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) error {
|
||||||
var genesisState bond.GenesisState
|
var genesisState bond.GenesisState
|
||||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
am.cdc.MustUnmarshalJSON(data, &genesisState)
|
||||||
|
|
||||||
if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
|
if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
|
||||||
panic(fmt.Sprintf("failed to initialize %s genesis state: %v", bond.ModuleName, err))
|
return fmt.Errorf("failed to initialize %s genesis state: %w", bond.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
||||||
// module.
|
// module.
|
||||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
|
||||||
gs, err := am.keeper.ExportGenesis(ctx)
|
gs, err := am.keeper.ExportGenesis(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to export %s genesis state: %v", bond.ModuleName, err))
|
panic(fmt.Sprintf("failed to export %s genesis state: %v", bond.ModuleName, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return cdc.MustMarshalJSON(gs)
|
return am.cdc.MustMarshalJSON(gs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// module.HasServices
|
// module.HasServices
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package onboarding
|
package onboarding
|
||||||
|
|
||||||
import (
|
import (
|
||||||
types "github.com/cosmos/cosmos-sdk/codec/types"
|
"cosmossdk.io/core/registry"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterInterfaces registers the interfaces types with the interface registry.
|
// RegisterInterfaces registers the interfaces types with the interface registry.
|
||||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
func RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||||
&MsgOnboardParticipant{},
|
&MsgOnboardParticipant{},
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,8 @@ func (ms msgServer) OnboardParticipant(c context.Context, msg *onboarding.MsgOnb
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Participant)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
signerAddress, err := addrCodec.StringToBytes(msg.Participant)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ package module
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"cosmossdk.io/core/address"
|
"cosmossdk.io/core/address"
|
||||||
"cosmossdk.io/core/appmodule"
|
appmodule "cosmossdk.io/core/appmodule/v2"
|
||||||
"cosmossdk.io/core/store"
|
"cosmossdk.io/core/store"
|
||||||
"cosmossdk.io/depinject"
|
"cosmossdk.io/depinject"
|
||||||
|
"cosmossdk.io/depinject/appconfig"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
|
||||||
@ -22,9 +22,9 @@ func (am AppModule) IsOnePerModuleType() {}
|
|||||||
func (am AppModule) IsAppModule() {}
|
func (am AppModule) IsAppModule() {}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
appmodule.Register(
|
appconfig.RegisterModule(
|
||||||
&modulev1.Module{},
|
&modulev1.Module{},
|
||||||
appmodule.Provide(ProvideModule),
|
appconfig.Provide(ProvideModule),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,23 +5,26 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"cosmossdk.io/core/appmodule"
|
appmodule "cosmossdk.io/core/appmodule/v2"
|
||||||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
"cosmossdk.io/core/registry"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/x/onboarding"
|
"git.vdb.to/cerc-io/laconicd/x/onboarding"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
|
"git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ module.AppModuleBasic = AppModule{}
|
|
||||||
_ module.HasGenesis = AppModule{}
|
|
||||||
_ appmodule.AppModule = AppModule{}
|
_ appmodule.AppModule = AppModule{}
|
||||||
|
_ appmodule.HasGenesis = AppModule{}
|
||||||
|
_ appmodule.HasConsensusVersion = AppModule{}
|
||||||
|
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||||
|
|
||||||
|
_ module.HasGRPCGateway = AppModule{}
|
||||||
|
_ module.HasServices = AppModule{}
|
||||||
|
// _ module.HasAminoCodec = AppModule{} // TODO
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConsensusVersion defines the current module consensus version.
|
// ConsensusVersion defines the current module consensus version.
|
||||||
@ -40,16 +43,12 @@ func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAppModuleBasic(m AppModule) module.AppModuleBasic {
|
// module.AppModule
|
||||||
return module.CoreAppModuleBasicAdaptor(m.Name(), m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name returns the onboarding module's name.
|
// Name returns the onboarding module's name.
|
||||||
func (AppModule) Name() string { return onboarding.ModuleName }
|
func (AppModule) Name() string { return onboarding.ModuleName }
|
||||||
|
|
||||||
// RegisterLegacyAminoCodec registers the onboarding module's types on the LegacyAmino codec.
|
// module.HasGRPCGateway
|
||||||
// New modules do not need to support Amino.
|
|
||||||
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
|
|
||||||
|
|
||||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the onboarding module.
|
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the onboarding module.
|
||||||
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
||||||
@ -58,14 +57,20 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appmodule.HasRegisterInterfaces
|
||||||
|
|
||||||
// RegisterInterfaces registers interfaces and implementations of the onboarding module.
|
// RegisterInterfaces registers interfaces and implementations of the onboarding module.
|
||||||
func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||||
onboarding.RegisterInterfaces(registry)
|
onboarding.RegisterInterfaces(registry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appmodule.HasConsensusVersion
|
||||||
|
|
||||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||||
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||||
|
|
||||||
|
// module.HasServices
|
||||||
|
|
||||||
// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries.
|
// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries.
|
||||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||||
// Register servers
|
// Register servers
|
||||||
@ -80,14 +85,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
||||||
func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||||
return cdc.MustMarshalJSON(onboarding.DefaultGenesisState())
|
return am.cdc.MustMarshalJSON(onboarding.DefaultGenesisState())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateGenesis performs genesis state validation for the circuit module.
|
// ValidateGenesis performs genesis state validation for the circuit module.
|
||||||
func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
|
func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
|
||||||
var data onboarding.GenesisState
|
var data onboarding.GenesisState
|
||||||
if err := cdc.UnmarshalJSON(bz, &data); err != nil {
|
if err := am.cdc.UnmarshalJSON(bz, &data); err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", onboarding.ModuleName, err)
|
return fmt.Errorf("failed to unmarshal %s genesis state: %w", onboarding.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,22 +101,23 @@ func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig,
|
|||||||
|
|
||||||
// InitGenesis performs genesis initialization for the onboarding module.
|
// InitGenesis performs genesis initialization for the onboarding module.
|
||||||
// It returns no validator updates.
|
// It returns no validator updates.
|
||||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) error {
|
||||||
var genesisState onboarding.GenesisState
|
var genesisState onboarding.GenesisState
|
||||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
am.cdc.MustUnmarshalJSON(data, &genesisState)
|
||||||
|
|
||||||
if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
|
if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
|
||||||
panic(fmt.Sprintf("failed to initialize %s genesis state: %v", onboarding.ModuleName, err))
|
return fmt.Errorf("failed to initialize %s genesis state: %w", onboarding.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
||||||
// module.
|
// module.
|
||||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
|
||||||
gs, err := am.keeper.ExportGenesis(ctx)
|
gs, err := am.keeper.ExportGenesis(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to export %s genesis state: %v", onboarding.ModuleName, err))
|
return nil, fmt.Errorf("failed to export %s genesis state: %w", onboarding.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cdc.MustMarshalJSON(gs)
|
return am.cdc.MustMarshalJSON(gs), nil
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ func GetCmdReserveAuthority() *cobra.Command {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ownerAddress, err := sdk.AccAddressFromBech32(args[1])
|
ownerAddress, err := utils.NewAddressCodec().StringToBytes(args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
"cosmossdk.io/core/registry"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
func RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||||
&MsgSetName{},
|
&MsgSetName{},
|
||||||
&MsgReserveAuthority{},
|
&MsgReserveAuthority{},
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
@ -9,7 +11,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// InitGenesis initializes the module state from a genesis state.
|
// InitGenesis initializes the module state from a genesis state.
|
||||||
func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error {
|
func (k *Keeper) InitGenesis(ctx_ context.Context, data *registry.GenesisState) error {
|
||||||
|
ctx, ok := sdk.TryUnwrapSDKContext(ctx_)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("failed to unwrap sdk.Context")
|
||||||
|
}
|
||||||
|
|
||||||
if err := k.Params.Set(ctx, data.Params); err != nil {
|
if err := k.Params.Set(ctx, data.Params); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -18,13 +25,11 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error
|
|||||||
if err := k.SaveRecord(ctx, record); err != nil {
|
if err := k.SaveRecord(ctx, record); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to record expiry queue if expiry time is in the future.
|
// Add to record expiry queue if expiry time is in the future.
|
||||||
expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime)
|
expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if expiryTime.After(ctx.BlockTime()) {
|
if expiryTime.After(ctx.BlockTime()) {
|
||||||
if err := k.insertRecordExpiryQueue(ctx, record); err != nil {
|
if err := k.insertRecordExpiryQueue(ctx, record); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -38,7 +43,6 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error
|
|||||||
if err := k.SaveNameAuthority(ctx, authority.Name, authority.Entry); err != nil {
|
if err := k.SaveNameAuthority(ctx, authority.Name, authority.Entry); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add authority name to expiry queue.
|
// Add authority name to expiry queue.
|
||||||
if err := k.insertAuthorityExpiryQueue(ctx, authority.Name, authority.Entry.ExpiryTime); err != nil {
|
if err := k.insertAuthorityExpiryQueue(ctx, authority.Name, authority.Entry.ExpiryTime); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -51,27 +55,28 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportGenesis exports the module state to a genesis state.
|
// ExportGenesis exports the module state to a genesis state.
|
||||||
func (k *Keeper) ExportGenesis(ctx sdk.Context) (*registry.GenesisState, error) {
|
func (k *Keeper) ExportGenesis(ctx_ context.Context) (*registry.GenesisState, error) {
|
||||||
|
ctx, ok := sdk.TryUnwrapSDKContext(ctx_)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("failed to unwrap sdk.Context")
|
||||||
|
}
|
||||||
|
|
||||||
params, err := k.Params.Get(ctx)
|
params, err := k.Params.Get(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
records, _, err := k.PaginatedListRecords(ctx, nil)
|
records, _, err := k.PaginatedListRecords(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
authorityEntries, err := k.ListNameAuthorityRecords(ctx, "")
|
authorityEntries, err := k.ListNameAuthorityRecords(ctx, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
names, err := k.ListNameRecords(ctx)
|
names, err := k.ListNameRecords(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -12,13 +12,13 @@ import (
|
|||||||
storetypes "cosmossdk.io/core/store"
|
storetypes "cosmossdk.io/core/store"
|
||||||
errorsmod "cosmossdk.io/errors"
|
errorsmod "cosmossdk.io/errors"
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
|
bank "cosmossdk.io/x/bank/keeper"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
"github.com/cosmos/cosmos-sdk/types/query"
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
||||||
"github.com/gibson042/canonicaljson-go"
|
"github.com/gibson042/canonicaljson-go"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
"github.com/ipld/go-ipld-prime"
|
"github.com/ipld/go-ipld-prime"
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
errorsmod "cosmossdk.io/errors"
|
errorsmod "cosmossdk.io/errors"
|
||||||
|
govtypes "cosmossdk.io/x/gov/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
|
|
||||||
"git.vdb.to/cerc-io/laconicd/utils"
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
@ -30,7 +30,8 @@ func (ms msgServer) SetRecord(c context.Context, msg *registrytypes.MsgSetRecord
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -68,7 +69,8 @@ func (ms msgServer) SetName(c context.Context, msg *registrytypes.MsgSetName) (*
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -105,11 +107,12 @@ func (ms msgServer) ReserveAuthority(c context.Context, msg *registrytypes.MsgRe
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
_, err = sdk.AccAddressFromBech32(msg.Owner)
|
_, err = addrCodec.StringToBytes(msg.Owner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -147,7 +150,8 @@ func (ms msgServer) SetAuthorityBond(c context.Context, msg *registrytypes.MsgSe
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -184,7 +188,8 @@ func (ms msgServer) DeleteName(c context.Context, msg *registrytypes.MsgDeleteNa
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -220,7 +225,8 @@ func (ms msgServer) RenewRecord(c context.Context, msg *registrytypes.MsgRenewRe
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -257,7 +263,8 @@ func (ms msgServer) AssociateBond(c context.Context, msg *registrytypes.MsgAssoc
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -294,7 +301,8 @@ func (ms msgServer) DissociateBond(c context.Context, msg *registrytypes.MsgDiss
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -333,7 +341,8 @@ func (ms msgServer) DissociateRecords(
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -369,7 +378,8 @@ func (ms msgServer) ReassociateRecords(c context.Context, msg *registrytypes.Msg
|
|||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
addrCodec := utils.NewAddressCodec()
|
||||||
|
_, err := addrCodec.StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconicd/utils"
|
||||||
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/registry/helpers"
|
"git.vdb.to/cerc-io/laconicd/x/registry/helpers"
|
||||||
@ -150,7 +151,7 @@ func (k Keeper) SaveNameRecord(ctx sdk.Context, lrn string, id string) error {
|
|||||||
|
|
||||||
// SetName creates a LRN -> Record ID mapping.
|
// SetName creates a LRN -> Record ID mapping.
|
||||||
func (k Keeper) SetName(ctx sdk.Context, msg registrytypes.MsgSetName) error {
|
func (k Keeper) SetName(ctx sdk.Context, msg registrytypes.MsgSetName) error {
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := utils.NewAddressCodec().StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -260,7 +261,7 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ownerAddress, err := sdk.AccAddressFromBech32(owner)
|
ownerAddress, err := utils.NewAddressCodec().StringToBytes(owner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid owner address.")
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid owner address.")
|
||||||
}
|
}
|
||||||
@ -369,7 +370,7 @@ func (k Keeper) SetAuthorityBond(ctx sdk.Context, msg registrytypes.MsgSetAuthor
|
|||||||
|
|
||||||
// DeleteName removes a LRN -> Record ID mapping.
|
// DeleteName removes a LRN -> Record ID mapping.
|
||||||
func (k Keeper) DeleteName(ctx sdk.Context, msg registrytypes.MsgDeleteName) error {
|
func (k Keeper) DeleteName(ctx sdk.Context, msg registrytypes.MsgDeleteName) error {
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := utils.NewAddressCodec().StringToBytes(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetParams - Get all parameters as types.Params.
|
// GetParams - Get all parameters as types.Params.
|
||||||
func (k Keeper) GetParams(ctx sdk.Context) (*registrytypes.Params, error) {
|
func (k Keeper) GetParams(ctx context.Context) (*registrytypes.Params, error) {
|
||||||
params, err := k.Params.Get(ctx)
|
params, err := k.Params.Get(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
@ -130,7 +131,7 @@ func (rk RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionId string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UsesBond returns true if the bond has associated records.
|
// UsesBond returns true if the bond has associated records.
|
||||||
func (rk RecordKeeper) UsesBond(ctx sdk.Context, bondId string) bool {
|
func (rk RecordKeeper) UsesBond(ctx context.Context, bondId string) bool {
|
||||||
iter, err := rk.k.Records.Indexes.BondId.MatchExact(ctx, bondId)
|
iter, err := rk.k.Records.Indexes.BondId.MatchExact(ctx, bondId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -4,12 +4,12 @@ import (
|
|||||||
"cosmossdk.io/core/appmodule"
|
"cosmossdk.io/core/appmodule"
|
||||||
"cosmossdk.io/core/store"
|
"cosmossdk.io/core/store"
|
||||||
"cosmossdk.io/depinject"
|
"cosmossdk.io/depinject"
|
||||||
|
"cosmossdk.io/depinject/appconfig"
|
||||||
|
bank "cosmossdk.io/x/bank/keeper"
|
||||||
|
govtypes "cosmossdk.io/x/gov/types"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
|
|
||||||
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/registry/module/v1"
|
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/registry/module/v1"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/auction"
|
"git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
@ -28,9 +28,9 @@ func (am AppModule) IsOnePerModuleType() {}
|
|||||||
func (am AppModule) IsAppModule() {}
|
func (am AppModule) IsAppModule() {}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
appmodule.Register(
|
appconfig.Register(
|
||||||
&modulev1.Module{},
|
&modulev1.Module{},
|
||||||
appmodule.Provide(ProvideModule),
|
appconfig.Provide(ProvideModule),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,15 +5,15 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"cosmossdk.io/client/v2/autocli"
|
||||||
"cosmossdk.io/core/appmodule"
|
"cosmossdk.io/core/appmodule"
|
||||||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
"cosmossdk.io/core/registry"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
"git.vdb.to/cerc-io/laconicd/x/registry/client/cli"
|
"git.vdb.to/cerc-io/laconicd/x/registry/client/cli"
|
||||||
@ -21,13 +21,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ module.AppModuleBasic = AppModule{}
|
|
||||||
_ appmodule.AppModule = AppModule{}
|
_ appmodule.AppModule = AppModule{}
|
||||||
_ module.HasGenesis = AppModule{}
|
|
||||||
_ module.HasServices = AppModule{}
|
|
||||||
_ module.HasConsensusVersion = AppModule{}
|
|
||||||
_ appmodule.HasEndBlocker = AppModule{}
|
_ appmodule.HasEndBlocker = AppModule{}
|
||||||
|
_ appmodule.HasGenesis = AppModule{}
|
||||||
|
_ appmodule.HasConsensusVersion = AppModule{}
|
||||||
|
_ appmodule.HasRegisterInterfaces = AppModule{}
|
||||||
|
|
||||||
|
_ module.HasGRPCGateway = AppModule{}
|
||||||
|
_ module.HasServices = AppModule{}
|
||||||
_ module.HasInvariants = AppModule{}
|
_ module.HasInvariants = AppModule{}
|
||||||
|
// _ module.HasAminoCodec = AppModule{} // TODO
|
||||||
|
|
||||||
|
_ autocli.HasCustomTxCommand = AppModule{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConsensusVersion defines the current module consensus version.
|
// ConsensusVersion defines the current module consensus version.
|
||||||
@ -46,18 +51,12 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAppModuleBasic(m AppModule) module.AppModuleBasic {
|
// module.AppModule
|
||||||
return module.CoreAppModuleBasicAdaptor(m.Name(), m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// module.AppModuleBasic
|
|
||||||
|
|
||||||
// Name returns the registry module's name.
|
// Name returns the registry module's name.
|
||||||
func (AppModule) Name() string { return registrytypes.ModuleName }
|
func (AppModule) Name() string { return registrytypes.ModuleName }
|
||||||
|
|
||||||
// RegisterLegacyAminoCodec registers the registry module's types on the LegacyAmino codec.
|
// module.HasGRPCGateway
|
||||||
// New modules do not need to support Amino.
|
|
||||||
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
|
|
||||||
|
|
||||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the registry module.
|
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the registry module.
|
||||||
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
||||||
@ -66,25 +65,27 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appmodule.HasRegisterInterfaces
|
||||||
|
|
||||||
// RegisterInterfaces registers interfaces and implementations of the registry module.
|
// RegisterInterfaces registers interfaces and implementations of the registry module.
|
||||||
func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||||
registrytypes.RegisterInterfaces(registry)
|
registrytypes.RegisterInterfaces(registry)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||||
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||||
|
|
||||||
// module.HasGenesis
|
// appmodule.HasGenesis
|
||||||
|
|
||||||
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
||||||
func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||||
return cdc.MustMarshalJSON(registrytypes.DefaultGenesisState())
|
return am.cdc.MustMarshalJSON(registrytypes.DefaultGenesisState())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateGenesis performs genesis state validation for the circuit module.
|
// ValidateGenesis performs genesis state validation for the circuit module.
|
||||||
func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
|
func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
|
||||||
var data registrytypes.GenesisState
|
var data registrytypes.GenesisState
|
||||||
if err := cdc.UnmarshalJSON(bz, &data); err != nil {
|
if err := am.cdc.UnmarshalJSON(bz, &data); err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", registrytypes.ModuleName, err)
|
return fmt.Errorf("failed to unmarshal %s genesis state: %w", registrytypes.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,24 +94,25 @@ func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig,
|
|||||||
|
|
||||||
// InitGenesis performs genesis initialization for the registry module.
|
// InitGenesis performs genesis initialization for the registry module.
|
||||||
// It returns no validator updates.
|
// It returns no validator updates.
|
||||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) error {
|
||||||
var genesisState registrytypes.GenesisState
|
var genesisState registrytypes.GenesisState
|
||||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
am.cdc.MustUnmarshalJSON(data, &genesisState)
|
||||||
|
|
||||||
if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
|
if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
|
||||||
panic(fmt.Sprintf("failed to initialize %s genesis state: %v", registrytypes.ModuleName, err))
|
return fmt.Errorf("failed to initialize %s genesis state: %w", registrytypes.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
||||||
// module.
|
// module.
|
||||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
|
||||||
gs, err := am.keeper.ExportGenesis(ctx)
|
gs, err := am.keeper.ExportGenesis(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to export %s genesis state: %v", registrytypes.ModuleName, err))
|
return nil, fmt.Errorf("failed to export %s genesis state: %w", registrytypes.ModuleName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cdc.MustMarshalJSON(gs)
|
return am.cdc.MustMarshalJSON(gs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// module.HasServices
|
// module.HasServices
|
||||||
@ -134,6 +136,8 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
|||||||
keeper.RegisterInvariants(ir, am.keeper)
|
keeper.RegisterInvariants(ir, am.keeper)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// autocli.HasCustomTxCommand
|
||||||
|
|
||||||
// Get the root tx command of this module
|
// Get the root tx command of this module
|
||||||
func (AppModule) GetTxCmd() *cobra.Command {
|
func (AppModule) GetTxCmd() *cobra.Command {
|
||||||
return cli.GetTxCmd()
|
return cli.GetTxCmd()
|
||||||
|
Loading…
Reference in New Issue
Block a user