Skip to content

Commit

Permalink
Merge pull request #265 from ingenuity-build/ajansari95/escrowModuleA…
Browse files Browse the repository at this point in the history
…ccount

added escrow module account
  • Loading branch information
ajansari95 authored Dec 19, 2022
2 parents 4be1a23 + cea8a49 commit 3441f0f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ jobs:
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: ./coverage_nogen.txt
flags: unittests
fail_ci_if_error: true
Expand Down
19 changes: 10 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,16 @@ var (
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
// TODO: Remove Burner from mint - for dev/test only;
minttypes.ModuleName: {authtypes.Minter, authtypes.Burner},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
icatypes.ModuleName: nil,
claimsmanagertypes.ModuleName: nil,
interchainstakingtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
interchainquerytypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter, authtypes.Burner},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
icatypes.ModuleName: nil,
claimsmanagertypes.ModuleName: nil,
interchainstakingtypes.ModuleName: {authtypes.Minter},
interchainstakingtypes.EscrowModuleAccount: {authtypes.Burner},
interchainquerytypes.ModuleName: nil,
// TODO: Remove Burner from participationrewards - for dev/test only;
participationrewardstypes.ModuleName: {authtypes.Burner},
airdroptypes.ModuleName: nil,
Expand Down
4 changes: 2 additions & 2 deletions x/interchainstaking/keeper/ibc_packet_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (k *Keeper) HandleWithdrawForUser(ctx sdk.Context, zone *types.Zone, msg *b
if len(withdrawalRecord.Amount) == 1 && len(msg.Amount) == 1 && msg.Amount[0].Denom == withdrawalRecord.Amount[0].Denom && withdrawalRecord.Amount.IsEqual(msg.Amount) {
k.Logger(ctx).Info("found matching withdrawal; marking as completed")
k.UpdateWithdrawalRecordStatus(ctx, &withdrawalRecord, WithdrawStatusCompleted)
if err = k.BankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(withdrawalRecord.BurnAmount)); err != nil {
if err = k.BankKeeper.BurnCoins(ctx, types.EscrowModuleAccount, sdk.NewCoins(withdrawalRecord.BurnAmount)); err != nil {
// if we can't burn the coins, fail.
return err
}
Expand All @@ -357,7 +357,7 @@ func (k *Keeper) HandleWithdrawForUser(ctx sdk.Context, zone *types.Zone, msg *b
// we just removed the last element
k.Logger(ctx).Info("found matching withdrawal; marking as completed")
k.UpdateWithdrawalRecordStatus(ctx, &withdrawalRecord, WithdrawStatusCompleted)
if err = k.BankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(withdrawalRecord.BurnAmount)); err != nil {
if err = k.BankKeeper.BurnCoins(ctx, types.EscrowModuleAccount, sdk.NewCoins(withdrawalRecord.BurnAmount)); err != nil {
// if we can't burn the coins, fail.
return err
}
Expand Down
10 changes: 8 additions & 2 deletions x/interchainstaking/keeper/ibc_packet_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,10 @@ func (s *KeeperTestSuite) TestHandleWithdrawForUser() {
// set up zones
for _, record := range records {
app.InterchainstakingKeeper.SetWithdrawalRecord(ctx, record)
app.BankKeeper.MintCoins(ctx, icstypes.ModuleName, sdk.NewCoins(record.BurnAmount))
err := app.BankKeeper.MintCoins(ctx, icstypes.ModuleName, sdk.NewCoins(record.BurnAmount))
s.Require().NoError(err)
err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, icstypes.ModuleName, icstypes.EscrowModuleAccount, sdk.NewCoins(record.BurnAmount))
s.Require().NoError(err)
}

// trigger handler
Expand Down Expand Up @@ -672,7 +675,10 @@ func (s *KeeperTestSuite) TestHandleWithdrawForUserLSM() {
// set up zones
for _, record := range records {
app.InterchainstakingKeeper.SetWithdrawalRecord(ctx, record)
app.BankKeeper.MintCoins(ctx, icstypes.ModuleName, sdk.NewCoins(record.BurnAmount))
err := app.BankKeeper.MintCoins(ctx, icstypes.ModuleName, sdk.NewCoins(record.BurnAmount))
s.Require().NoError(err)
err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, icstypes.ModuleName, icstypes.EscrowModuleAccount, sdk.NewCoins(record.BurnAmount))
s.Require().NoError(err)
}

// trigger handler
Expand Down
4 changes: 4 additions & 0 deletions x/interchainstaking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, accountKeeper auth
panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
}

if addr := accountKeeper.GetModuleAddress(types.EscrowModuleAccount); addr == nil {
panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
}

if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}
Expand Down
2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (k msgServer) RequestRedemption(goCtx context.Context, msg *types.MsgReques
hash := sha256.Sum256(append(msg.GetSignBytes(), heightBytes...))
hashString := hex.EncodeToString(hash[:])

if err := k.BankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(msg.Value)); err != nil {
if err := k.BankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.EscrowModuleAccount, sdk.NewCoins(msg.Value)); err != nil {
return nil, err
}

Expand Down
3 changes: 2 additions & 1 deletion x/interchainstaking/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const (
ICASuffixWithdrawal = "withdrawal"
ICASuffixPerformance = "performance"

BankStoreKey = "store/bank/key"
BankStoreKey = "store/bank/key"
EscrowModuleAccount = "ics-escrow-account"
)

var (
Expand Down

0 comments on commit 3441f0f

Please sign in to comment.