Skip to content

Commit

Permalink
add staking middleware module
Browse files Browse the repository at this point in the history
  • Loading branch information
RustNinja committed Dec 16, 2023
1 parent a15f9fd commit 1a79bc5
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 0 deletions.
16 changes: 16 additions & 0 deletions proto/centauri/stakingmiddleware/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package centauri.stakingmiddleware.v1beta1;

import "gogoproto/gogo.proto";

option go_package = "x/stakingmiddleware/types";

// GenesisState defines the stakingmiddleware module's genesis state.
message GenesisState {
// last_total_power tracks the total amounts of bonded tokens recorded during
// the previous end block.
bytes last_total_power = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
321 changes: 321 additions & 0 deletions x/stakingmiddleware/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions x/stakingmiddleware/types/keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
)

// MinterKey is the key to use for the keeper store.
var (
DelegationKey = []byte{0x01} // key for a delegation
)

const (
// module name
ModuleName = "mint"

// StoreKey is the default store key for mint
StoreKey = ModuleName
)

// GetDelegationKey creates the key for delegator bond with validator
// VALUE: staking/Delegation
func GetDelegationKey(delAddr sdk.AccAddress, valAddr sdk.ValAddress) []byte {
return append(GetDelegationsKey(delAddr), address.MustLengthPrefix(valAddr)...)
}

func GetDelegationsKey(delAddr sdk.AccAddress) []byte {
return append(DelegationKey, address.MustLengthPrefix(delAddr)...)
}

0 comments on commit 1a79bc5

Please sign in to comment.