-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d4c4dc
commit 00b7d29
Showing
20 changed files
with
176 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
build/ | ||
|
||
config.local.yaml | ||
Dockerfile | ||
# Coverage | ||
coverage.* | ||
vendor |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package types | ||
|
||
type AdminVestingRow struct { | ||
ID int64 `db:"id"` | ||
Address string `db:"address"` | ||
VestingPeriod int64 `db:"vesting_period"` | ||
RewardsPerPeriod DbCoins `db:"reward_per_period"` | ||
LastVestingTime int64 `db:"last_vesting_time"` | ||
VestingCounter int64 `db:"vesting_counter"` | ||
VestingPeriodsCount int64 `db:"vesting_periods_count"` | ||
Denom string `db:"denom"` | ||
} | ||
|
||
func NewAdminVestingRow(id int64, address string, vestingPeriod int64, rewardsPerPeriod DbCoins, lastVestingTime, vestingCounter int64, denom string) AdminVestingRow { | ||
return AdminVestingRow{ | ||
ID: id, | ||
Address: address, | ||
VestingPeriod: vestingPeriod, | ||
RewardsPerPeriod: rewardsPerPeriod, | ||
LastVestingTime: lastVestingTime, | ||
VestingCounter: vestingCounter, | ||
Denom: denom, | ||
} | ||
} | ||
|
||
func (r AdminVestingRow) Equal(s AdminVestingRow) bool { | ||
return r.RewardsPerPeriod.Equal(&s.RewardsPerPeriod) && | ||
r.ID == s.ID && | ||
r.Address == s.Address | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package accumulator | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
accumulatortypes "github.com/cosmos/cosmos-sdk/x/accumulator/types" | ||
|
||
tmtypes "github.com/tendermint/tendermint/types" | ||
|
||
"github.com/forbole/bdjuno/v4/types" | ||
|
||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
// HandleGenesis implements modules.Module | ||
func (m *Module) HandleGenesis(doc *tmtypes.GenesisDoc, appState map[string]json.RawMessage) error { | ||
log.Debug().Str("module", "accumulator").Msg("parsing genesis") | ||
|
||
// Read the genesis state | ||
var genState accumulatortypes.GenesisState | ||
err := m.cdc.UnmarshalJSON(appState[accumulatortypes.ModuleName], &genState) | ||
if err != nil { | ||
return fmt.Errorf("error while reading mint genesis data: %s", err) | ||
} | ||
|
||
// Save the params | ||
err = m.db.SaveAccumulatorParams(types.NewAccumulatorParams(genState.Params, doc.InitialHeight)) | ||
if err != nil { | ||
return fmt.Errorf("error while storing genesis mint params: %s", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package accumulator | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/x/authz" | ||
"github.com/rs/zerolog/log" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
accumulator "github.com/cosmos/cosmos-sdk/x/accumulator/types" | ||
juno "github.com/forbole/juno/v4/types" | ||
) | ||
|
||
// HandleMsgExec implements modules.AuthzMessageModule | ||
func (m *Module) HandleMsgExec(index int, _ *authz.MsgExec, _ int, executedMsg sdk.Msg, tx *juno.Tx) error { | ||
return m.HandleMsg(index, executedMsg, tx) | ||
} | ||
|
||
// HandleMsg implements modules.MessageModule | ||
func (m *Module) HandleMsg(_ int, msg sdk.Msg, tx *juno.Tx) error { | ||
log.Debug().Str("module", "accumulator").Msg("handle msg") | ||
|
||
switch cosmosMsg := msg.(type) { | ||
case *accumulator.MsgAddAdmin: | ||
return m.handleMsgAddAdmin(tx, cosmosMsg) | ||
default: | ||
break | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// handleMsgAddAdmin save a new admin to db | ||
func (m *Module) handleMsgAddAdmin(_ *juno.Tx, msg *accumulator.MsgAddAdmin) error { | ||
return m.db.SaveAdmin( | ||
msg.Address, | ||
msg.VestingPeriodsCount, | ||
0, | ||
msg.VestingPeriod, | ||
msg.RewardPerPeriod, | ||
msg.Denom, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.