app

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 101 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Bech32MainPrefix defines the Bech32 prefix for account addresses
	Bech32MainPrefix = "kava"
	// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
	Bech32PrefixAccPub = Bech32MainPrefix + "pub"
	// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
	Bech32PrefixValAddr = Bech32MainPrefix + "val" + "oper"
	// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
	Bech32PrefixValPub = Bech32MainPrefix + "val" + "oper" + "pub"
	// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
	Bech32PrefixConsAddr = Bech32MainPrefix + "val" + "cons"
	// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
	Bech32PrefixConsPub = Bech32MainPrefix + "val" + "cons" + "pub"

	Bip44CoinType = 459 // see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
)

Variables

View Source
var (
	// DefaultNodeHome default home directories for the application daemon
	DefaultNodeHome string

	// ModuleBasics defines the module BasicManager is in charge of setting up basic,
	// non-dependant module elements, such as codec registration
	// and genesis verification.
	ModuleBasics = module.NewBasicManager(
		auth.AppModuleBasic{},
		genutil.AppModuleBasic{},
		bank.AppModuleBasic{},
		capability.AppModuleBasic{},
		staking.AppModuleBasic{},
		mint.AppModuleBasic{},
		distr.AppModuleBasic{},
		gov.NewAppModuleBasic(
			paramsclient.ProposalHandler,
			distrclient.ProposalHandler,
			upgradeclient.ProposalHandler,
			upgradeclient.CancelProposalHandler,
		),
		params.AppModuleBasic{},
		crisis.AppModuleBasic{},
		slashing.AppModuleBasic{},
		authzmodule.AppModuleBasic{},
		feegrantmodule.AppModuleBasic{},
		upgrade.AppModuleBasic{},
		evidence.AppModuleBasic{},
		vesting.AppModuleBasic{},

		evm.AppModuleBasic{},
		feemarket.AppModuleBasic{},

		bridge.AppModuleBasic{},
	)
)

Functions

func GeneratePrivKeyAddressPairs

func GeneratePrivKeyAddressPairs(n int) (keys []cryptotypes.PrivKey, addrs []sdk.AccAddress)

GeneratePrivKeyAddressPairsFromRand generates (deterministically) a total of n private keys and addresses.

func GetMaccPerms

func GetMaccPerms() map[string][]string

GetMaccPerms returns a copy of the module account permissions

func MakeEncodingConfig

func MakeEncodingConfig() params.EncodingConfig

MakeEncodingConfig creates an EncodingConfig and registers the app's types on it.

func RegisterSwaggerAPI

func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router)

RegisterSwaggerAPI registers swagger route with API Server

func SetBech32AddressPrefixes

func SetBech32AddressPrefixes(config *sdk.Config)

SetBech32AddressPrefixes sets the global prefix to be used when serializing addresses to bech32 strings.

func SetBip44CoinType

func SetBip44CoinType(config *sdk.Config)

SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets.

func SetSDKConfig

func SetSDKConfig() *sdk.Config

SetSDKConfig configures the global config with kava app specific parameters. It does not seal the config to allow modification in tests.

Types

type AuthBankGenesisBuilder

type AuthBankGenesisBuilder struct {
	AuthGenesis authtypes.GenesisState
	BankGenesis banktypes.GenesisState
}

AuthBankGenesisBuilder is a tool for creating a combined auth and bank genesis state. Helper methods create basic accounts types and add them to a default genesis state. All methods return the builder so method calls can be chained together.

Example:

// create a single account genesis state
builder := NewAuthBankGenesisBuilder().WithSimpleAccount(testUserAddress, testCoins)
genesisState := builder.BuildMarshalled()

func NewAuthBankGenesisBuilder

func NewAuthBankGenesisBuilder() *AuthBankGenesisBuilder

NewAuthBankGenesisBuilder creates a AuthBankGenesisBuilder containing default genesis states.

func (*AuthBankGenesisBuilder) BuildMarshalled

func (builder *AuthBankGenesisBuilder) BuildMarshalled(cdc codec.JSONCodec) GenesisState

BuildMarshalled assembles the final GenesisState and json encodes it into a generic genesis type.

func (*AuthBankGenesisBuilder) WithAccounts

func (builder *AuthBankGenesisBuilder) WithAccounts(account ...authtypes.GenesisAccount) *AuthBankGenesisBuilder

WithAccounts adds accounts of any type to the genesis state.

func (*AuthBankGenesisBuilder) WithBalances

func (builder *AuthBankGenesisBuilder) WithBalances(balance ...banktypes.Balance) *AuthBankGenesisBuilder

WithBalances adds balances to the bank genesis state. It does not check the new denom is in the genesis state denom metadata.

func (*AuthBankGenesisBuilder) WithSimpleAccount

func (builder *AuthBankGenesisBuilder) WithSimpleAccount(address sdk.AccAddress, balance sdk.Coins) *AuthBankGenesisBuilder

WithSimpleAccount adds a standard account to the genesis state.

func (*AuthBankGenesisBuilder) WithSimpleModuleAccount

func (builder *AuthBankGenesisBuilder) WithSimpleModuleAccount(moduleName string, balance sdk.Coins, permissions ...string) *AuthBankGenesisBuilder

WithSimpleModuleAccount adds a module account to the genesis state.

func (*AuthBankGenesisBuilder) WithSimplePeriodicVestingAccount

func (builder *AuthBankGenesisBuilder) WithSimplePeriodicVestingAccount(address sdk.AccAddress, balance sdk.Coins, periods vestingtypes.Periods, firstPeriodStartTimestamp int64) *AuthBankGenesisBuilder

WithSimplePeriodicVestingAccount adds a periodic vesting account to the genesis state.

type BridgeApp

type BridgeApp struct {
	*baseapp.BaseApp

	// keepers
	AccountKeeper    authkeeper.AccountKeeper
	BankKeeper       bankkeeper.Keeper
	CapabilityKeeper *capabilitykeeper.Keeper
	StakingKeeper    stakingkeeper.Keeper
	SlashingKeeper   slashingkeeper.Keeper
	MintKeeper       mintkeeper.Keeper
	DistrKeeper      distrkeeper.Keeper
	GovKeeper        govkeeper.Keeper
	CrisisKeeper     crisiskeeper.Keeper
	UpgradeKeeper    upgradekeeper.Keeper
	ParamsKeeper     paramskeeper.Keeper
	FeeGrantKeeper   feegrantkeeper.Keeper
	AuthzKeeper      authzkeeper.Keeper
	EvidenceKeeper   evidencekeeper.Keeper

	// Ethermint keepers
	EvmKeeper       *evmkeeper.Keeper
	FeeMarketKeeper feemarketkeeper.Keeper

	// Bridge keepers
	BridgeKeeper bridgekeeper.Keeper
	// contains filtered or unexported fields
}

BridgeApp implements an extended ABCI application.

func NewApp

func NewApp(
	logger log.Logger,
	db dbm.DB,
	traceStore io.Writer,
	loadLatest bool,
	skipUpgradeHeights map[int64]bool,
	homePath string,
	invCheckPeriod uint,
	encodingConfig bridgeparams.EncodingConfig,
	appOpts servertypes.AppOptions,
	baseAppOptions ...func(*baseapp.BaseApp),
) *BridgeApp

NewApp returns a reference to a new initialized kava bridge application.

func (*BridgeApp) AppCodec

func (app *BridgeApp) AppCodec() codec.Codec

AppCodec returns BridgeApp's app codec.

NOTE: This is solely to be used for testing purposes as it may be desirable for modules to register their own custom testing types.

func (*BridgeApp) BeginBlocker

func (app *BridgeApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock

BeginBlocker updates every begin block

func (*BridgeApp) BlockedAddrs

func (app *BridgeApp) BlockedAddrs() map[string]bool

BlockedAddrs returns all the app's module account addresses that are not allowed to receive external tokens.

func (*BridgeApp) EndBlocker

func (app *BridgeApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock

EndBlocker updates every end block

func (*BridgeApp) ExportAppStateAndValidators

func (app *BridgeApp) ExportAppStateAndValidators(
	forZeroHeight bool, jailAllowedAddrs []string,
) (servertypes.ExportedApp, error)

ExportAppStateAndValidators exports the state of the application for a genesis file.

func (*BridgeApp) GetKey

func (app *BridgeApp) GetKey(storeKey string) *sdk.KVStoreKey

GetKey returns the KVStoreKey for the provided store key.

NOTE: This is solely to be used for testing purposes.

func (*BridgeApp) GetMemKey

func (app *BridgeApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey

GetMemKey returns the MemStoreKey for the provided mem key.

NOTE: This is solely used for testing purposes.

func (*BridgeApp) GetSubspace

func (app *BridgeApp) GetSubspace(moduleName string) paramstypes.Subspace

GetSubspace returns a param subspace for a given module name.

NOTE: This is solely to be used for testing purposes.

func (*BridgeApp) GetTKey

func (app *BridgeApp) GetTKey(storeKey string) *sdk.TransientStoreKey

GetTKey returns the TransientStoreKey for the provided store key.

NOTE: This is solely to be used for testing purposes.

func (*BridgeApp) InitChainer

func (app *BridgeApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain

InitChainer updates at chain initialization

func (*BridgeApp) InterfaceRegistry

func (app *BridgeApp) InterfaceRegistry() types.InterfaceRegistry

InterfaceRegistry returns BridgeApp's InterfaceRegistry

func (*BridgeApp) LegacyAmino

func (app *BridgeApp) LegacyAmino() *codec.LegacyAmino

LegacyAmino returns BridgeApp's amino codec.

NOTE: This is solely to be used for testing purposes as it may be desirable for modules to register their own custom testing types.

func (*BridgeApp) LoadHeight

func (app *BridgeApp) LoadHeight(height int64) error

LoadHeight loads state at a particular height

func (*BridgeApp) ModuleAccountAddrs

func (app *BridgeApp) ModuleAccountAddrs() map[string]bool

ModuleAccountAddrs returns all the app's module account addresses.

func (*BridgeApp) Name

func (app *BridgeApp) Name() string

Name returns the name of the App

func (*BridgeApp) RegisterAPIRoutes

func (app *BridgeApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig)

RegisterAPIRoutes registers all application module routes with the provided API server.

func (*BridgeApp) RegisterTendermintService

func (app *BridgeApp) RegisterTendermintService(clientCtx client.Context)

func (*BridgeApp) RegisterTxService

func (app *BridgeApp) RegisterTxService(clientCtx client.Context)

func (*BridgeApp) SimulationManager

func (app *BridgeApp) SimulationManager() *module.SimulationManager

SimulationManager implements the SimulationApp interface

type GenesisState

type GenesisState map[string]json.RawMessage

GenesisState represents the genesis state of the blockchain. It is a map from module names to module genesis states.

func NewDefaultGenesisState

func NewDefaultGenesisState() GenesisState

NewDefaultGenesisState generates the default state for the application.

func NewFundedGenStateWithCoins

func NewFundedGenStateWithCoins(cdc codec.JSONCodec, coins []sdk.Coins, addresses []sdk.AccAddress) GenesisState

NewFundedGenStateWithCoins creates a (auth and bank) genesis state populated with accounts from the given addresses and coins.

func NewFundedGenStateWithSameCoins

func NewFundedGenStateWithSameCoins(cdc codec.JSONCodec, balance sdk.Coins, addresses []sdk.AccAddress) GenesisState

NewFundedGenStateWithSameCoins creates a (auth and bank) genesis state populated with accounts from the given addresses and balance.

func NewFundedGenStateWithSameCoinsWithModuleAccount

func NewFundedGenStateWithSameCoinsWithModuleAccount(cdc codec.JSONCodec, coins sdk.Coins, addresses []sdk.AccAddress, modAcc *authtypes.ModuleAccount) GenesisState

NewFundedGenStateWithSameCoinsWithModuleAccount creates a (auth and bank) genesis state populated with accounts from the given addresses and balance along with an empty module account

type TestApp

type TestApp struct {
	BridgeApp
}

TestApp is a simple wrapper around an App. It exposes internal keepers for use in integration tests. This file also contains test helpers. Ideally they would be in separate package. Basic Usage:

Create a test app with NewTestApp, then all keepers and their methods can be accessed for test setup and execution.

Advanced Usage:

Some tests call for an app to be initialized with some state. This can be achieved through keeper method calls (ie keeper.SetParams(...)).
However this leads to a lot of duplicated logic similar to InitGenesis methods.
So TestApp.InitializeFromGenesisStates() will call InitGenesis with the default genesis state.
and TestApp.InitializeFromGenesisStates(authState, cdpState) will do the same but overwrite the auth and cdp sections of the default genesis state
Creating the genesis states can be combersome, but helper methods can make it easier such as NewAuthGenStateFromAccounts below.

func NewTestApp

func NewTestApp() TestApp

NewTestApp creates a new TestApp

Note, it also sets the sdk config with the app's address prefix, coin type, etc.

func NewTestAppFromSealed

func NewTestAppFromSealed() TestApp

NewTestAppFromSealed creates a TestApp without first setting sdk config.

func (*TestApp) AppCodec

func (app *TestApp) AppCodec() codec.Codec

AppCodec returns the app's app codec.

func (TestApp) CheckBalance

func (tApp TestApp) CheckBalance(t *testing.T, ctx sdk.Context, owner sdk.AccAddress, expectedCoins sdk.Coins)

CheckBalance requires the account address has the expected amount of coins.

func (TestApp) FundAccount

func (tApp TestApp) FundAccount(ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error

FundAccount is a utility function that funds an account by minting and sending the coins to the address.

func (TestApp) FundModuleAccount

func (tApp TestApp) FundModuleAccount(ctx sdk.Context, recipientMod string, amounts sdk.Coins) error

FundModuleAccount is a utility function that funds a module account by minting and sending the coins to the address.

func (TestApp) GetAccountKeeper

func (tApp TestApp) GetAccountKeeper() authkeeper.AccountKeeper

nolint

func (TestApp) GetBankKeeper

func (tApp TestApp) GetBankKeeper() bankkeeper.Keeper

func (TestApp) GetBridgeKeeper

func (tApp TestApp) GetBridgeKeeper() bridgekeeper.Keeper

func (TestApp) GetCrisisKeeper

func (tApp TestApp) GetCrisisKeeper() crisiskeeper.Keeper

func (TestApp) GetDistrKeeper

func (tApp TestApp) GetDistrKeeper() distkeeper.Keeper

func (TestApp) GetGovKeeper

func (tApp TestApp) GetGovKeeper() govkeeper.Keeper

func (TestApp) GetMintKeeper

func (tApp TestApp) GetMintKeeper() mintkeeper.Keeper

func (TestApp) GetParamsKeeper

func (tApp TestApp) GetParamsKeeper() paramskeeper.Keeper

func (TestApp) GetSlashingKeeper

func (tApp TestApp) GetSlashingKeeper() slashingkeeper.Keeper

func (TestApp) GetStakingKeeper

func (tApp TestApp) GetStakingKeeper() stakingkeeper.Keeper

func (TestApp) InitializeFromGenesisStates

func (tApp TestApp) InitializeFromGenesisStates(genesisStates ...GenesisState) TestApp

InitializeFromGenesisStates calls InitChain on the app using the default genesis state, overwitten with any passed in genesis states

func (TestApp) InitializeFromGenesisStatesWithTime

func (tApp TestApp) InitializeFromGenesisStatesWithTime(genTime time.Time, genesisStates ...GenesisState) TestApp

InitializeFromGenesisStatesWithTime calls InitChain on the app using the default genesis state, overwitten with any passed in genesis states and genesis Time

func (TestApp) InitializeFromGenesisStatesWithTimeAndChainID

func (tApp TestApp) InitializeFromGenesisStatesWithTimeAndChainID(genTime time.Time, chainID string, genesisStates ...GenesisState) TestApp

InitializeFromGenesisStatesWithTimeAndChainID calls InitChain on the app using the default genesis state, overwitten with any passed in genesis states and genesis Time

func (*TestApp) LegacyAmino

func (app *TestApp) LegacyAmino() *codec.LegacyAmino

LegacyAmino returns the app's amino codec.

func (TestApp) NewQueryServerTestHelper

func (tApp TestApp) NewQueryServerTestHelper(ctx sdk.Context) *baseapp.QueryServiceTestHelper

NewQueryServerTestHelper creates a new QueryServiceTestHelper that wraps the provided sdk.Context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL