Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajansari95/escrow module account #265

Merged
merged 4 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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